PowerShell - Set-Culture doesn't seem to change anything
Asked Answered
P

2

11

I have a Cloud Service Web Role that I need to run some PowerShell on to ensure the server is always setup in the right culture: en-AU.

The reason for this is that Microsoft could, at anytime, reset the culture values.

When I run:

Get-Culture

I get:

1033             en-US            English (United States)

So then I run:

Set-Culture en-AU

But I still get:

1033             en-US            English (United States)

I have tried many things but nothing seems to really change the culture.

Any help would be great.

Prolongation answered 14/12, 2015 at 5:19 Comment(1)
Changing user locale does not affect already started PowerShell instances. You have to start new PowerShell process, so it pickup new value.Engrossing
U
9

The root cause is because you are not running the PowerShell with Administrator privilege.

Set-Culture needs Administrator privilege to be set on the system.

Just run your PowerShell in Administrator mode and your culture will be set to the new one as below:

enter image description here

Hope this helps!

Urena answered 14/12, 2015 at 6:21 Comment(7)
If you were to run the PowerShell script in the Azure Cloud Service web role, I would recommend to add #Requires -RunAsAdministrator in your PowerShell script to make sure your PowerShell will have the elevated privilege to set cultureUrena
If the above able to resolve your issue, I will edit my answer.Urena
What is the status of this issue? Is anymore support needed?Urena
your answer was correct. So as far as I understand, I should always run powershell ISE as administrator?Prolongation
@RuSs, thanks for your feedback. Yes I would recommend that if you intend to modify system settingsUrena
Thanks; changes took place immediately but I had to close and reopen the powershell terminal before Get-Culture to get the updated value.Superadd
For me its works only on PowerShell 7 (on windows server 2022).Yoruba
R
6

Like petseral said in a comment above:

Changing user locale does not affect already started PowerShell instances.
You have to start new PowerShell process.

Readytowear answered 4/8, 2019 at 14:32 Comment(1)
This is exactly the answer for meSelfinterest

© 2022 - 2024 — McMap. All rights reserved.