When using the follwoing to create a key, the result is not as expected. what is wrong? Thanks
$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", $ip)
$key = $baseKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\",$true)
$key.CreateSubKey('mapdrives')
$key.SetValue('mapdrives', 'C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File "C:\mapdrives.ps1"')
the expected result:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]
"mapdrives"="C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy Unrestricted -File \"C:\\mapdrives.ps1\""