-
-
Notifications
You must be signed in to change notification settings - Fork 38
Object Organization
Sensors, Devices, Groups and Probes can be renamed with the RenameObject
method.
//Rename the object with ID 1001 to "New Device"
client.RenameObject(1001, "New Device");
Sensors, Devices and Groups and Probes can be removed from PRTG using the RemoveObject
method.
//Permanently remove the object with ID 1001
client.RemoveObject(1001);
Once an object has been deleted, this cannot be undone. As such, you should be sure you want to delete the specified object before executing this method.
Certain objects cannot be deleted from PRTG, including the Root group (ID: 0) and the Probe Device object under each probe. Attempting to delete an undeletable object will result in a PrtgRequestException
Objects can be individually reordered under their parent object using the SetPosition
method.
//Move the object with ID 1001 up one position under its parent.
client.SetPosition(2001, Position.Up);
Objects can be moved Up
, Down
, to the Top
or Bottom
of all objects under their parent. If you wish to immediately set an object to a specific position, you can also specify a numeric value.
//Move the object with ID 3042 to be second under its parent
client.SetPosition(3042, 2);
If a position goes beyond the bounds of valid positions (e.g. setting a sensor to position 1000 when there are only 100 sensors under the device) PRTG will automatically move the object to the closest valid position (such as last in the list).
If you simply wish to sort all children of an object alphabetically, you can use the SortAlphabetically
method.
//Sort all probes alphabetically. Object ID 0 corresponds to the Root group.
client.SortAlphabetically(0);
This can be particularly useful when sorting probes, which typically require manual repositioning under PRTG's Mangement tab.
Devices and Groups can be moved to other Probes or Groups using the MoveObject
method.
//Move the object with ID 1001 to under the object with ID 2001
client.MoveObject(1001, 2001);
Certain objects such as the Probe Device device and the Root group cannot be moved.
All Object Organization cmdlets are capable of operating in PassThru Mode. For more information on PassThru Mode, see PassThru Requests
Sensors, Devices, Groups and Probes can be renamed with the Rename-Object
cmdlet.
# Rename all WMI Memory sensors to "Memory Free"
Get-Device -Tags wmimem* | Rename-Object "Memory Free"
By default, these Rename-Object
operates in batch mode. For information on batch mode, please see Batch Requests.
Sensors, Devices, Groups and Probes can be removed from PRTG using the Remove-Object
cmdlet. When attempting to remove an object, PrtgAPI will prompt you for each individual object you wish to remove to confirm you are sure you want to remove the specified object. Once an object has been deleted, this cannot be undone
# Remove all SSL Security Check sensors
Get-Sensor -Tags sslsensor | Remove-Object
If you are deleting a large number of objects, it can be tedious having to confirm each object to delete individually. As such, the recommended procedure is to first execute the Remove-Object
cmdlet using the -WhatIf
parameter. If the objects listed from -WhatIf
align with the objects you expected, you can then run Remove-Object
using the -Force` parameter
C:\> Get-Sensor -Tags sslsensor | Remove-Object -WhatIf
What if: Performing the operation "Remove-Object" on target "'SSL Security Check' (ID: 2001)".
What if: Performing the operation "Remove-Object" on target "'SSL Security Check' (ID: 2020)".
...
C:\> Get-Sensor -Tags sslsensor | Remove-Object -Force
By default, these Rename-Object
does not in batch mode. However, if not otherwise specified (via -Batch:$false
) for maximum performance batch mode will automatically be enabled when specifying -Force
. For information on batch mode, please see Batch Requests.
Objects can be repositioned under their parent using the Set-ObjectPosition
cmdlet. Objects can either be moved to an absolute position or in a specified direction (Up
, Down
, Top
, Bottom
)
# Move the sensor with ID 1001 to be second in the list of objects under its parent
Get-Sensor -Id 1001 | Set-ObjectPosition 2
# Move the sensor with ID 2002 up a single position
Get-Sensor -Id 2002 | Set-ObjectPosition Up
If a position goes beyond the bounds of valid positions (e.g. setting a sensor to position 1000 when there are only 100 sensors under the device) PRTG will automatically move the object to the closest valid position (such as last in the list).
If you simply wish to sort all children of an object alphabetically you can use the Sort-PrtgObject
cmdlet
# Sort all probes alphabetically. The group with ID 0 corresponds to the Root group.
Get-Group -Id 0 | Sort-PrtgObject
Devices and Groups can be moved to other Probes or Groups using the Move-Object
cmdlet.
# Move the device with ID 1003 to under the "Servers" group
C:\> $group = Get-Group Servers
C:\> Get-Device -Id 1003 | Move-Object $group.Id