Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Read remote registry - service woes

$
0
0

I want to read the remote registry using PowerShell which I know will require [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey()

Firstly though, I need to ensure the RemoteRegistry service is running.  I probably should also check the StartMode of it first before I try and start it.  I can use WMI and Invoke-WmiMethod to do this.

Here then are my questions.

1) If I change the start mode, do I then need to do some form of loop and check the mode change has applied before moving on to start the service?

2) After starting the service, will I have to code a check that waits for the service to start before I try reading the remote registry with .NET?  I could either do WMI queries in a loop or use a [System.ServiceProcess.ServiceControllerStatus] and .WaitForStatus() with a timeout.  Why can't a WMI Method optionally wait before returning?

It all seems horribly involved just to read a remote registry!  How do other people tackle this common task?  Thanks for any thoughts!

Oh and why on earth do the .NET classes not allow for changing the start mode either?!


Viewing all articles
Browse latest Browse all 8583

Trending Articles