I wrote a script to get all the exchange server names you specify and it gets their version numbers. But I cannot get PRTG to display them. Rather have the names anyway but after reading multiple forum posts this is not possible I guess. Maybe someone with some insight into this would really help me.
powershell script:
param ( [string]$EXCHServers = '' ) $ExchangeServers = $EXCHServers.Split(",") $Excharray = @() ForEach ($Server in $ExchangeServers) { $Excharray += @(Invoke-Command -ComputerName $Server -ScriptBlock {Get-Command Exsetup.exe | ForEach-Object {$_.FileversionInfo}}) } $CompareArray = @() $ResultArray = @() $HTML = New-Object -Com "HTMLFile" $WebResponse = Invoke-WebRequest "https://technet.microsoft.com/en-us/library/hh135098%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396" -UseBasicParsing If ($WebResponse.StatusCode -eq '200') { $HTML.IHTMLDocument2_write($WebResponse.RawContent) $HTMLperLine = @($HTML.all.tags("p") | % InnerText) ForEach ($Server in $Excharray) { ForEach ($line in $HTMLperLine) { if ($line -match $Server.ProductVersion) { [int]$lineindex = ([array]::IndexOf($HTMLperLine, $Server.ProductVersion)) $ResultArray += $Server.PSComputerName+";"+$HTMLperLine[($lineindex-2)]+";"+$Server.ProductVersion } } } } ELSE { write-host "no http 200 status" exit } ##################### ##Begin XML PRTG##### ##################### write-host "<prtg>" Foreach ($ResultServer in $ResultArray) { $Servername,$ExchVersionText,$ExchProductVersion = $ResultServer.split(";") ##debug #write-host $Servername #write-host $ExchVersionText #write-host $ExchProductVersion If ($Servername -or $ExchVersionText) { write-host "<result>" write-host "<channel>$($Servername)</channel>" write-host "<value>$($ExchProductVersion)</value>" #write-host "<text>$($ExchVersionText)</text>" write-host "<float>1</float>" write-host "</result>" } } write-host "</prtg>" ##################### ## End XML PRTG##### ##################### Exit 0
sample result output:
<prtg> <result> <channel>EXCHSRV01</channel> <value>14.03.0361.001</value> <float>1</float> </result> <result> <channel>EXCHSRV02</channel> <value>14.03.0361.001</value> <float>1</float> </result> </prtg>
Would be nice to see their version number, I dont need alerts just the numbers displayed and maybe make a report later with all the servers and their versions. But the sensor factory sensor should be sufficient for that.
Add comment