Hello,
I am trying to write a registry key and value to a remote machine.
A short snippet of what I am trying to do:
If (Test-Connection $Computer -Quiet){
Push-Location
Enter-PSSession $Computer -Credential $Credentials
If (Test-Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer){
Set-Location HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer' -Name RemappedElevatedProxiesPolicy -Value 1 -PropertyType Dword
}
I am setting the proper credentials prior to this, but when run, I get,
Enter-PSSession : Connecting to remote server $Computer failed with the following error message : Access is denied.
Now, I can do everything I want to do in my script if I use regedit and connect to the target computer but it fails with the script.
Ideas?