Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue creating registry key on remote computer

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
I am running my powershell from my machine as an administrator domain account that as local admin access on a server. I am trying to create a registry key with the below and the code works to copy my directory, but when trying to create the new registry key it fails.

Code:
# Check if you can ping list of servers
$servers = get-content "C:\Temp\servers.txt"
$pingable  = @()
$notpingable = @()
$regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"

foreach ($s in $servers) {
    if (Test-Connection -ComputerName $s -Quiet -Count 1)
        {
            $pingable += $s
            write-host = "Connect     $s"
            Copy-Item $source -Destination \\$servers\$dest -Recurse -Force
            New-Item -Path $regpath -Name GIL-Login -Value "C:\Program Files (x86)\Chevron\GIL Login\GILogin.exe"           
        } 
    else
        {
            $notpingable += $s
            write-host = "Failed      $s"
        }
}

When I run it I get:

New-Item : Requested registry access is not allowed.
At C:\Temp\mytest.ps1:13 char:13
+ New-Item -Path $regpath -Name GIL-Login -Value "C:\Program Files (x8 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (HKEY_LOCAL_MACH...rentVersion\Run:String) [New-Item], SecurityException
+ FullyQualifiedErrorId : System.Security.SecurityException,Microsoft.PowerShell.Commands.NewItemCommand

 
Where are you creating the key on a remote computer? Is this wrapped in an Invoke-Command script block or something? Looking at the code you posted, it would attempt to write the registry key to the local computer, which may very well be the cause of your access denied errors. My apologies if I overlooked something.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top