run a reg file remotely

Ask your 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.
This topic is 6 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
jramon.r@tv3.cat
Posts: 25
Last visit: Tue Jan 11, 2022 4:23 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 25
Last visit: Tue Jan 11, 2022 4:23 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 25
Last visit: Tue Jan 11, 2022 4:23 am

Re: run a reg file remotely

Post by jramon.r@tv3.cat »

I found it

The problem was the .reg file security.

Thanks
This topic is 6 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked