Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Getting Access Denied with Enter-PSSession

$
0
0

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?


Viewing all articles
Browse latest Browse all 6937

Trending Articles