run a reg file remotely

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
jramon.r@tv3.cat
Posts: 21
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Mon Jan 19, 2015 2:32 am

run a reg file remotely

Post 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

jvierra
Posts: 14213
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: run a reg file remotely

Post 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

User avatar
jramon.r@tv3.cat
Posts: 21
Joined: Mon Jan 19, 2015 2:32 am

Re: run a reg file remotely

Post by jramon.r@tv3.cat »

But I want to do it for 30 servers

Thanks

jvierra
Posts: 14213
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: run a reg file remotely

Post by jvierra »

Look in the Gallery and you will find many examples that can do exactly that.

jvierra
Posts: 14213
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: run a reg file remotely

Post 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

User avatar
jramon.r@tv3.cat
Posts: 21
Joined: Mon Jan 19, 2015 2:32 am

Re: run a reg file remotely

Post by jramon.r@tv3.cat »

I found it

The problem was the .reg file security.

Thanks

Locked