Share via


Get-ItemProperty on Remote Server

Question

Thursday, June 20, 2013 6:44 PM

I need to get the values of a registry key on a remote server. Tried the below without any luck? Is there a simpler method?

$strMachineName = "mail02-ny"
$objReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $strMachineName)
$objRegKey= $objReg.OpenSubKey('\HKLM\System\CurrentControlSet\services\MSExchangeAB\Parameters')
$objRegkey.RPCTCPORT()

All replies (11)

Thursday, June 20, 2013 7:54 PM âś…Answered | 2 votes

I just ran this as a test and it worked fine:

$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $machine)$regKey = $reg.OpenSubKey("SOFTWARE\\Microsoft\\ASP.NET")$regKey.GetValue("RootVer")

So for your's you may try this:

$strMachineName = "mail02-ny"$objReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $strMachineName)$objRegKey= $objReg.OpenSubKey("SYSTEM\\CurrentControlSet\\services\\MSExchangeAB\\Parameters")$objRegkey.GetValue("RPCTCPORT")

If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.


Thursday, June 20, 2013 7:48 PM

Now when you say you tried without any luck, are you receiving any error messages or anything?

If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.


Thursday, June 20, 2013 7:51 PM


Thursday, June 20, 2013 8:03 PM

It does not throw any errors anymore, but I am not getting the property of the registry key output?

Thanks.


Thursday, June 20, 2013 8:16 PM

You are postive the reg key has a value named "RPCTCPORT"? So if you open regedit on the machine in question, and browse to that key, that value does exist?

If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.


Thursday, June 20, 2013 8:18 PM

All set. Had a typo.


Thursday, June 20, 2013 8:19 PM

what *are* you getting, what *is* happening?

Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.


Thursday, June 20, 2013 8:19 PM

All set. Had a typo.

OK, cool. I know I had a typo in the code which I fixed, so not sure if it was my fault or not

If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.


Thursday, June 20, 2013 8:20 PM

I fixed that typo, but had my own!

Thanks again.


Thursday, June 20, 2013 9:17 PM

One more question. If I need to query a value where there are spaces, how can I achieve this?

$strMachineName = "$Server"
$objReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $strMachineName)
$objRegKey= $objReg.OpenSubKey("SYSTEM\CurrentControlSet\services\MSExchangeIS\ParametersSystem")
$Reg2 = $objRegkey.GetValue**("Reread Logon Quotas Interval")**


Friday, June 21, 2013 12:37 PM

I do not think I ever seen a reg value with spaces, so I created one for testing, and it works just as is

If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.