Richard Siddaway's Blog

A forum question regarding retrieving WMI based data from multiple servers and displaying it as HTML was interesting.  I would approach it like this

$servers=Get-Content-PathC:\scripts\servers.txt$data=@()foreach($serverin$servers){$compdata=New-Object-TypeNamePSObject-Property@{Computer=$serverContactable=$falseLastBootTime=""AllowTSConnections=$false}if(Test-Connection-ComputerName$server-Quiet-Count1){$compdata.Contactable=$true$os=Get-WmiObject-ClassWin32_OperatingSystem-ComputerName$server$compdata.LastBootTime=$os.ConvertToDateTime($os.LastBootUpTime)$ts=Get-WmiObject-Namespaceroot\cimv2\terminalservices-ClassWin32_TerminalServiceSetting-ComputerName$server-AuthenticationPacketPrivacyif($ts.AllowTSConnections-eq1){$compdata.AllowTSConnections=$true}}$data+=$compdata}$data$data|ConvertTo-Html|Out-File-FilePathc:\scripts\report.htmlInvoke-Item-Pathc:\scripts\report.html

Put the list of servers in a text file & read it in via…

View original post 80 altre parole

Annunci