< Back

New-DeviceNode

Sun Jan 19, 2020 5:43 pm

NAME New-DeviceNode



SYNOPSIS

Creates a new DeviceNode for modelling a PRTG Tree.





SYNTAX

New-DeviceNode [-Value] <Device> [[-ScriptBlock] <ScriptBlock>] [<CommonParameters>]



New-DeviceNode [-Value] <Device> -Children <PrtgNode[]> [<CommonParameters>]



New-DeviceNode [[-Name] <object[]>] [[-ScriptBlock] <ScriptBlock>] [-Id <int[]>] [<CommonParameters>]



New-DeviceNode [[-Name] <object[]>] -Children <PrtgNode[]> [-Id <int[]>] [<CommonParameters>]





DESCRIPTION

The New-DeviceNode cmdlet creates a new DeviceNode object for modelling a PRTG Tree. Each DeviceNode object

encapsulates a single Device object along with any optional children (such as SensorNode and TriggerNode items).



New-DeviceNode supports many different ways of being invoked, however at its core there are two pieces of

information that can be provided to the cmdlet: information that identifies the Device to encapsulate, and the

nodes that should be used as the children of the node.



If an existing Device object retrieved from the Get-Device cmdlet is not specified or piped to the -Value

parameter, one or more of -Name or -Id must be specified to identify the object to encapsulate. If multiple values

are returned as a result of these parameters, a unique DeviceNode object will be created for each item.



Child nodes to this node can either be specified via the pipeline, or declaratively via a ScriptBlock. When a

ScriptBlock defining children is specified, DeviceNode will incorporate a copy of the children in each DeviceNode

that is produced. While each DeviceNode will end up with a unique copy of all its descendant nodes, the underlying

Value of each nodw will be the same.





PARAMETERS

-Value <Device>

The value to use for the node.



Required? true

Position? 0

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Name <object[]>

The name of the object to retrieve. Can include wildcards.



Required? false

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Id <int[]>

The ID of the object to retrieve.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ObjectId <int[]>

The ID of the object to retrieve.



This is an alias of the Id parameter.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ScriptBlock <ScriptBlock>

A script block that returns the children to use for this node.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Children <PrtgNode[]>

The children to use for the node.



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue)

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.Device

The value to use for the node.



PrtgAPI.Tree.PrtgNode[]

The children to use for the node.





OUTPUTS



---------- EXAMPLE 1 ----------



C:\\> Get-Device -Id 2001 | New-DeviceNode



Create a device node from the device with ID 2001.



---------- EXAMPLE 2 ----------



C:\\> New-DeviceNode -Id 2001



Create a device node from the device with ID 2001.



---------- EXAMPLE 3 ----------



C:\\> New-DeviceNode dc*



Create a device node for each device whose name starts with "dc".



---------- EXAMPLE 4 ----------



C:\\> DeviceNode -Id 2001 {

>> SensorNode -Id 1001 {

>> TriggerNode -ObjectId 1001

>> }

>>

>> SensorNode -Id 1002 {

>> TriggerNode -ObjectId 1002

>> }

>> }



Create a new device node from the object with ID 2001 with child nodes for the sensors with IDs 1001 and 1002,

each of which contains child nodes for each of their descendant notification triggers.



---------- EXAMPLE 5 ----------



New-Sensor -Id 1001,1002 | New-DeviceNode -Id 2001



Create a new device node from the object with ID 2001 with child nodes for the sensors with IDs 1001 and 1002.



RELATED LINKS

Online version: https://github.com/lordmilko/PrtgAPI/wiki/Tree-Creation

Get-Device

New-SensorNode

New-GroupNode

New-ProbeNode

New-TriggerNode

New-PropertyNode