Answered by:
Checking for presence of registry key

Question
-
Hi
I have about 30 Windows 2008 Servers running Exchange 2010. We have a third party application running on them named AddOn
We need to check whether these servers have the following key value set
HKLM\CurrentControlSet\Services\AddO n\paramete rs\cleanup
"Logs" = "1"
It would be helpful to export this to a CSV file with the following columns:
Servername
Registry key presence/value (whichever is easier)
Space left on D: drive
Server OS
I was thinking of creating a Powershell script to do this, with an input of servers.csv. I assume I need a WMI query for the last two.
The method I was going to use was :- Create a function
- Within that function have WMI queries for Space/ Server OS
- Create a new object and Add-Member for the Space/OS
But what I'm not sure on is how I test for the presence of that particular key and how I'd report on it (can I create an object and Add-Member again)?
Tuesday, April 2, 2013 7:55 PM
Answers
-
Some ideas in this thread will help you with reading the remote registry value: http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/c60a07ae-6645-4f35-b458-e063931da6e9
Inspired by Carlsberg.
Tuesday, April 2, 2013 8:32 PM -
Hi Jason,
This should do the trick for you. You might have to play with the registry string to get it to work
as I do not have the "AddOn" program loaded. (I left an example string for you to see how it works.)
# servers are a list of servers in the following format: \\server1
$servers = get-content C:\Scripts\CheckServersRegistry.txtforeach ($server in $servers){
Try {# tested with this string
$command = "reg query " + $server + "\HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Setup\Results\SelfUpdate" + " /v RebootFailCount"
#command = "reg query " + $server + "HKLM\CurrentControlSet\Ser
vices\AddO n\paramete rs\cleanup" + " /v Logs" $result = Invoke-Expression $command
$server + " is set to " + $result
}
Catch {
$servererror = $server + " not configured."
}
}$result will contain a string like this that you can parse and check for your values:
\\server is set to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Setup\Results\SelfUpdate RebootFailC
ount REG_DWORD 0x0---------------------------------------------------
Please mark as answer if this helps you.
Wednesday, April 3, 2013 7:27 PM
All replies
-
Some ideas in this thread will help you with reading the remote registry value: http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/c60a07ae-6645-4f35-b458-e063931da6e9
Inspired by Carlsberg.
Tuesday, April 2, 2013 8:32 PM -
Hi Jason,
This should do the trick for you. You might have to play with the registry string to get it to work
as I do not have the "AddOn" program loaded. (I left an example string for you to see how it works.)
# servers are a list of servers in the following format: \\server1
$servers = get-content C:\Scripts\CheckServersRegistry.txtforeach ($server in $servers){
Try {# tested with this string
$command = "reg query " + $server + "\HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Setup\Results\SelfUpdate" + " /v RebootFailCount"
#command = "reg query " + $server + "HKLM\CurrentControlSet\Ser
vices\AddO n\paramete rs\cleanup" + " /v Logs" $result = Invoke-Expression $command
$server + " is set to " + $result
}
Catch {
$servererror = $server + " not configured."
}
}$result will contain a string like this that you can parse and check for your values:
\\server is set to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Setup\Results\SelfUpdate RebootFailC
ount REG_DWORD 0x0---------------------------------------------------
Please mark as answer if this helps you.
Wednesday, April 3, 2013 7:27 PM