Page 1 of 1

run a reg file remotely

Posted: Fri Sep 22, 2017 2:00 am
by jramon.r@tv3.cat
I want to run a .reg file remotely for changing its register
The code is

$nomservidor="ssvspospocpa2"
$pathserver="c:\temp\snmp.reg"

Invoke-Command -ComputerName $nomservidor -ScriptBlock {

Start-Process -FilePath "c:\windows\regedit.exe" -ArgumentList "/s $pathserver"

} -Credential pospocpa\administrator


It doesn't work although there is no error.
If I run

Start-Process -FilePath "c:\windows\regedit.exe" -ArgumentList "/s $pathserver"

directly in the server it Works ok so I don't Know where is the problem

Thanks

Re: run a reg file remotely

Posted: Fri Sep 22, 2017 2:26 am
by jvierra
Use the remote registry classes of Net. They can do it without remoting.

See examples in the TechNet Gallery: http://gallery.technet.microsoft.com

Re: run a reg file remotely

Posted: Fri Sep 22, 2017 2:40 am
by jramon.r@tv3.cat
But I want to do it for 30 servers

Thanks

Re: run a reg file remotely

Posted: Fri Sep 22, 2017 2:43 am
by jvierra
Look in the Gallery and you will find many examples that can do exactly that.

Re: run a reg file remotely

Posted: Fri Sep 22, 2017 3:43 am
by jvierra
Here is a module you can install that will do what you ask:

Run this command:
find-module PoshRegistry

To install run this command:
find-module PoshRegistry | Install-Module

Re: run a reg file remotely

Posted: Fri Sep 22, 2017 4:30 am
by jramon.r@tv3.cat
I found it

The problem was the .reg file security.

Thanks