INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Issue creating registry key on remote computer

Issue creating registry key on remote computer

(OP)
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

RE: Issue creating registry key on remote computer

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close