Saturday, January 19, 2008

PowerShell + LogParser

Love the ability to use LogParser to query specific configuration settings on a server, or group of servers.  Didn't like that I had to "up arrow" and change server names.  LogParser nicely solves the 'how do I query a remote registry key' without spinning through WMI, or anything else (e.g. C# snippet). 

I can definitely see where I could potentially expand the following script to include a list of resources (e.g. servers) and resource paths (e.g. registry) in either a text file, or xml, then loop through it using PowerShell and report on the output.

Of course, your probably thinking, well what about SMS, or MOM?  Believe it or not, I do not have ready access to those tools, even though at least SMS is available to the enterprise.  For now, its easier to just blow n' go, using a sample like below.  At the end of the day, I would really like an application where I could declare a baseline configuration, and then report against a group of servers for any differences.  Maybe 'Oslo' will help solve that problem, Team Architect certainly didn't.  Or I could just force my way into SMS!

 
$computers = @("APP01","APP02","JDE01","JDE02","JDE04","JDE05","JDE06","JDE07","JDE08", "BIZ01", "BIZ02", "BIZ03", "DSI01", "DSI02")

foreach($computer in $computers)
{

$out = logparser "SELECT ValueName, Value, ValueType FROM \\$computer\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters WHERE ValueName = 'EnableTCPChimney'" -i:REG -rtp:70 -q:ON

write-host $computer " - " $out


$out = logparser "SELECT ValueName, Value, ValueType FROM \\$computer\HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters WHERE ValueName = 'SynAttackProtect'" -i:REG -rtp:70 -q:ON

if ( [string]::isnullorempty($out) )
{
write-host $computer "SynAttackProtect not found"
}
else
{
write-host $computer " - " $out
}


}



 

1 comment:

  1. Anonymous3:49 AM

    excellent !


    never thought I could query powershell providers from logparser

    ReplyDelete