Public/Set-DeviceRequiredAvailability.ps1
# Code generated from specification version 1.0.0: DO NOT EDIT Function Set-DeviceRequiredAvailability { <# .SYNOPSIS Set the required availability of a device .DESCRIPTION Devices that have not sent any message in the response interval are considered unavailable. Response interval can have value between -32768 and 32767 and any values out of range will be shrink to range borders. Such devices are marked as unavailable (see below) and an unavailability alarm is raised. Devices with a response interval of zero minutes are considered to be under maintenance. No alarm is raised while a device is under maintenance. Devices that do not contain 'c8y_RequiredAvailability' are not monitored. .EXAMPLE PS> Set-DeviceRequiredAvailability -Device $device.id -Interval 10 Set the required availability of a device by name to 10 minutes .EXAMPLE PS> Get-ManagedObject -Id $device.id | PSc8y\Set-DeviceRequiredAvailability -Interval 10 Set the required availability of a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Interval in minutes (required) [Parameter(Mandatory = $true)] [long] $Interval, # Include raw response including pagination information [Parameter()] [switch] $Raw, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Interval")) { $Parameters["interval"] = $Interval } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { foreach ($item in (PSc8y\Expand-Device $Device)) { if ($item) { $Parameters["device"] = if ($item.id) { $item.id } else { $item } } if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-Command ` -Noun "devices" ` -Verb "setRequiredAvailability" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.inventory+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } } End {} } |