# mrscounter # # Script to collect and merge Exchange MRS Performance Counters about migrations and post them to PRTG # # Pending: Parallel execution to # Pending: Grab Exchange Servers automatically # param ( $serverlist = @("EX01", "ex02", "ex03"), [string]$prtgurl = "http://prtg.msxfaq.net:5050/mrsjobcounter?content=", [string]$exchangeuri = "http://dag.msxfaq.net/Powershell", $validstatus = @("AutoSuspended", "Completed", "CompletedWithWarning", "CompletionInProgress", "Failed", "InProgress", "Queued", "ReadyToComplete", "Suspended") ) Set-PSDebug -Strict write-host "PRTG-MRSJobcounter: Start" write-host "PRTG-MRSJobcounter: Loading Exchange PowerShell" if ((Get-PSSnapin | where {$_.name -eq "Microsoft.Exchange.Management.PowerShell.E2010"}) -eq $null) { write-output ("PRTG-MRSJobcounter: Creating Exchange Remote Session") Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 } write-host "PRTG-MRSJobcounter: Loading Move Request List" Set-ADServerSettings -ViewEntireForest:$true $joblist = Get-MoveRequest | group status -NoElement $prtgresult = '' foreach ($status in $validstatus) { write-host "PRTG-MRSJobcounter: Processing Status $status" $prtgresult+= ' '+$status+' '+ ($joblist | where {$_.name -eq $status}).count +' 0 Anzahl ' } $prtgresult+= '' write-host "PRTG-MRSJobcounter: Sending Data to $prtgurl" $httprequest=[system.Net.HttpWebRequest]::Create($prtgurl+$prtgresult); $data = $httprequest.getresponse(); $stat = $data.statuscode; $data.Close(); # no errorhandling here write-host "PRTG-MRSJobcounter: End"