Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Copy Folder and add Registry Key/Value

$
0
0

I am Trying to copy a folder from a UNC path to a remote PC and add registry Key and value on that remote PC also. The Registry piece seems to work but the file copy dose not. Any ideas?
Thanks

$servername = "serv1"

copy-item -Path "\\shares\home\user\AdminTools\bginfo\" -Recurse -Destination "\\$servername\c$\BGInfo"

Invoke-Command -ComputerName $servername -ScriptBlock {

$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", $servername)
$key = $baseKey.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run\", $true)
$key.SetValue('bginfo', 'c:\\bginfo\\bginfo.bat')
}


Viewing all articles
Browse latest Browse all 13067

Trending Articles