Reputation: 1381
I'm trying to add/edit the registry key with powershell:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment Name:Station Value: 2 Type: String
I was trying to do it with:
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -Name "Station" -ItemType "String -Value "2" -force
However this just creates a subfolder named "Station" under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet001\Control\Session Manager\Environment with a name: "default" and a value: "2"
I don't understand one why it makes a key in the 001 CCS tab, and two why it makes it as a sub-folder instead of a key name. What am I missing here.
Upvotes: 1
Views: 953
Reputation: 16792
When using the registry provider, "Items" correspond to KEYS (i.e. "folders"), whereas "Item Properties" correspond to VALUES. So you want to use the New-ItemProperty
cmdlet for this.
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name 'Station' -Value '2' -PropertyType 'string'
You can view complete documentation on the registry provider by running Get-Help Registry
.
Upvotes: 6