< Back

New-Sensor

Sun Jan 19, 2020 5:43 pm

NAME New-Sensor



SYNOPSIS

Adds a new sensor to a PRTG Device.





SYNTAX

New-Sensor [-ExeXml] <SwitchParameter> [-Name] <string> [-ExeFile] <ExeFileTarget> -Device <Device> [-DebugMode

{Discard | WriteToDisk | WriteToDiskWhenError}] [-ExeParameters <string>] [-InheritInterval <Nullable`1>]

[-InheritTriggers <Nullable`1>] [-Interval <ScanningInterval>] [-IntervalErrorMode <Nullable`1>] [-Mutex <string>]

[-Priority <Nullable`1>] [-Resolve <SwitchParameter>] [-SetExeEnvironmentVariables <bool>] [-Tags <string[]>]

[-Timeout <int>] [-UseWindowsAuthentication <bool>] [<CommonParameters>]



New-Sensor [-Http] <SwitchParameter> [[-Name] <string>] [[-Url] <string>] -Device <Device> [-HttpRequestMethod

{GET | POST | HEAD}] [-InheritInterval <Nullable`1>] [-InheritTriggers <Nullable`1>] [-Interval

<ScanningInterval>] [-IntervalErrorMode <Nullable`1>] [-PostContentType <string>] [-PostData <string>] [-Priority

<Nullable`1>] [-Resolve <SwitchParameter>] [-Tags <string[]>] [-Timeout <int>] [-UseCustomPostContent <bool>]

[-UseSNIFromUrl <bool>] [<CommonParameters>]



New-Sensor [-WmiService] <SwitchParameter> [-Service] <WmiServiceTarget[]> -Device <Device> [-InheritInterval

<Nullable`1>] [-InheritTriggers <Nullable`1>] [-Interval <ScanningInterval>] [-IntervalErrorMode <Nullable`1>]

[-MonitorPerformance <bool>] [-Name <string>] [-NotifyChanged <bool>] [-Priority <Nullable`1>] [-Resolve

<SwitchParameter>] [-StartStopped <bool>] [-Tags <string[]>] [<CommonParameters>]



New-Sensor [-WmiService] <SwitchParameter> [-ServiceName] <string[]> -Device <Device> [-InheritInterval

<Nullable`1>] [-InheritTriggers <Nullable`1>] [-Interval <ScanningInterval>] [-IntervalErrorMode <Nullable`1>]

[-MonitorPerformance <bool>] [-Name <string>] [-NotifyChanged <bool>] [-Priority <Nullable`1>] [-Resolve

<SwitchParameter>] [-StartStopped <bool>] [-Tags <string[]>] [<CommonParameters>]



New-Sensor [-Factory] <SwitchParameter> [-Name] <string> [-ChannelName] <NameOrScriptBlock> [[-ChannelId] <int>]

-DestinationId <int> -Sensor <Sensor> [-Expression <ScriptBlock>] [-FactoryErrorFormula <string>]

[-FactoryErrorMode {ErrorOnError | WarnOnError | CustomFormula}] [-FactoryMissingDataMode {DontCalculate |

CalculateWithZero}] [-InheritInterval <Nullable`1>] [-InheritTriggers <Nullable`1>] [-Interval <ScanningInterval>]

[-IntervalErrorMode <Nullable`1>] [-Priority <Nullable`1>] [-Resolve <SwitchParameter>] [-StartId <int>] [-Tags

<string[]>] [<CommonParameters>]



New-Sensor [-Factory] <SwitchParameter> [-Name] <string> [-ChannelName] <NameOrScriptBlock> [[-ChannelId] <int>]

-Aggregator <EnumOrScriptBlock`1> -DestinationId <int> -Sensor <Sensor> [-Expression <ScriptBlock>]

[-FactoryErrorFormula <string>] [-FactoryErrorMode {ErrorOnError | WarnOnError | CustomFormula}]

[-FactoryMissingDataMode {DontCalculate | CalculateWithZero}] [-Finalizer <ScriptBlock>] [-InheritInterval

<Nullable`1>] [-InheritTriggers <Nullable`1>] [-Interval <ScanningInterval>] [-IntervalErrorMode <Nullable`1>]

[-Priority <Nullable`1>] [-Resolve <SwitchParameter>] [-StartId <int>] [-Tags <string[]>] [<CommonParameters>]



New-Sensor [-Factory] <SwitchParameter> [-Name] <string> [-ChannelName] <NameOrScriptBlock> [[-ChannelId] <int>]

-DestinationId <int> -Sensor <Sensor> -SummaryExpression <EnumOrScriptBlock`1> -SummaryName <string> [-Expression

<ScriptBlock>] [-FactoryErrorFormula <string>] [-FactoryErrorMode {ErrorOnError | WarnOnError | CustomFormula}]

[-FactoryMissingDataMode {DontCalculate | CalculateWithZero}] [-InheritInterval <Nullable`1>] [-InheritTriggers

<Nullable`1>] [-Interval <ScanningInterval>] [-IntervalErrorMode <Nullable`1>] [-Priority <Nullable`1>] [-Resolve

<SwitchParameter>] [-StartId <int>] [-SummaryFinalizer <ScriptBlock>] [-Tags <string[]>] [<CommonParameters>]



New-Sensor [-Factory] <SwitchParameter> [-Name] <string> [-ChannelName] <NameOrScriptBlock> -DestinationId <int>

-Value <string> [-FactoryErrorFormula <string>] [-FactoryErrorMode {ErrorOnError | WarnOnError | CustomFormula}]

[-FactoryMissingDataMode {DontCalculate | CalculateWithZero}] [-InheritInterval <Nullable`1>] [-InheritTriggers

<Nullable`1>] [-Interval <ScanningInterval>] [-IntervalErrorMode <Nullable`1>] [-Priority <Nullable`1>] [-Resolve

<SwitchParameter>] [-StartId <int>] [-Tags <string[]>] [<CommonParameters>]



New-Sensor [-Factory] <SwitchParameter> [-Name] <string> -ChannelDefinition <string[]> -DestinationId <int>

[-FactoryErrorFormula <string>] [-FactoryErrorMode {ErrorOnError | WarnOnError | CustomFormula}]

[-FactoryMissingDataMode {DontCalculate | CalculateWithZero}] [-InheritInterval <Nullable`1>] [-InheritTriggers

<Nullable`1>] [-Interval <ScanningInterval>] [-IntervalErrorMode <Nullable`1>] [-Priority <Nullable`1>] [-Resolve

<SwitchParameter>] [-Tags <string[]>] [<CommonParameters>]





DESCRIPTION

The New-Sensor cmdlet adds a new sensor to a PRTG Device. Unlike the similar Add-Sensor cmdlet, New-Sensor

provides the ability to specify the properties of each sensor type as dynamic parameters directly to the cmdlet.

As such, New-Sensor can only be used for creating sensor types that are properly supported by PrtgAPI.



All parameter sets found on New-Sensor adhere to the following basic rules: 1. The first parameter is always a

SwitchParameter specifying the sensor type. 2. The second parameter is always the Name (if applicable). 3. The

-Device parameter specifies where the sensor will be created (unless otherwise specified). 4. Required values are

positional parameters, unless they would conflict with another parameter set. 5. Unless otherwise specified, all

other parameters are named parameters.



Sensor types that require the use of complex sensor targets can either specify the target objects directly or

specify one or more wildcard expressions, which New-Sensor will use to lookup these targets for you. Note that if

you specify a wildcard expression when trying to create sensors on multiple objects, New-Sensor will resolve these

targets on each individual target, which could be time consuming.



When creating sensor factory objects, New-Sensor incorporates the functionality of the New-SensorFactoryDefinition

cmdlet, allowing you to generate a complex sensor factory definition from several specified sensors. Unlike other

sensor types, the device the sensor factory should be created on is specified via the -DestinationId parameter,

allowing the sensors to use for the factory to be piped into the cmdlet.



To view the parameters of your sensor without creating it, you can specify the -WhatIf parameter. This can be

especially useful when creating sensor factories to confirm the channel definition was correctly generated as

expected.





PARAMETERS

-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



-ExeFile <ExeFileTarget>



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ExeParameters <string>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SetExeEnvironmentVariables <bool>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-UseWindowsAuthentication <bool>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Mutex <string>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Timeout <int>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-DebugMode <DebugMode>

Possible values: Discard, WriteToDisk, WriteToDiskWhenError



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Priority <Nullable`1>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-InheritTriggers <Nullable`1>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-InheritInterval <Nullable`1>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Interval <ScanningInterval>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-IntervalErrorMode <Nullable`1>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Name <string>



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Tags <string[]>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ExeXml <SwitchParameter>



Required? true

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Device <Device>



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Service <WmiServiceTarget[]>



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ServiceName <string[]>



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-StartStopped <bool>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-NotifyChanged <bool>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-MonitorPerformance <bool>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-WmiService <SwitchParameter>



Required? true

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Url <string>



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-HttpRequestMethod <HttpRequestMethod>

Possible values: GET, POST, HEAD



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-PostData <string>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-UseCustomPostContent <bool>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-PostContentType <string>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-UseSNIFromUrl <bool>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Http <SwitchParameter>



Required? true

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ChannelDefinition <string[]>



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-FactoryErrorMode <FactoryErrorMode>

Possible values: ErrorOnError, WarnOnError, CustomFormula



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-FactoryErrorFormula <string>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-FactoryMissingDataMode <FactoryMissingDataMode>

Possible values: DontCalculate, CalculateWithZero



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Sensor <Sensor>



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-ChannelName <NameOrScriptBlock>



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ChannelId <int>



Required? false

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Expression <ScriptBlock>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-StartId <int>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Aggregator <EnumOrScriptBlock`1>



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Finalizer <ScriptBlock>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Value <string>



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SummaryName <string>



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-sn <string>

This is an alias of the SummaryName parameter.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SummaryExpression <EnumOrScriptBlock`1>



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-se <EnumOrScriptBlock`1>

This is an alias of the SummaryExpression parameter.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-sa <EnumOrScriptBlock`1>

This is an alias of the SummaryExpression parameter.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SummaryAggregator <EnumOrScriptBlock`1>

This is an alias of the SummaryExpression parameter.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SummaryFinalizer <ScriptBlock>



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-sf <ScriptBlock>

This is an alias of the SummaryFinalizer parameter.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Factory <SwitchParameter>



Required? true

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-DestinationId <int>



Required? true

Position? named

Default value

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



PrtgAPI.Sensor





OUTPUTS



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



C:\\> Get-Device -Id 1001 | New-Sensor -ExeXml test test.ps1 -Mutex mutex1



Create a new EXE/Script Advanced sensor named "test" that executes the script "test.ps1" with property "Mutex" set

to "mutex1" on the device with ID 1001.



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



C:\\> Get-Device -Id 1001 | New-Sensor -Http



Create a new HTTP sensor on the device with ID 1001. The Name and Url of the sensor will use their default values

("HTTP" and "https://" respectively).



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



C:\\> Get-Device exch-1 | New-Sensor -WmiService *exchange*



Create WMI Service sensors for all Exchange services on the device named exch-1.



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



C:\\> $targets = Get-Device exch-1 | Get-SensorTarget WmiService *exchange*

C:\\> Get-Device *exch* | New-Sensor -WmiService $targets



Create the same WMI Service sensors for all Exchange servers.



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



C:\\> Get-Sensor -Tags wmicpu* | New-Sensor -Factory "CPU Overview" { $_.Device } -sn "Average CPU Usage" -se

Average -DestinationId 1001



Create a sensor factory for showing the CPU Usage of all sensors on the device with ID 1001, including a summary

channel showing the average CPU Usage of all devices.



RELATED LINKS

Online version: https://github.com/lordmilko/PrtgAPI/wi ... ion#simple

Get-Device

Get-Sensor

Add-Sensor

New-SensorParameters

Get-SensorTarget

New-SensorFactoryDefinition