I'm running a PowerShell script across thousands of computers globally and due to our machines having many different languages (Spanish, French, German, etc.) some of the commands aren't working and having to write code multiple times to suite each locale is a sin when I could have just written the code once. As just one example, I'm trying to check who the group members are of the local administrators group on workstations.
Example Command in English
$localGroupAdmins = (Get-LocalGroupMember -SID "S-1-5-32-544" | Where-Object {$_.ObjectClass -eq "Group"}).Name
Need to specify the SID of the local administrators group since that word is also in another language (no problem for now). Issue really is that the object class is "grupo" for Spanish machines, "Gruppe" for German machines and so on so doing the Where-Object {$_.ObjectClass... is not consistent and of course fails.
Therefore, how can I get this over to English for just the PowerShell session without impacting the user and changing their UI? Last thing I want is to have calls to the Help Desk stating their computer is now in English.
I've tried links below but nothing works. Also, script runs in system context if that matters.
Temporarily change powershell language to English? Forcing PowerShell errors output in English on localized systems https://community.spiceworks.com/topic/560456-how-to-change-powershell-script-errors-to-english