When you use some language oriented objects of workstation like local admin user or local admins group it’s names and other properties depends on the language of OS.
That’s why it’s helpful to know the language of OS you are using or writing scripts for.
For this purposes here it is a script which generates a csv file with workstation names and OS languages.
$path = "c:\oslang.csv"
#deleting old file if exist one
if (Test-Path "$path")
{
Remove-Item "$path"
}
Get-QADComputer | ForEach-Object `
{
if (Test-Connection $_.name -count 1 -quiet)
{
$pcname=$_.name
#making for current workstation a variable with oscode
$oscode = Get-WmiObject Win32_OperatingSystem -ComputerName $pcname -ErrorAction continue | foreach {$_.oslanguage}
#making a variable to switch to needed text depending on oscode (decimal language code)
#it can be wided by adding your language code for example from here: http://www.science.co.il/language/Locale-Codes.asp
$switch = switch ($oscode) `
{
1033 {"English"};
1049 {"Russian"};
default {"Unknown"}
}
#core operation for getting oslanguage using above variables
Get-WmiObject Win32_OperatingSystem -ComputerName $pcname -ErrorAction stop | foreach {$_.csname + ", " + $switch >> $path}
#trapping error code for last operation. on operation before this last one pointed an option -erroraction continue which means that it's not capturing with trap cmdlet and exclude double writing workstation names with errors to csv file
trap {$pcname + ", " + "{0}" -f $_.Exception.Message >> $path; continue}
}
}
Hi Andreas,
Here is some information taken from http://technet.microsoft.com/en-us/library/hh847854.aspx:
The $PSUICulture variable stores the name of the UI language used on the system for user interface elements such as menus and text strings.
Hey I’ve got a question: How can I retrieve the UI language for the current user? We’ve installed a windows language pack and ever since we can’t use the os language anymore for groups since the original language code is still returned but doesn’t work in the context of the user.