stephanlinke

[PRTG] Get Comments and run command with it

Aug 18th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. param([int]$sensorid, [string]$database,[string]$host,[string]$username,[string]$password)
  2.  
  3. $PRTGServer = "";
  4. $PRTGPort   = 80;
  5. $PRTGProtocol   = "http";
  6. $PRTGUser   = "prtgadmin";
  7. $PRTGPassHash   = "";
  8.  
  9.  
  10. # Get the current sensor comment into a variable
  11. [XML]$CurrentComment = (New-Object System.Net.WebClient).DownloadString("$($PRTGprotocol)://$($PRTGserver):$($PRTGport)/api/getobjectproperty.htm?id=$($SensorID)&name=Comments&username=$($PRTGuser)&passhash=$($PRTGpasshash)")
  12. $StoredProcedureCall = $CurrentComment.prtg.result
  13.  
  14. $Result = (Start-Process -FilePath "C:\Sensors\SQLspXML.exe" -ArgumentList "-Input -d=$($database) -sp='CALL $($StoredProcedureCall)' -s=$($host) -u=$($username) -p=$($password)");
  15. $Result
Advertisement
Add Comment
Please, Sign In to add comment