Skip to content

Microsoft Powershells output is not local system language independet or - why "query user" sometimes returns USERNAME and BENUTZERNAME

I am working in an enviroment where some systems have a locale (or how microsoft is calling it "culture") of "en-US" or "de-DE".

Today I had to debug a script that is not outputting something. After a while, I've figured out that the result of query user /server:<server> is returning objects with different properties.

If the current locale is en-US, the property USERNAME exists. If the current locale is de-DE, the property BENUTZERNAME exists.

This is pretty sad since I could not find a way to set the culture within my powershell script to en-US.

What I've tried and what did not worked.

[System.Threading.Thread]::CurrentThread.CurrentCulture = "de-DE";
[System.Threading.Thread]::CurrentThread.CurrentUICulture = "de-DE";
[cultureinfo]::currentculture = 'de-DE';
[cultureinfo]::CurrentUICulture = 'de-DE';
Set-Culture de-DE

How did I solved it? I've added an or condition to support both properties, which is sad.

Where-Object { ($_.USERNAME -like "*$userNameToFilterAgainstOrNull*") -or ($_.BENUTZERNAME -like "*$userNameToFilterAgainstOrNull*") }

Good luck!

Translate to de es fr it pt ja

Manage your windows installed software with chocolatey and backup your collection by using this little manager

While working more and more with windows, I wanted the freedom of having a centralized packagemanager under the hood to ease up "keeping software up to date" or manage installed software in general.

Right now, I ended up using chocolatey.

After using it and building up my "finest selection" of installed software, I wanted to backup this collection.

I found the needed powershell commands pretty fast. Since I am a lazy person, I wanted to even ease up this by just having two scripts doing all the "heavy work" for backing up and restore this software collection.

After 30 minutes of work, I was able to release version one of my chocolatey manager.

This is a simple wrapper to backup and restore packages maintained by chocolatey.

The "" will install chocolatey if not installed. The "" will create a local file containing the currently installed packages.

Hope I can put you too more into the lazy area with this.

Cheers, artodeto

Translate to de es fr it pt ja