What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

One-Time maintenance window list

Votes:

0

Hi, Do you have a way to view all the scheduled Maintenance windows in a list. It would be nice to check they are set etc.

Thanks Mike

list maintenance one-time

Created on Oct 8, 2013 4:44:06 PM



Best Answer

Accepted Answer

Votes:

6

This article applies to PRTG Network Monitor 16 or later.

Disclaimer: This script is a proof-of-concept and comes as-is. It comes without support. Using it happens at your own risk.

Introduction

This script will give you a list of configured maintenance windows within PRTG, including the object ID, name, type, start/end of the maintenance and its duration. Here's what it looks like:


All configured maintenance windows in PRTG

Installation

Remarks

The script needs to be run on the PRTG server itself as it reads the configuration file.

Setup
  1. Create a new PowerShell script on the desktop of the PRTG server
  2. Paste the script, save it and start it

Script

## PRTG configuration 
[string] $ConfigurationFilePath = ((Get-ItemProperty -Path "hklm:SOFTWARE\Wow6432Node\Paessler\PRTG Network Monitor\Server\Core" -Name "Datapath").DataPath) + "PRTG Configuration.dat"
   [xml] $configuration = New-Object -TypeName XML;
         $configuration.Load($ConfigurationFilePath)

## PRTGs internal start date
$Start = Get-Date -Date "1899-12-30 23:00:00Z"

## nodes 
$prtgGroups  = $configuration.SelectNodes("//group")
$prtgDevices = $configuration.SelectNodes("//device")
$prtgSensors = $configuration.SelectNodes("//sensor")
#endregion

#region function
<# Function Section
#################################
All functions of the script are defined here. 
############################### #>

<# Function Name: This-GetXMLValue
#################################
Used For: Retrieving XML values. Returns inherited if the trim fails (i.e. if there's nothing to trim
#################################
Parameters: 
# [xml]    object - the object that should have it's node extracted
# [string] node   - the node you want retrieved
################################# #>
function This-GetXMLValue($object,[string]$node){

    try   { $value = $object.data.$node.trim(); }
    catch { $value = "Inherited" }

    return $value;

}
#endregion

$MaintenanceList = @(); 

foreach($prtgGroup in $prtgGroups){

    if((($prtgGroup.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtggroup.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtggroup.data.maintend)
        $maintenanceEnabled = "Yes"

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
    
    $Group = [pscustomobject]@{
            ID   = $prtgGroup.ID
            Name = $prtgGroup.data.name.Trim()
            Type = "Group"
            "Maintenance Start" = $maintenanceStart
            "Maintenance End"   = $maintenanceEnd
            Duration            = $duration
           
           }
     $MaintenanceList += $Group 
    }
}

foreach($prtgDevice in $prtgDevices){

    if((($prtgDevice.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtgDevice.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtgDevice.data.maintend)
      

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
    
        $Device = [pscustomobject]@{
                ID   = $prtgDevice.ID
                Name = $prtgDevice.data.name.Trim()
                Type = "Device"
            
                "Maintenance Start" = $maintenanceStart
                "Maintenance End"   = $maintenanceEnd
                Duration            = $duration
           
        }
        $MaintenanceList += $Device;
    }
}

foreach($prtgSensor in $prtgSensors){

    if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtgSensor.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtgSensor.data.maintend)
        $maintenanceEnabled = "Yes"

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
   
        $Sensor = [pscustomobject]@{
                ID   = $prtgSensor.ID
                Name = $prtgSensor.data.name.Trim()
                Type = "Sensor"
                "Has Maintenance Configured" = $maintenanceEnabled
                "Maintenance Start" = $maintenanceStart
                "Maintenance End"   = $maintenanceEnd
                 Duration            = $duration
               }
         $MaintenanceList += $Sensor; 
        }
}

$MaintenanceList | Out-GridView -Title "Maintenance List"

Created on Apr 21, 2017 7:27:37 AM by  Stephan Linke [Paessler Support]

Last change on Mar 13, 2018 11:30:02 AM by  Torsten Lindner [Paessler Support]



12 Replies

Votes:

0

I'm afraid such a function is not yet available, but I have added it to the wish list for future consideration. Please bear with us.

Created on Oct 9, 2013 12:32:19 PM by  Patrick Hutter [Paessler Support] (7,225) 3 3



Votes:

0

thank you.

Created on Oct 9, 2013 12:34:47 PM



Votes:

0

Question about this: Has this been implemented yet? Because I can't find this functionality (running version 17.1.29.1427)

Reason: One of our providers announced Maintenance on one of our connections. So I added a One time maintenance to a list of devices. However, the provider just notified us they changed the date of the maintenance. So now I want to remove the previously added One time maintenance, so the devices won't be paused for nothing.

Created on Apr 20, 2017 2:29:39 PM



Accepted Answer

Votes:

6

This article applies to PRTG Network Monitor 16 or later.

Disclaimer: This script is a proof-of-concept and comes as-is. It comes without support. Using it happens at your own risk.

Introduction

This script will give you a list of configured maintenance windows within PRTG, including the object ID, name, type, start/end of the maintenance and its duration. Here's what it looks like:


All configured maintenance windows in PRTG

Installation

Remarks

The script needs to be run on the PRTG server itself as it reads the configuration file.

Setup
  1. Create a new PowerShell script on the desktop of the PRTG server
  2. Paste the script, save it and start it

Script

## PRTG configuration 
[string] $ConfigurationFilePath = ((Get-ItemProperty -Path "hklm:SOFTWARE\Wow6432Node\Paessler\PRTG Network Monitor\Server\Core" -Name "Datapath").DataPath) + "PRTG Configuration.dat"
   [xml] $configuration = New-Object -TypeName XML;
         $configuration.Load($ConfigurationFilePath)

## PRTGs internal start date
$Start = Get-Date -Date "1899-12-30 23:00:00Z"

## nodes 
$prtgGroups  = $configuration.SelectNodes("//group")
$prtgDevices = $configuration.SelectNodes("//device")
$prtgSensors = $configuration.SelectNodes("//sensor")
#endregion

#region function
<# Function Section
#################################
All functions of the script are defined here. 
############################### #>

<# Function Name: This-GetXMLValue
#################################
Used For: Retrieving XML values. Returns inherited if the trim fails (i.e. if there's nothing to trim
#################################
Parameters: 
# [xml]    object - the object that should have it's node extracted
# [string] node   - the node you want retrieved
################################# #>
function This-GetXMLValue($object,[string]$node){

    try   { $value = $object.data.$node.trim(); }
    catch { $value = "Inherited" }

    return $value;

}
#endregion

$MaintenanceList = @(); 

foreach($prtgGroup in $prtgGroups){

    if((($prtgGroup.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtggroup.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtggroup.data.maintend)
        $maintenanceEnabled = "Yes"

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
    
    $Group = [pscustomobject]@{
            ID   = $prtgGroup.ID
            Name = $prtgGroup.data.name.Trim()
            Type = "Group"
            "Maintenance Start" = $maintenanceStart
            "Maintenance End"   = $maintenanceEnd
            Duration            = $duration
           
           }
     $MaintenanceList += $Group 
    }
}

foreach($prtgDevice in $prtgDevices){

    if((($prtgDevice.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtgDevice.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtgDevice.data.maintend)
      

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
    
        $Device = [pscustomobject]@{
                ID   = $prtgDevice.ID
                Name = $prtgDevice.data.name.Trim()
                Type = "Device"
            
                "Maintenance Start" = $maintenanceStart
                "Maintenance End"   = $maintenanceEnd
                Duration            = $duration
           
        }
        $MaintenanceList += $Device;
    }
}

foreach($prtgSensor in $prtgSensors){

    if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
        $maintenanceStart = $start.AddDays($prtgSensor.data.maintstart)
        $maintenanceEnd   = $Start.AddDays($prtgSensor.data.maintend)
        $maintenanceEnabled = "Yes"

        $Days = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Days
        $Hour = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Hours
        $Min  = (New-TimeSpan -Start $maintenanceStart -End $maintenanceEnd).Minutes

        $duration = [string]::Format("{0} Days, {1} Hours, {2} Minutes", $Days, $Hour, $Min)
   
        $Sensor = [pscustomobject]@{
                ID   = $prtgSensor.ID
                Name = $prtgSensor.data.name.Trim()
                Type = "Sensor"
                "Has Maintenance Configured" = $maintenanceEnabled
                "Maintenance Start" = $maintenanceStart
                "Maintenance End"   = $maintenanceEnd
                 Duration            = $duration
               }
         $MaintenanceList += $Sensor; 
        }
}

$MaintenanceList | Out-GridView -Title "Maintenance List"

Created on Apr 21, 2017 7:27:37 AM by  Stephan Linke [Paessler Support]

Last change on Mar 13, 2018 11:30:02 AM by  Torsten Lindner [Paessler Support]



Votes:

0

Regarding my post of April 20th: Now I run this script (it throws some errors, but it still gives me the list; I'll have to find time to get rid of the errors) and it displays the list of future and past One Time Maintenance windows.

Together with the solution of https://kb.paessler.com/en/topic/75783-cancel-one-time-maintenance-windows I am now able to remove the One Time Maintenance for the sensors if needed.

Created on Oct 12, 2017 2:14:38 PM



Votes:

0

Thanks for your feedback, Corné. Glad it's saving you some time :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Oct 13, 2017 7:38:49 AM by  Stephan Linke [Paessler Support]



Votes:

0

I get the following errors when running this as an administrator on main Probe Server.

You cannot call a method on a null-valued expression.
At D:\Utilities\Maintenance-list.ps1:96 char:8
+     if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At D:\Utilities\Maintenance-list.ps1:96 char:8
+     if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At D:\Utilities\Maintenance-list.ps1:96 char:8
+     if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At D:\Utilities\Maintenance-list.ps1:96 char:8
+     if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
You cannot call a method on a null-valued expression.
At D:\Utilities\Maintenance-list.ps1:96 char:8
+     if((($prtgSensor.data.maintenable).ToString().Trim() -eq 1)){
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Created on Mar 10, 2018 4:18:58 PM

Last change on Mar 13, 2018 6:24:13 AM by  Luciano Lingnau [Paessler]



Votes:

0

Shock, did you run the script on the actual host machine of the PRTG core server? Or on your client work station?

Created on Mar 13, 2018 11:30:44 AM by  Torsten Lindner [Paessler Support]



Votes:

0

I have the same error that Shock has listed above. I am running the script on our PRTG core server.

Created on Apr 26, 2019 7:32:53 PM



Votes:

0

Also, the times reported are incorrect in the maintenance list. I have a window set to begin at 2019-04-26 19:00 but the script is reporting that it begins 4/27/19 17:00

Created on Apr 26, 2019 7:52:09 PM



Votes:

0

It's working perfectly fine for, still. Does the Windows Server have a different timezone than your PRTG? Could you provide some screenshots of the defined maintenance window and the output of the script?


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Apr 29, 2019 10:11:18 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hello,

I've noticed on "Probe Health" sensor (in "Probe Device" device), the "maintenable" object does not exist, generating an error at line number 94 in the script.

Even if this point is not script blocking, if you want, you can just add a conditional test for the block 94-116 :

if($prtgSensor.data.maintenable){ ... }

Created on Oct 7, 2021 8:27:34 AM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.