Got this working.
Its suppose to be $regPath.PSPath
instead of $regPath.Name
New-ItemProperty -Path $regPath.PSPath -Name "NetworkName" -Value "DOMAIN" -PropertyType String
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have the below code which adds a newKey in the Registry, then adds Property and Value to the Key.
$reg = "Registry::\"
$keyPath = Join-Path -Path $reg -ChildPath 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures'
$keyPath
$regPath = New-item -Path $keyPath -Name "010103000F0000F0A00000000F0000F02C87FF61F728E3750B595CBC8787E88B96F707107614712C139EE8F64A2CFB3C"
$regPath.Name
New-ItemProperty -Path $regPath.Name -Name "NetworkName" -Value "DOMAIN" -PropertyType String
Which results in the below output:
PS C:\Users\Administrator\Desktop\Configuration> $reg = "Registry::\"
PS C:\Users\Administrator\Desktop\Configuration> $keyPath = Join-Path -Path $reg -ChildPath 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures'
PS C:\Users\Administrator\Desktop\Configuration> $keyPath
Registry::\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures
PS C:\Users\Administrator\Desktop\Configuration> $regPath = New-item -Path $keyPath -Name "010103000F0000F0A00000000F0000F02C87FF61F728E3750B595CBC8787E88B96F707107614712C139EE8F64A2CFB3C"
PS C:\Users\Administrator\Desktop\Configuration> $regPath.Name
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0A00000000F0000F02C87FF61F728E3750B595CBC8787E88B96F707107614712C139EE8F64A2CFB3C
New-ItemProperty : Cannot find path
'C:\Users\Administrator\Desktop\Configuration\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows NT\Cur
rentVersion\NetworkList\Signatures\010103000F0000F0A00000000F0000F02C87FF61F728E3750B595CBC8787E88B96F707107614712C139E
E8F64A2CFB3C' because it does not exist.
At line:1 char:1
+ New-ItemProperty -Path $regPath.Name -Name "NetworkName" -Value "DOMA ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The variable $regPath.Name results in the absolute path of the Key as in the code above, when I pass it to the next command for some reason its appending the $regPath.Name
value with C:\Users\Administrator\Desktop\Configuration\HKEY_LOCAL_MACHINE
address instead of parsing it as a registry address.
Any idea what's going on ?
Thank You
Got this working.
Its suppose to be $regPath.PSPath
instead of $regPath.Name
New-ItemProperty -Path $regPath.PSPath -Name "NetworkName" -Value "DOMAIN" -PropertyType String
Got this working.
Its suppose to be $regPath.PSPath
instead of $regPath.Name
New-ItemProperty -Path $regPath.PSPath -Name "NetworkName" -Value "DOMAIN" -PropertyType String