Advertisement
stephanlinke

[PRTG] enable all notifications

Dec 3rd, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $prtgserver="";
  2. $protocol="";
  3. $port=80;
  4. $user="prtgadmin";
  5. $passhash="";
  6. $configpath = "C:\ProgramData\Paessler\PRTG Network Monitor\PRTG Configuration.dat";
  7.  
  8. [xml]$Configuration = (Get-Content $configpath);
  9. $Notifications = $Configuration.SelectNodes("//notification[@id]")
  10.  
  11. foreach($notification in $Notifications){
  12.     $URL = "{0}://{1}:{2}/api/pause.htm?id={3}&action=1&username={4}&passhash={5}" -f $protocol,$prtgserver,$port,$Notification.id,$user,$passhash;
  13.     $Response = (Invoke-WebRequest -UseBasicParsing $URL);
  14.     if($Response.StatusCode -eq 200){
  15.         Write-Host ("[{0}] " -f (Get-Date)) -NoNewline;
  16.         Write-Host "[success] " -ForegroundColor Green -NoNewline;
  17.         Write-Host ("Notification '{0}' has been resumed successfully" -f $notification.data.name.Trim())
  18.     }
  19.     else {
  20.         Write-Host ("[{0}] " -f (Get-Date)) -NoNewline;
  21.         Write-Host "[error] " -ForegroundColor Red -NoNewline;
  22.         Write-Host ("Something went wrong for '{0}', please check if the URL {1} works in a browser" -f $notification.data.name.Trim(),$URL)
  23.     }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement