< Back
Copy-Object
Post
NAME Copy-Object
SYNOPSIS
Clones a sensor, device, group or notification trigger within PRTG.
SYNTAX
Copy-Object [-DestinationId] <int> [[-Name] <string>] -Sensor <Sensor> [-Resolve <SwitchParameter>] [-Resume
<SwitchParameter>] [<CommonParameters>]
Copy-Object [-DestinationId] <int> [[-Name] <string>] [[-Host] <string>] -Device <Device> [-Resolve
<SwitchParameter>] [-Resume <SwitchParameter>] [<CommonParameters>]
Copy-Object [-DestinationId] <int> [[-Name] <string>] -Group <Group> [-Resolve <SwitchParameter>] [-Resume
<SwitchParameter>] [<CommonParameters>]
Copy-Object [-DestinationId] <int> -Trigger <NotificationTrigger> [-Resolve <SwitchParameter>] [<CommonParameters>]
Copy-Object [[-Name] <string>] -SourceId <int> [-DestinationId <int>] [-Resolve <SwitchParameter>] [-Resume
<SwitchParameter>] [<CommonParameters>]
Copy-Object -Destination <DeviceOrGroupOrProbe> -SourceId <int> [-Resolve <SwitchParameter>] [-Resume
<SwitchParameter>] [-SkipParent <SwitchParameter>] [<CommonParameters>]
DESCRIPTION
The Clone-Object cmdlet duplicates a PRTG Sensor, Device, Group or Notification Trigger, including all objects
defined under it (such as all sensors of a device, or all devices and sensors of a group).
Clone-Object can operate in two modes: Clone From and Clone To. In Clone From mode (the default) objects you wish
to clone are piped into Clone-Object, requiring you to specify the Object ID of the parent the cloned object will
sit under. In Clone To mode, objects you wish to clone a single object to are piped to Clone-Object, requiring you
to specify the ID of the object you wish to clone.
Sensors can only be cloned to Device objects, whereas devices and groups can both cloned to other groups or
directly under a probe.
When cloning sensors, devices and groups objects (in Clone From mode), a name can optionally be specified. When
cloning sensors and groups, if a name is not specified the name of the original sensor or group will be used. When
cloning devices, if a name is not specified PrtgAPI will automatically name the device as "Clone of <device>,
where <device> is the name of the original device. When cloning devices, a Hostname/IP Address can optionally be
specified. If a Hostname/IP Address is ommitted, PrtgAPI will use the name of the device as the hostname. Cloning
a notification trigger with Clone-Object is equivalent to passing a trigger to the New-TriggerParameters cmdlet,
followed by Add-NotificationTrigger.
To clone a single child object to multiple destination objects, the -SourceId parameter can be specified. When
operating in Clone To mode, Clone-Object will automatically assign the newly created object the same name as the
source object. When Clone-Object executes, it will automatically attempt to resolve the target object specified by
the -SourceId parameter. If -SourceId cannot be resolved to a valid sensor, device or group, Clone-Object will
throw an exception specifying that the specified object ID is not valid. If the list of objects piped to
Clone-Object includes the parent of the object specified to -SourceId, you can skip this parent by specifying
-SkipParent.
When an object has been cloned, by default Clone-Object will attempt to automatically resolve the object into its
resultant Sensor, Device, Group or NotificationTrigger object. Based on the speed of your PRTG Server, this can
sometimes result in a delay of 5-10 seconds due to the delay with which PRTG clones the object. If Clone-Object
cannot resolve the resultant object on the first attempt, PrtgAPI will make a further 4 retries, pausing for a
successively greater duration between each try. After each failed attempt a warning will be displayed indicating
the number of attempts remaining. Object resolution can be aborted at any time by pressing an escape sequence such
as Ctrl-C.
If you do not wish to resolve the resultant object, you can specify -Resolve:$false, which will cause Clone-Object
to output a clone summary, including the object ID, name and hostname (for devices) of the new object. When
cloning triggers, is -Resolve:$false is specified, no summary will be returned (as PRTG does not automatically
return any information regarding cloned triggers).
As PRTG pauses all cloned sensors, devices and groups by default, it is generally recommended to resolve the new
object so that you may unpause the object with Resume-Object. Objects can alternatively be resumed as Clone-Object
progresses by specifying the -Resume parameter, however note that this will cause an additional resume API request
to be executed for every cloned object, as opposed to Resume-Object which will simply resume all of the cloned
objects in one go once all of the objects have been created.
Object types that are not conventionally supported by the Clone-Object cmdlet can still be cloned by specifying
both a -SourceId and -DestinationId. When cloning objects that fall outside the conventional object tree (such as
Maps and Notification Actions) the -DestinationId will always be ignored in favour of the appropriate System
object for that object type (such as the Notifications (ID: -3) object for Notification Actions). If a
-DestinationId is not specified alongside a -SourceId, the source ID's parent will automatically be used.
PARAMETERS
-DestinationId <int>
The ID of the device (for sensors), group or probe (for groups and devices) that will hold the cloned object.
Required? true
Position? 0
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-Name <string>
The name to rename the cloned object to.
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Host <string>
The hostname or IP Address to set on the cloned device.
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Sensor <Sensor>
The sensor to clone.
Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Device <Device>
The device to clone.
Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Group <Group>
The group to clone.
Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Trigger <NotificationTrigger>
The notification trigger to clone.
Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-SourceId <int>
The ID of the object to clone.
Required? true
Position? named
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-Id <int>
The ID of the object to clone.
This is an alias of the SourceId parameter.
Required? true
Position? named
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-SkipParent <SwitchParameter>
Indicates that the -Destination specified for -SourceId should be skipped if it is the -SourceId's parent.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Destination <DeviceOrGroupOrProbe>
The object to clone the object specified by the SourceId to.
Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Resume <SwitchParameter>
Resume the object immediately after cloning it.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Resolve <SwitchParameter>
Indicates whether or not the new object should be resolved to a PrtgObject. By default this value is Present.
Required? false
Position? named
Default value True
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
PrtgAPI.Sensor
The sensor to clone.
PrtgAPI.Device
The device to clone.
PrtgAPI.Group
The group to clone.
PrtgAPI.NotificationTrigger
The notification trigger to clone.
PrtgAPI.DeviceOrGroupOrProbe
The object to clone the object specified by the SourceId to.
OUTPUTS
---------- EXAMPLE 1 ----------
C:\\> Get-Sensor -Id 1234 | Clone-Object -DestinationId 5678
Clone the sensor with ID 1234 to the device with ID 5678
---------- EXAMPLE 2 ----------
C:\\> Get-Sensor -Id 1234 | Clone-Object -DestinationId 5678 MyNewSensor
Clone the sensor with ID 1234 to the device with ID 5678 renamed as "MyNewSensor"
---------- EXAMPLE 3 ----------
C:\\> Get-Device *exch* | Clone-Object -SourceId 2002
Clone the object with ID 2002 to all devices whose name contains "exch"
---------- EXAMPLE 4 ----------
C:\\> Get-Sensor -Id 1234 | Clone-Object -DestinationId 5678 -Resolve:$false
Clone the sensor with ID 1234 into the device with ID 5678 without resolving the resultant PrtgObject
---------- EXAMPLE 5 ----------
C:\\> Get-Device -Id 1234 | Clone-Object -DestinationId 5678 MyNewDevice 192.168.1.1
Clone the device with ID 1234 into the group or probe with ID 5678 renamed as "MyNewDevice" with IP Address
192.168.1.1
---------- EXAMPLE 6 ----------
C:\\> Get-Probe -Id 1234 | Get-Trigger | Clone-Object -DestinationId 5678
Clone all notification triggers (both inherited and explicitly defined) on the probe with ID 1234 to the object
with ID 5678
---------- EXAMPLE 7 ----------
C:\\> Clone-Object -Id 1001 -DestinationId 2002
Clone the object with ID 1001 to under the object with ID 2002.
---------- EXAMPLE 8 ----------
C:\\> Get-Device *exch* | Clone-Object -SourceId 2002 | Resume-Object
Clone the object with ID 2002 to all devices whose name contains "exch" and resume all the created objects once
they have been created.
---------- EXAMPLE 9 ----------
C:\\> Get-Device *exch* | Clone-Object -SourceId 2002 -Resume
Clone the object with ID 2002 to all devices whose name contains "exch", resuming each object as it is created.
---------- EXAMPLE 10 ----------
C:\\> Clone-Object -Id 300 "New Notification Trigger"
Clone the Notification Trigger with ID 300, automatically placing the trigger under the "Notifications" system
object.
RELATED LINKS
Online version: https://github.com/lordmilko/PrtgAPI/wi ... #cloning-1
Get-Sensor
Get-Device
Get-Group
Get-Trigger
Get-NotificationTriggerParameters
Add-NotificationTrigger
Resume-Object
SYNOPSIS
Clones a sensor, device, group or notification trigger within PRTG.
SYNTAX
Copy-Object [-DestinationId] <int> [[-Name] <string>] -Sensor <Sensor> [-Resolve <SwitchParameter>] [-Resume
<SwitchParameter>] [<CommonParameters>]
Copy-Object [-DestinationId] <int> [[-Name] <string>] [[-Host] <string>] -Device <Device> [-Resolve
<SwitchParameter>] [-Resume <SwitchParameter>] [<CommonParameters>]
Copy-Object [-DestinationId] <int> [[-Name] <string>] -Group <Group> [-Resolve <SwitchParameter>] [-Resume
<SwitchParameter>] [<CommonParameters>]
Copy-Object [-DestinationId] <int> -Trigger <NotificationTrigger> [-Resolve <SwitchParameter>] [<CommonParameters>]
Copy-Object [[-Name] <string>] -SourceId <int> [-DestinationId <int>] [-Resolve <SwitchParameter>] [-Resume
<SwitchParameter>] [<CommonParameters>]
Copy-Object -Destination <DeviceOrGroupOrProbe> -SourceId <int> [-Resolve <SwitchParameter>] [-Resume
<SwitchParameter>] [-SkipParent <SwitchParameter>] [<CommonParameters>]
DESCRIPTION
The Clone-Object cmdlet duplicates a PRTG Sensor, Device, Group or Notification Trigger, including all objects
defined under it (such as all sensors of a device, or all devices and sensors of a group).
Clone-Object can operate in two modes: Clone From and Clone To. In Clone From mode (the default) objects you wish
to clone are piped into Clone-Object, requiring you to specify the Object ID of the parent the cloned object will
sit under. In Clone To mode, objects you wish to clone a single object to are piped to Clone-Object, requiring you
to specify the ID of the object you wish to clone.
Sensors can only be cloned to Device objects, whereas devices and groups can both cloned to other groups or
directly under a probe.
When cloning sensors, devices and groups objects (in Clone From mode), a name can optionally be specified. When
cloning sensors and groups, if a name is not specified the name of the original sensor or group will be used. When
cloning devices, if a name is not specified PrtgAPI will automatically name the device as "Clone of <device>,
where <device> is the name of the original device. When cloning devices, a Hostname/IP Address can optionally be
specified. If a Hostname/IP Address is ommitted, PrtgAPI will use the name of the device as the hostname. Cloning
a notification trigger with Clone-Object is equivalent to passing a trigger to the New-TriggerParameters cmdlet,
followed by Add-NotificationTrigger.
To clone a single child object to multiple destination objects, the -SourceId parameter can be specified. When
operating in Clone To mode, Clone-Object will automatically assign the newly created object the same name as the
source object. When Clone-Object executes, it will automatically attempt to resolve the target object specified by
the -SourceId parameter. If -SourceId cannot be resolved to a valid sensor, device or group, Clone-Object will
throw an exception specifying that the specified object ID is not valid. If the list of objects piped to
Clone-Object includes the parent of the object specified to -SourceId, you can skip this parent by specifying
-SkipParent.
When an object has been cloned, by default Clone-Object will attempt to automatically resolve the object into its
resultant Sensor, Device, Group or NotificationTrigger object. Based on the speed of your PRTG Server, this can
sometimes result in a delay of 5-10 seconds due to the delay with which PRTG clones the object. If Clone-Object
cannot resolve the resultant object on the first attempt, PrtgAPI will make a further 4 retries, pausing for a
successively greater duration between each try. After each failed attempt a warning will be displayed indicating
the number of attempts remaining. Object resolution can be aborted at any time by pressing an escape sequence such
as Ctrl-C.
If you do not wish to resolve the resultant object, you can specify -Resolve:$false, which will cause Clone-Object
to output a clone summary, including the object ID, name and hostname (for devices) of the new object. When
cloning triggers, is -Resolve:$false is specified, no summary will be returned (as PRTG does not automatically
return any information regarding cloned triggers).
As PRTG pauses all cloned sensors, devices and groups by default, it is generally recommended to resolve the new
object so that you may unpause the object with Resume-Object. Objects can alternatively be resumed as Clone-Object
progresses by specifying the -Resume parameter, however note that this will cause an additional resume API request
to be executed for every cloned object, as opposed to Resume-Object which will simply resume all of the cloned
objects in one go once all of the objects have been created.
Object types that are not conventionally supported by the Clone-Object cmdlet can still be cloned by specifying
both a -SourceId and -DestinationId. When cloning objects that fall outside the conventional object tree (such as
Maps and Notification Actions) the -DestinationId will always be ignored in favour of the appropriate System
object for that object type (such as the Notifications (ID: -3) object for Notification Actions). If a
-DestinationId is not specified alongside a -SourceId, the source ID's parent will automatically be used.
PARAMETERS
-DestinationId <int>
The ID of the device (for sensors), group or probe (for groups and devices) that will hold the cloned object.
Required? true
Position? 0
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-Name <string>
The name to rename the cloned object to.
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Host <string>
The hostname or IP Address to set on the cloned device.
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Sensor <Sensor>
The sensor to clone.
Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Device <Device>
The device to clone.
Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Group <Group>
The group to clone.
Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Trigger <NotificationTrigger>
The notification trigger to clone.
Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-SourceId <int>
The ID of the object to clone.
Required? true
Position? named
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-Id <int>
The ID of the object to clone.
This is an alias of the SourceId parameter.
Required? true
Position? named
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-SkipParent <SwitchParameter>
Indicates that the -Destination specified for -SourceId should be skipped if it is the -SourceId's parent.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Destination <DeviceOrGroupOrProbe>
The object to clone the object specified by the SourceId to.
Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Resume <SwitchParameter>
Resume the object immediately after cloning it.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-Resolve <SwitchParameter>
Indicates whether or not the new object should be resolved to a PrtgObject. By default this value is Present.
Required? false
Position? named
Default value True
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
PrtgAPI.Sensor
The sensor to clone.
PrtgAPI.Device
The device to clone.
PrtgAPI.Group
The group to clone.
PrtgAPI.NotificationTrigger
The notification trigger to clone.
PrtgAPI.DeviceOrGroupOrProbe
The object to clone the object specified by the SourceId to.
OUTPUTS
---------- EXAMPLE 1 ----------
C:\\> Get-Sensor -Id 1234 | Clone-Object -DestinationId 5678
Clone the sensor with ID 1234 to the device with ID 5678
---------- EXAMPLE 2 ----------
C:\\> Get-Sensor -Id 1234 | Clone-Object -DestinationId 5678 MyNewSensor
Clone the sensor with ID 1234 to the device with ID 5678 renamed as "MyNewSensor"
---------- EXAMPLE 3 ----------
C:\\> Get-Device *exch* | Clone-Object -SourceId 2002
Clone the object with ID 2002 to all devices whose name contains "exch"
---------- EXAMPLE 4 ----------
C:\\> Get-Sensor -Id 1234 | Clone-Object -DestinationId 5678 -Resolve:$false
Clone the sensor with ID 1234 into the device with ID 5678 without resolving the resultant PrtgObject
---------- EXAMPLE 5 ----------
C:\\> Get-Device -Id 1234 | Clone-Object -DestinationId 5678 MyNewDevice 192.168.1.1
Clone the device with ID 1234 into the group or probe with ID 5678 renamed as "MyNewDevice" with IP Address
192.168.1.1
---------- EXAMPLE 6 ----------
C:\\> Get-Probe -Id 1234 | Get-Trigger | Clone-Object -DestinationId 5678
Clone all notification triggers (both inherited and explicitly defined) on the probe with ID 1234 to the object
with ID 5678
---------- EXAMPLE 7 ----------
C:\\> Clone-Object -Id 1001 -DestinationId 2002
Clone the object with ID 1001 to under the object with ID 2002.
---------- EXAMPLE 8 ----------
C:\\> Get-Device *exch* | Clone-Object -SourceId 2002 | Resume-Object
Clone the object with ID 2002 to all devices whose name contains "exch" and resume all the created objects once
they have been created.
---------- EXAMPLE 9 ----------
C:\\> Get-Device *exch* | Clone-Object -SourceId 2002 -Resume
Clone the object with ID 2002 to all devices whose name contains "exch", resuming each object as it is created.
---------- EXAMPLE 10 ----------
C:\\> Clone-Object -Id 300 "New Notification Trigger"
Clone the Notification Trigger with ID 300, automatically placing the trigger under the "Notifications" system
object.
RELATED LINKS
Online version: https://github.com/lordmilko/PrtgAPI/wi ... #cloning-1
Get-Sensor
Get-Device
Get-Group
Get-Trigger
Get-NotificationTriggerParameters
Add-NotificationTrigger
Resume-Object