10

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.

RuSs
  • 1,725
  • 1
  • 29
  • 47
  • 4
    Changing user locale does not affect already started PowerShell instances. You have to start new PowerShell process, so it pickup new value. – user4003407 Dec 14 '15 at 05:39

2 Answers2

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!

juvchan
  • 6,113
  • 2
  • 22
  • 35
  • 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 culture – juvchan Dec 14 '15 at 12:17
  • If the above able to resolve your issue, I will edit my answer. – juvchan Dec 14 '15 at 12:17
  • What is the status of this issue? Is anymore support needed? – juvchan Dec 17 '15 at 05:18
  • your answer was correct. So as far as I understand, I should always run powershell ISE as administrator? – RuSs Dec 17 '15 at 19:57
  • @RuSs, thanks for your feedback. Yes I would recommend that if you intend to modify system settings – juvchan Dec 17 '15 at 21:14
  • Thanks; changes took place immediately but I had to close and reopen the powershell terminal before `Get-Culture` to get the updated value. – MakotoE Jul 08 '19 at 23:04
  • For me its works only on PowerShell 7 (on windows server 2022). – Feiga Lubow Apr 24 '23 at 05:22
5

Like petseral said in a comment above:

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

Luke
  • 1,734
  • 2
  • 15
  • 18