PSc8y.psm1
######################################################################################### # # PSc8y Module # ######################################################################################### #Microsoft.PowerShell.Core\Set-StrictMode -Version Latest #region script variables $script:IsWindows = (-not (Get-Variable -Name IsWindows -ErrorAction Ignore)) -or $IsWindows $script:IsLinux = (Get-Variable -Name IsLinux -ErrorAction Ignore) -and $IsLinux $script:IsMacOS = (Get-Variable -Name IsMacOS -ErrorAction Ignore) -and $IsMacOS $script:IsCoreCLR = $PSVersionTable.ContainsKey('PSEdition') -and $PSVersionTable.PSEdition -eq 'Core' $script:Dependencies = & { Join-Path -Path $PSScriptRoot -ChildPath "Dependencies" } #endregion #region Private Functions Function Format-CommandParameter { [cmdletbinding()] Param( [Parameter( Mandatory = $true, Position = 0 )] [object] $ParameterList ) $Parameters = @{} $ParameterList = (Get-Command -Name $CommandName).Parameters # Grab each parameter value, using Get-Variable foreach ($Name in ($ParameterList.Keys -notmatch "^Raw$")) { $iParam = Get-Variable -Name $Name -ErrorAction SilentlyContinue; if ($iParam.Value -is [Switch]) { if ($iParam.Value.IsPresent -and $iParam) { $Parameters[$Name] = $true } } elseif ($iParam.Value -is [hashtable]) { $Parameters[$Name] = "{0}" -f ((ConvertTo-Json $iParam.Value -Compress) -replace '"', '\"') } elseif ($iParam.Value -is [datetime]) { $Parameters[$Name] = Format-Date $iParam.Value } else { if ("$iParam" -notmatch "^$") { $Parameters[$Name] = $iParam.Value } } } $Parameters } Function Format-ConfirmationMessage { <# .SYNOPSIS Format the confirmation message from a cmdlet name and input object #> [cmdletbinding()] Param( [Parameter( Mandatory = $true, Position = 0)] [string] $Name, [Parameter( Mandatory = $true, Position = 1)] [AllowNull()] [object] $inputObject, [string] $IgnorePrefix = "" ) $parts = New-Object System.Collections.ArrayList; # Remove fully qualified module name $Name = $Name -replace "^\w+\\", "" foreach ($item in ($Name -csplit '(?=[A-Z\-])')) { if ($item -eq "-" -or $item -eq "" -or $item -eq $IgnorePrefix) { continue; } if ($parts.Count -eq 0) { $null = $parts.Add($item); } else { $null = $parts.Add("$item".ToLowerInvariant()); } } if ($inputObject.id -and $inputObject.name) { $null = $parts.Add(("[{1} ({0})]" -f $inputObject.id, $inputObject.name)) } elseif ($inputObject.id) { $null = $parts.Add(("[{0}]" -f $inputObject.id)) } elseif ($inputObject) { $null = $parts.Add("[{0}]" -f $inputObject) } else { # Don't add anything } $parts -join " " } Function Get-NestedProperty { [cmdletbinding()] Param( [Parameter( Mandatory = $true, Position = 0 )] [AllowNull()] [AllowEmptyCollection()] [object[]] $InputObject, [Parameter( Mandatory = $true, Position = 1 )] [AllowNull()] [AllowEmptyString()] [string] $Name ) if (!$Name) { $null return } $Output = $InputObject foreach ($part in ($Name -split "\.")) { if ($null -eq $Output.$part -and $null -eq $Output.$part.Count) { $Output = $null break; } $Output = $Output.$part } $Output } Function Get-SessionHomePath { [cmdletbinding()] Param() $c8yFolderName = ".cumulocity" if ($env:C8Y_SESSION_HOME) { $HomePath = $env:C8Y_SESSION_HOME } elseif ($env:HOME) { $HomePath = Join-Path $env:HOME -ChildPath $c8yFolderName } else { # Check if on windows (PS 5.1) $IsWindowsOS = !($IsMacOS -or $IsLinux) if ($IsWindowsOS -and $env:HOMEDRIVE -and $env:HOMEPATH) { $HomePath = Join-Path -Path "$Env:HOMEDRIVE\$Env:HOMEPATH" -ChildPath $c8yFolderName } else { # default to current directory $HomePath = Join-Path "." -ChildPath $c8yFolderName } } $HomePath } Function Invoke-ClientCommand { <# .SYNOPSIS Run a Cumulocity client command using the c8y binary. Only intended for internal usage only .DESCRIPTION The command is a wrapper around the c8y binary which is used to send the rest request to Cumulocity. The result will also be parsed, and Powershell type information will be added to the result set, so only relevant information is shown. #> [cmdletbinding()] Param( # Name of the command [Parameter( Mandatory = $true )] [string] $Noun, # Command verb, i.e. list, get, delete etc. [Parameter( Mandatory = $true )] [string] $Verb, # Parameters which should be passed to the c8y binary # The full parameter name should be used (i.e. --header, and not -H) [hashtable] $Parameters, [string] $Type = "c8y.item", # Type to be added to the result set. Used to control the view of the # returned data in Powershell [string] $ItemType, # Name of the property to return a portion (fragment) of the data instead of the full # data set. [string] $ResultProperty, # Future Roadmap: Currently not used: Include all result sets [switch] $IncludeAll, # Return the raw response rather than Powershell objects [switch] $Raw, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) $c8yargs = New-Object System.Collections.ArrayList $null = $c8yargs.Add($Noun) $null = $c8yargs.Add($Verb) foreach ($iKey in $Parameters.Keys) { $Value = $Parameters[$iKey] foreach ($iValue in $Value) { if ("$Value" -notmatch "^$") { $key = $iKey[0].ToString().ToLowerInvariant() + $iKey.SubString(1) if ($Value -is [bool] -and $Value) { $null = $c8yargs.AddRange(@("--${key}")) } else { if ($key -eq "data") { # due to cli parsing, data needs to be sent using "=" $null = $c8yargs.AddRange(@("--${key}", $Value)) } else { if ($Value -match " ") { # $null = $c8yargs.AddRange(@("--${key}", "$Value")) $null = $c8yargs.Add("--${key}=`"$Value`"") } else { $null = $c8yargs.Add("--${key}=$Value") } } } } } } $null = $c8yargs.Add("--pretty=false") if ($WhatIfPreference) { $null = $c8yargs.Add("--dry") } if ($VerbosePreference) { $null = $c8yargs.Add("--verbose") } if ($TimeoutSec) { # Convert to milliseconds (cast to an integer) [int] $TimeoutInMS = $TimeoutSec * 1000 $null = $c8yargs.AddRange(@("--timeout", $TimeoutInMS)) } # Include all pagination results if ($IncludeAll) { Write-Warning "IncludeAll operation is currently not implemented" # $null = $c8yargs.Add("--all") } $null = $c8yargs.Add("--raw") $c8ycli = Get-ClientBinary Write-Verbose ("$c8ycli {0}" -f $c8yargs -join " ") try { $RawResponse = & $c8ycli $c8yargs } catch { Write-Warning -Message $_.Exception.Message # do nothing, due to remote powershell session issue and $ErrorActionPreference being set to 'Stop' # https://github.com/PowerShell/PowerShell/issues/4002 } $ExitCode = $LASTEXITCODE if ($ExitCode -ne 0) { try { $errormessage = $RawResponse | Select-Object -First 1 | ConvertFrom-Json Write-Error ("{0}: {1}" -f @( $errormessage.error, $errormessage.message )) } catch { Write-Error "c8y command failed. $RawResponse" } return } $isJSON = $false try { # Hide senstive data in the response if ($env:C8Y_LOGGER_HIDE_SENSITIVE -eq "true") { if ($env:C8Y_TENANT) { $RawResponse = $RawResponse -replace [regex]::Unescape($env:C8Y_TENANT), "{tenant}" } if ($env:C8Y_USERNAME) { # $RawResponse = $RawResponse -replace [regex]::Unescape($env:C8Y_USERNAME), "{username}" } if ($env:C8Y_PASSWORD) { # $RawResponse = $RawResponse -replace [regex]::Unescape($env:C8Y_PASSWORD), "{password}" } } $response = $RawResponse | ConvertFrom-Json $isJSON = $true } catch { # ignore json errors, because sometimes the response is not json...so we want # to return it anyways } # Return quickly if a non-json response is detected if (!$isJSON) { Write-Verbose "non-json response detected" $global:_rawdata = $RawResponse $global:_data = $null $RawResponse return } $NestedData = Get-NestedProperty -InputObject $response -Name $ResultProperty if ($ResultProperty -and $ItemType) { $null = $NestedData ` | Select-Object ` | Add-PowershellType $ItemType } if ($response -and $Type) { $null = $response ` | Select-Object ` | Add-PowershellType $Type } $ReturnRawData = $Raw -or [string]::IsNullOrEmpty($ResultProperty) -or ( $Parameters.ContainsKey("WithTotalPages") -and $Parameters["WithTotalPages"] ) if ($response.statistics.pageSize) { Write-Verbose ("Statistics: currentPage={2}, pageSize={0}, totalPages={1}" -f @( $response.statistics.pageSize, $response.statistics.totalPages, $response.statistics.currentPage )) } <# if ($NestedData) { $null = Add-Member -InputObject $NestedData -MemberType NoteProperty -Name "PSStatistics" -Value @{ pageSize = $response.statistics.pageSize totalPages = $response.statistics.totalPages currentPage = $response.statistics.currentPage } } #> # Save last value for easier recall on command line $global:_rawdata = $response $global:_data = $null if ($null -ne $NestedData -or $NestedData.Count -ge 0) { $global:_data = $NestedData } if ($ReturnRawData -or ($null -eq $NestedData -and $null -eq $NestedData.Count)) { $response } else { $NestedData } } Function New-TemporaryDirectory { $parent = [System.IO.Path]::GetTempPath() [string] $name = [System.Guid]::NewGuid() New-Item -ItemType Directory -Path (Join-Path $parent $name) } Function Set-EnvironmentVariablesFromSession { <# .SYNOPSIS Set environment variables based on the current Cumulocity session .NOTES If no session is active, then it will clear the environment variables .EXAMPLE Set-EnvironmentVariablesFromSession .OUTPUTS None #> [cmdletbinding()] Param() $Session = Get-Session if ($null -eq $Session) { Write-Verbose "Clearing the Cumulocity environment variables" $Env:C8Y_URL = "" $Env:C8Y_BASEURL = "" $Env:C8Y_HOST = "" $Env:C8Y_TENANT = "" $Env:C8Y_USER = "" $Env:C8Y_USERNAME = "" $Env:C8Y_PASSWORD = "" return } Write-Verbose "Setting Cumulocity environment variables" $Env:C8Y_URL = $Session.host; # Used by @c8y/cli $Env:C8Y_BASEURL = $Session.host; $Env:C8Y_HOST = $Session.host; $Env:C8Y_TENANT = $Session.tenant; $Env:C8Y_USER = $Session.username; $Env:C8Y_USERNAME = $Session.username; $Env:C8Y_PASSWORD = $Session.password; } #endregion #region Public Functions # Code generated from specification version 1.0.0: DO NOT EDIT Function Add-AssetToGroup { <# .SYNOPSIS Add a group or device as an asset to an existing group .DESCRIPTION Assigns a group or device to an existing group and marks them as assets .EXAMPLE PS> Add-AssetToGroup -Group $Group1.id -NewChildGroup $Group2.id Create group heirachy (parent group -> child group) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Group (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Group, # New child device to be added to the group as an asset [Parameter()] [object[]] $NewChildDevice, # New child device group to be added to the group as an asset [Parameter()] [object[]] $NewChildGroup, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("NewChildDevice")) { $Parameters["newChildDevice"] = $NewChildDevice } if ($PSBoundParameters.ContainsKey("NewChildGroup")) { $Parameters["newChildGroup"] = $NewChildGroup } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Group)) { if ($item) { $Parameters["group"] = 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-ClientCommand ` -Noun "inventoryReferences" ` -Verb "createChildAsset" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectReference+json" ` -ItemType "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ResultProperty "managedObject" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Add-ChildDeviceToDevice { <# .SYNOPSIS Create a child device reference .DESCRIPTION Create a child device reference .EXAMPLE PS> Add-ChildDeviceToDevice -Device $Device.id -NewChild $ChildDevice.id Assign a device as a child device to an existing device .EXAMPLE PS> Get-ManagedObject -Id $ChildDevice.id | Add-ChildDeviceToDevice -Device $Device.id Assign a device as a child device to an existing device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device. (required) [Parameter(Mandatory = $true)] [object[]] $Device, # New child device (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $NewChild, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Device")) { $Parameters["device"] = $Device } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $NewChild)) { if ($item) { $Parameters["newChild"] = 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-ClientCommand ` -Noun "inventoryReferences" ` -Verb "assignChildDevice" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectReference+json" ` -ItemType "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ResultProperty "managedObject" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Add-ChildGroupToGroup { <# .SYNOPSIS Add a device group to an existing group .DESCRIPTION Assigns a group to a group. The group will be a childAsset of the group .EXAMPLE PS> Add-ChildGroupToGroup -Group $Group.id -NewChildGroup $ChildGroup1.id Add a group to a group as a child .EXAMPLE PS> Get-DeviceGroup $SubGroup1.name, $SubGroup2.name | Add-ChildGroupToGroup -Group $CustomGroup.id Add multiple devices to a group. Alternatively `Get-DeviceCollection` can be used to filter for a collection of devices and assign the results to a single group. #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Group (required) [Parameter(Mandatory = $true)] [object[]] $Group, # New child group to be added to the group as an child asset (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $NewChildGroup, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Group")) { $Parameters["group"] = $Group } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $NewChildGroup)) { if ($item) { $Parameters["newChildGroup"] = 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-ClientCommand ` -Noun "inventoryReferences" ` -Verb "assignGroupToGroup" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectReference+json" ` -ItemType "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ResultProperty "managedObject" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Add-DeviceToGroup { <# .SYNOPSIS Add a device to an existing group .DESCRIPTION Assigns a device to a group. The device will be a childAsset of the group .EXAMPLE PS> Add-DeviceToGroup -Group $Group.id -NewChildDevice $Device.id Add a device to a group .EXAMPLE PS> Get-Device $Device1.name, $Device2.name | Add-DeviceToGroup -Group $Group.id Add multiple devices to a group. Alternatively `Get-DeviceCollection` can be used to filter for a collection of devices and assign the results to a single group. #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Group (required) [Parameter(Mandatory = $true)] [object[]] $Group, # New device to be added to the group as an child asset (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $NewChildDevice, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Group")) { $Parameters["group"] = $Group } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $NewChildDevice)) { if ($item) { $Parameters["newChildDevice"] = 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-ClientCommand ` -Noun "inventoryReferences" ` -Verb "assignDeviceToGroup" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectReference+json" ` -ItemType "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ResultProperty "managedObject" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Add-RoleToGroup { <# .SYNOPSIS Add role to a group .DESCRIPTION Assign a role to a user group .EXAMPLE PS> Add-RoleToGroup -Group "${NamePattern}*" -Role "*ALARM_*" Add a role to a group using wildcards .EXAMPLE PS> Get-RoleCollection -PageSize 100 | Where-Object Name -like "*ALARM*" | Add-RoleToGroup -Group "${NamePattern}*" Add a role to a group using wildcards (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Group ID (required) [Parameter(Mandatory = $true)] [object[]] $Group, # User role id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Role, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Group")) { $Parameters["group"] = PSc8y\Expand-Id $Group } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Role)) { if ($item) { $Parameters["role"] = 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-ClientCommand ` -Noun "userRoles" ` -Verb "addRoleToGroup" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.roleReference+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Add-RoleToUser { <# .SYNOPSIS Add role to a user .DESCRIPTION Add role to a user .EXAMPLE PS> Add-RoleToUser -User $User.id -Role "ROLE_ALARM_READ" Add a role (ROLE_ALARM_READ) to a user .EXAMPLE PS> Add-RoleToUser -User "customUser_*" -Role "*ALARM_*" Add a role to a user using wildcards .EXAMPLE PS> Get-RoleCollection -PageSize 100 | Where-Object Name -like "*ALARM*" | Add-RoleToUser -User "customUser_*" Add a role to a user using wildcards (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # User prefix or full username (required) [Parameter(Mandatory = $true)] [object[]] $User, # User role id [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Role, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("User")) { $Parameters["user"] = $User } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["role"] = PSc8y\Expand-Id $Role if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "userRoles" ` -Verb "addRoleTouser" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.roleReference+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Add-UserToGroup { <# .SYNOPSIS Get user .DESCRIPTION Get user .EXAMPLE PS> Add-UserToGroup -Group $Group.id -User $User.id Add a user to a user group #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Group ID (required) [Parameter(Mandatory = $true)] [object[]] $Group, # User id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $User, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Group")) { $Parameters["group"] = PSc8y\Expand-Id $Group } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-User $User)) { if ($item) { $Parameters["user"] = 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-ClientCommand ` -Noun "userReferences" ` -Verb "addUserToGroup" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.userReference+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Approve-DeviceRequest { <# .SYNOPSIS Approve a new device request .DESCRIPTION Approve a new device request. Note: a device can only be approved if the platform has received a request for device credentials. .EXAMPLE PS> Approve-DeviceRequest -Id $DeviceRequest.id Approve a new device request #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device identifier (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Status of registration [Parameter()] [ValidateSet('ACCEPTED')] [string] $Status, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Id")) { $Parameters["id"] = $Id } if ($PSBoundParameters.ContainsKey("Status")) { $Parameters["status"] = $Status } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "deviceCredentials" ` -Verb "approveDeviceRequest" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.newDeviceRequest+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Copy-Application { <# .SYNOPSIS Copy application .DESCRIPTION A POST request to the 'clone' resource creates a new application based on an already existing one. The properties are copied to the newly created application. For name, key and context path a 'clone' prefix is added in order to be unique. If the target application is hosted and has an active version, the new application will have the active version with the same content. The response contains a representation of the newly created application. Required role ROLE_APPLICATION_MANAGMENT_ADMIN .EXAMPLE PS> Copy-Application -Id $App.id Copy an existing application #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Application id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Application $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "applications" ` -Verb "copy" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Disable-Application { <# .SYNOPSIS Disable application on tenant .DESCRIPTION Disable application on tenant .EXAMPLE PS> Disable-Application -Tenant mycompany -Application myMicroservice Disable an application of a tenant #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Application id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Application, # Tenant id. Defaults to current tenant (based on credentials) [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Application $Application)) { if ($item) { $Parameters["application"] = 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-ClientCommand ` -Noun "tenants" ` -Verb "disableApplication" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Disable-Microservice { <# .SYNOPSIS Disable (unsubscribe) a microservice .DESCRIPTION Disable (unsubscribe) a microservice from the current tenant .EXAMPLE PS> Disable-Microservice -Id $App.id Disable (unsubscribe) to a microservice #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Microservice id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Tenant id [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Microservice $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "microservices" ` -Verb "disable" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Enable-Application { <# .SYNOPSIS Enable application on tenant .DESCRIPTION Enable application on tenant .EXAMPLE PS> Enable-Application -Tenant mycompany -Application myMicroservice Enable an application of a tenant #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Application id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Application, # Tenant id. Defaults to current tenant (based on credentials) [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Application $Application)) { if ($item) { $Parameters["application"] = 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-ClientCommand ` -Noun "tenants" ` -Verb "enableApplication" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.applicationReference+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Enable-Microservice { <# .SYNOPSIS Enable/subscribe a microservice .DESCRIPTION Enabling (subscribing) a microservice will activate the application in the tenant .EXAMPLE PS> Enable-Microservice -Id $App.id Enable (subscribe) to a microservice #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Microservice id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Tenant id [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Microservice $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "microservices" ` -Verb "enable" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.applicationReference+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Agent { <# .SYNOPSIS Get agent .DESCRIPTION Get an agent's managed object representation .EXAMPLE PS> Get-Agent -Id $agent.id Get agent by id .EXAMPLE PS> Get-Agent -Id $agent.name Get agent by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Agent ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "agents" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customAgent+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Alarm { <# .SYNOPSIS Get alarm/s .DESCRIPTION Get an alarm by its id .EXAMPLE PS> Get-Alarm -Id {{ NewAlarm }} Get alarm #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Alarm id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "alarms" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.alarm+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-AlarmCollection { <# .SYNOPSIS Get a collection of alarms based on filter parameters .DESCRIPTION Get a collection of alarms based on filter parameters .EXAMPLE PS> Get-AlarmCollection -Severity MAJOR -PageSize 100 Get alarms with the severity set to MAJOR .EXAMPLE PS> Get-AlarmCollection -DateFrom "-10m" -Status ACTIVE Get active alarms which occurred in the last 10 minutes .EXAMPLE PS> Get-DeviceCollection -Name $Device.name | Get-AlarmCollection -Status ACTIVE Get active alarms from a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Source device id. [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Start date or date and time of alarm occurrence. [Parameter()] [string] $DateFrom, # End date or date and time of alarm occurrence. [Parameter()] [string] $DateTo, # Alarm type. [Parameter()] [string] $Type, # Alarm fragment type. [Parameter()] [string] $FragmentType, # Comma separated alarm statuses, for example ACTIVE,CLEARED. [Parameter()] [ValidateSet('ACTIVE','ACKNOWLEDGED','CLEARED')] [string] $Status, # Alarm severity, for example CRITICAL, MAJOR, MINOR or WARNING. [Parameter()] [ValidateSet('CRITICAL','MAJOR','MINOR','WARNING')] [string] $Severity, # When set to true only resolved alarms will be removed (the one with status CLEARED), false means alarms with status ACTIVE or ACKNOWLEDGED. [Parameter()] [switch] $Resolved, # Include assets [Parameter()] [switch] $WithAssets, # Include devices [Parameter()] [switch] $WithDevices, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("Status")) { $Parameters["status"] = $Status } if ($PSBoundParameters.ContainsKey("Severity")) { $Parameters["severity"] = $Severity } if ($PSBoundParameters.ContainsKey("Resolved")) { $Parameters["resolved"] = $Resolved } if ($PSBoundParameters.ContainsKey("WithAssets")) { $Parameters["withAssets"] = $WithAssets } if ($PSBoundParameters.ContainsKey("WithDevices")) { $Parameters["withDevices"] = $WithDevices } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["device"] = PSc8y\Expand-Id $Device if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "alarms" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.alarmCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.alarm+json" ` -ResultProperty "alarms" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-AllTenantUsageSummaryStatistics { <# .SYNOPSIS Get collection of tenant usage statistics summary .DESCRIPTION Get collection of tenant usage statistics summary .EXAMPLE PS> Get-AllTenantUsageSummaryStatistics Get tenant summary statistics for all tenants .EXAMPLE PS> Get-AllTenantUsageSummaryStatistics -DateFrom "-30d" Get tenant summary statistics collection for the last 30 days .EXAMPLE PS> Get-AllTenantUsageSummaryStatistics -DateFrom "-10d" -DateTo "-9d" Get tenant summary statistics collection for the last 10 days, only return until the last 9 days #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Start date or date and time of the statistics. [Parameter()] [string] $DateFrom, # End date or date and time of the statistics. [Parameter()] [string] $DateTo, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "tenantStatistics" ` -Verb "listSummaryAllTenants" ` -Parameters $Parameters ` -Type "application/json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Application { <# .SYNOPSIS Get an application .DESCRIPTION Get an application by its id or name .EXAMPLE PS> Get-Application -Id $App.id Get an application by id .EXAMPLE PS> Get-Application -Id $App.name Get an application by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Application id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Application $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "applications" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ApplicationBinaryCollection { <# .SYNOPSIS Get application binaries .DESCRIPTION A list of all binaries related to the given application will be returned .EXAMPLE PS> Get-ApplicationBinaryCollection -Id $App.id List all of the binaries related to a Hosted (web) application .EXAMPLE PS> Get-Application $App.id | Get-ApplicationBinaryCollection List all of the binaries related to a Hosted (web) application (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Application id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Application $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "applications" ` -Verb "listApplicationBinaries" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customAttachmentCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.customBinaryAttachment+json" ` -ResultProperty "attachments" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ApplicationCollection { <# .SYNOPSIS Get a collection of applications .DESCRIPTION Get a collection of applications by a given filter .EXAMPLE PS> Get-ApplicationCollection -PageSize 100 Get applications #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Application type [Parameter()] [ValidateSet('APAMA_CEP_RULE','EXTERNAL','HOSTED','MICROSERVICE')] [string] $Type, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "applications" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.applicationCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.application+json" ` -ResultProperty "applications" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ApplicationReferenceCollection { <# .SYNOPSIS Get a collection of application references on a tenant .DESCRIPTION Get a collection of application references on a tenant .EXAMPLE PS> Get-ApplicationReferenceCollection -Tenant mycompany Get a list of referenced applications on a given tenant (from management tenant) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Tenant id [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object] $Tenant, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["tenant"] = PSc8y\Expand-Id $Tenant if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "tenants" ` -Verb "listReferences" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.applicationReferenceCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.applicationReference+json" ` -ResultProperty "references" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-AuditRecord { <# .SYNOPSIS Get an audit record .DESCRIPTION Get an audit record by id .EXAMPLE PS> Get-AuditRecord -Id $Record.id Get an audit record by id #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Audit id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "auditRecords" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.auditRecord+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-AuditRecordCollection { <# .SYNOPSIS Get collection of (user) audits .DESCRIPTION Audit records contain information about modifications to other Cumulocity entities. For example the audit records contain each operation state transition, so they can be used to check when an operation transitioned from PENDING -> EXECUTING -> SUCCESSFUL. .EXAMPLE PS> Get-AuditRecordCollection -PageSize 100 Get a list of audit records .EXAMPLE PS> Get-AuditRecordCollection -Source $Device2.id Get a list of audit records related to a managed object .EXAMPLE PS> Get-Operation -Id $Operation.id | Get-AuditRecordCollection Get a list of audit records related to an operation #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Source Id or object containing an .id property of the element that should be detected. i.e. AlarmID, or Operation ID. Note: Only one source can be provided [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object] $Source, # Type [Parameter()] [string] $Type, # Username [Parameter()] [string] $User, # Application [Parameter()] [string] $Application, # Start date or date and time of audit record occurrence. [Parameter()] [string] $DateFrom, # End date or date and time of audit record occurrence. [Parameter()] [string] $DateTo, # Return the newest instead of the oldest audit records. Must be used with dateFrom and dateTo parameters [Parameter()] [switch] $Revert, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("User")) { $Parameters["user"] = $User } if ($PSBoundParameters.ContainsKey("Application")) { $Parameters["application"] = $Application } if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("Revert")) { $Parameters["revert"] = $Revert } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["source"] = PSc8y\Expand-Id $Source if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "auditRecords" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.auditRecordCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.auditRecord+json" ` -ResultProperty "auditRecords" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Binary { <# .SYNOPSIS Get binary .DESCRIPTION Download a binary stored in Cumulocity and display it on the console. For non text based binaries or if the output should be saved to file, the output parameter should be used to write the file directly to a local file. .EXAMPLE PS> Get-Binary -Id $Binary.id Get a binary and display the contents on the console .EXAMPLE PS> Get-Binary -Id $Binary.id -OutputFile ./download-binary1.txt Get a binary and save it to a file #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Inventory binary id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "binaries" ` -Verb "get" ` -Parameters $Parameters ` -Type "*/*" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-BinaryCollection { <# .SYNOPSIS Get collection of inventory binaries .DESCRIPTION Get a list of inventory binaries. The results include the meta information about binary and not the binary itself. .EXAMPLE PS> Get-BinaryCollection -PageSize 100 Get a list of binaries #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "binaries" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ResultProperty "managedObjects" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ChildAssetCollection { <# .SYNOPSIS Get a collection of managedObjects child references .DESCRIPTION Get a collection of managedObjects child references .EXAMPLE PS> Get-ChildAssetCollection -Group $Group.id Get a list of the child assets of an existing device .EXAMPLE PS> Get-ChildAssetCollection -Group $Group.id Get a list of the child assets of an existing group #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device. [Parameter()] [object[]] $Device, # Group. [Parameter()] [object[]] $Group, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Device")) { $Parameters["device"] = $Device } if ($PSBoundParameters.ContainsKey("Group")) { $Parameters["group"] = $Group } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "inventoryReferences" ` -Verb "listChildAssets" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectReferenceCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ResultProperty "references.managedObject" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ChildAssetReference { <# .SYNOPSIS Get managed object child asset reference .DESCRIPTION Get managed object child asset reference .EXAMPLE PS> Get-ChildAssetReference -Asset $Agent.id -Reference $Ref.id Get an existing child asset reference #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Asset id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Asset, # Asset reference id (required) [Parameter(Mandatory = $true)] [object[]] $Reference, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Reference")) { $Parameters["reference"] = $Reference } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Asset)) { if ($item) { $Parameters["asset"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "inventoryReferences" ` -Verb "getChildAsset" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectReference+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ChildDeviceCollection { <# .SYNOPSIS Get a collection of managedObjects child references .DESCRIPTION Get a collection of managedObjects child references .EXAMPLE PS> Get-ChildDeviceCollection -Device $Device.id Get a list of the child devices of an existing device .EXAMPLE PS> Get-ManagedObject -Id $Device.id | Get-ChildDeviceCollection Get a list of the child devices of an existing device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device. (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Device)) { if ($item) { $Parameters["device"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "inventoryReferences" ` -Verb "listChildDevices" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectReferenceCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ResultProperty "references.managedObject" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ChildDeviceReference { <# .SYNOPSIS Get managed object child device reference .DESCRIPTION Get managed object child device reference .EXAMPLE PS> Get-ChildDeviceReference -Device $Agent.id -Reference $Ref.id Get an existing child device reference #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # ManagedObject id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Device reference id (required) [Parameter(Mandatory = $true)] [object[]] $Reference, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Reference")) { $Parameters["reference"] = $Reference } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Device)) { if ($item) { $Parameters["device"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "inventoryReferences" ` -Verb "getChildDevice" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectReference+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-CurrentApplication { <# .SYNOPSIS Get current application .DESCRIPTION Getting the current application only works when using bootstrap credentials from an application (not user credentials) .EXAMPLE PS> Get-CurrentApplication Get the current application (requires using application credentials) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "currentApplication" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-CurrentApplicationSubscription { <# .SYNOPSIS Get current application subscriptions .DESCRIPTION Required authentication with bootstrap user .EXAMPLE PS> Get-CurrentApplicationSubscription List the current application users/subscriptions #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "currentApplication" ` -Verb "listSubscriptions" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.applicationUserCollection+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-CurrentTenant { <# .SYNOPSIS Get current tenant .DESCRIPTION Get current tenant .EXAMPLE PS> Get-CurrentTenant Get the current tenant (based on your current credentials) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "tenants" ` -Verb "getCurrentTenant" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.currentTenant+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-CurrentUser { <# .SYNOPSIS Get user .DESCRIPTION Get the user representation associated with the current credentials used by the request .EXAMPLE PS> Get-CurrentUser Get the current user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "users" ` -Verb "getCurrentUser" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.currentUser+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-CurrentUserInventoryRole { <# .SYNOPSIS Get a specific inventory role of the current user .DESCRIPTION Get a specific inventory role of the current user .EXAMPLE PS> Get-CurrentUserInventoryRoleCollection -PageSize 1 | Get-CurrentUserInventoryRole Get an inventory role of the current user (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Role id. Note: lookup by name is not yet supported (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [long] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "users" ` -Verb "getCurrentUserInventoryRole" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.inventoryrole+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-CurrentUserInventoryRoleCollection { <# .SYNOPSIS Get the current users inventory roles .DESCRIPTION Get a list of inventory roles currently assigned to the user .EXAMPLE PS> Get-CurrentUserInventoryRoleCollection Get the current users inventory roles #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "users" ` -Verb "listInventoryRoles" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.inventoryrolecollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.inventoryrole+json" ` -ResultProperty "roles" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-DataBrokerConnector { <# .SYNOPSIS Get data broker connector .DESCRIPTION Get data broker connector .EXAMPLE PS> Get-DataBrokerConnector -Id $DataBroker.id Get a data broker connector #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Data broker connector id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "databroker" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.databrokerConnector+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-DataBrokerConnectorCollection { <# .SYNOPSIS Get collection of data broker connectors .DESCRIPTION Get collection of data broker connectors .EXAMPLE PS> Get-DataBrokerConnectorCollection Get a list of data broker connectors #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "databroker" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.databrokerConnectorCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.databrokerConnector+json" ` -ResultProperty "connectors" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Device { <# .SYNOPSIS Get device .DESCRIPTION Get a device by name or id. .EXAMPLE PS> Get-Device -Id $device.id Get device by id .EXAMPLE PS> Get-Device -Id $device.name Get device by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "devices" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customDevice+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-DeviceGroup { <# .SYNOPSIS Get device group .DESCRIPTION Get a device group by id or name .EXAMPLE PS> Get-DeviceGroup -Id $group.id Get device group by id .EXAMPLE PS> Get-DeviceGroup -Id $group.name Get device group by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device group ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "devices" ` -Verb "getGroup" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customDeviceGroup+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-DeviceRequest { <# .SYNOPSIS Get a new device requests .DESCRIPTION Get a new device requests .EXAMPLE PS> Get-DeviceRequest -Id "010af8dd0c102" Get a new device request #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # New Device Request ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "deviceCredentials" ` -Verb "getNewDeviceRequest" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.newDeviceRequest+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-DeviceRequestCollection { <# .SYNOPSIS Get a collection of new device requests .DESCRIPTION Get a collection of device requests .EXAMPLE PS> Get-DeviceRequestCollection Get a list of new device requests #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "deviceCredentials" ` -Verb "listNewDeviceRequests" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.newDeviceRequestCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.newDeviceRequest+json" ` -ResultProperty "newDeviceRequests" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Event { <# .SYNOPSIS Get event/s .DESCRIPTION Get an event by id .EXAMPLE PS> Get-Event -Id {{ NewEvent }} Get event #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Event id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Id")) { $Parameters["id"] = $Id } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { Invoke-ClientCommand ` -Noun "events" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.event+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-EventBinary { <# .SYNOPSIS Get event binary .DESCRIPTION Get the binary associated with an event .EXAMPLE PS> Get-EventBinary -Id $Event.id -OutputFile ./eventbinary.txt Download a binary related to an event #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Event id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "events" ` -Verb "downloadBinary" ` -Parameters $Parameters ` -Type "*/*" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-EventCollection { <# .SYNOPSIS Get a collection of events based on filter parameters .DESCRIPTION Get a collection of events based on filter parameters .EXAMPLE PS> Get-EventCollection -Type "my_CustomType2" -DateFrom "-10d" Get events with type 'my_CustomType' that were created in the last 10 days .EXAMPLE PS> Get-EventCollection -Device $Device.id Get events from a device .EXAMPLE PS> Get-DeviceCollection -Name $Device.name | Get-EventCollection Get events from a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Event type. [Parameter()] [string] $Type, # Fragment name from event. [Parameter()] [string] $FragmentType, # Start date or date and time of event occurrence. [Parameter()] [string] $DateFrom, # End date or date and time of event occurrence. [Parameter()] [string] $DateTo, # Return the newest instead of the oldest events. Must be used with dateFrom and dateTo parameters [Parameter()] [switch] $Revert, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("Revert")) { $Parameters["revert"] = $Revert } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["device"] = PSc8y\Expand-Id $Device if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "events" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.eventCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.event+json" ` -ResultProperty "events" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ExternalId { <# .SYNOPSIS Get external id .DESCRIPTION Get an external identity object. An external identify will include the reference to a single device managed object .EXAMPLE PS> Get-ExternalId -Type "my_SerialNumber" -Name "myserialnumber" Get external identity #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # External identity type (required) [Parameter(Mandatory = $true)] [string] $Type, # External identity id/name (required) [Parameter(Mandatory = $true)] [string] $Name, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "identity" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.externalId+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ExternalIdCollection { <# .SYNOPSIS Get a collection of external ids based on filter parameters .DESCRIPTION Get a collection of external ids based on filter parameters .EXAMPLE PS> Get-ExternalIdCollection -Device $Device.id Get a list of external ids #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Device)) { if ($item) { $Parameters["device"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "identity" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.externalIdCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.externalId+json" ` -ResultProperty "externalIds" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Group { <# .SYNOPSIS Create a new group by id .DESCRIPTION Create a new group by id .EXAMPLE PS> Get-Group -Id $Group.id Get a user group #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Group id [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["id"] = PSc8y\Expand-Id $Id if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "userGroups" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.group+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-GroupByName { <# .SYNOPSIS Get a group by name .DESCRIPTION Get a group by name .EXAMPLE PS> Get-GroupByName -Name $Group.name Get user group by its name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Group name [Parameter()] [string] $Name, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "userGroups" ` -Verb "getByName" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.group+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-GroupCollection { <# .SYNOPSIS Get collection of (user) groups .DESCRIPTION Get collection of (user) groups .EXAMPLE PS> Get-GroupCollection Get a list of user groups for the current tenant #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Tenant [Parameter()] [object] $Tenant, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "userGroups" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.groupCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.group+json" ` -ResultProperty "groups" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-GroupMembershipCollection { <# .SYNOPSIS Get all users in a group .DESCRIPTION Get all users in a group .EXAMPLE PS> Get-GroupMembershipCollection -Id $Group.id List the users within a user group .EXAMPLE PS> Get-GroupByName -Name "business" | Get-GroupMembershipCollection List the users within a user group (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Group ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Tenant [Parameter()] [object] $Tenant, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "userReferences" ` -Verb "listGroupMembership" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.userReferenceCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.user+json" ` -ResultProperty "references.user" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ManagedObject { <# .SYNOPSIS Get managed objects/s .DESCRIPTION Get a managed object by id .EXAMPLE PS> Get-ManagedObject -Id $mo.id Get a managed object .EXAMPLE PS> Get-ManagedObject -Id $mo.id | Get-ManagedObject Get a managed object (using pipeline) .EXAMPLE PS> Get-ManagedObject -Id $mo.id -WithParents Get a managed object with parent references #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # ManagedObject id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # include a flat list of all parents and grandparents of the given object [Parameter()] [switch] $WithParents, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("WithParents")) { $Parameters["withParents"] = $WithParents } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "inventory" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.inventory+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-ManagedObjectCollection { <# .SYNOPSIS Get a collection of managedObjects based on filter parameters .DESCRIPTION Get a collection of managedObjects based on filter parameters .EXAMPLE PS> Get-ManagedObjectCollection Get a list of managed objects .EXAMPLE PS> Get-ManagedObjectCollection -Device $Device1.name, $Device2.name Get a list of managed objects by looking up their names #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # List of ids. [Parameter()] [object[]] $Device, # ManagedObject type. [Parameter()] [string] $Type, # ManagedObject fragment type. [Parameter()] [string] $FragmentType, # managed objects containing a text value starting with the given text (placeholder {text}). Text value is any alphanumeric string starting with a latin letter (A-Z or a-z). [Parameter()] [string] $Text, # include a flat list of all parents and grandparents of the given object [Parameter()] [switch] $WithParents, # Don't include the child devices names in the resonse. This can improve the api's response because the names don't need to be retrieved [Parameter()] [switch] $SkipChildrenNames, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Device")) { $Parameters["device"] = $Device } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("Text")) { $Parameters["text"] = $Text } if ($PSBoundParameters.ContainsKey("WithParents")) { $Parameters["withParents"] = $WithParents } if ($PSBoundParameters.ContainsKey("SkipChildrenNames")) { $Parameters["skipChildrenNames"] = $SkipChildrenNames } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "inventory" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ResultProperty "managedObjects" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Measurement { <# .SYNOPSIS Get measurement/s .DESCRIPTION Get measurements by their ids .EXAMPLE PS> Get-Measurement -Id $Measurement.id Get measurement #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Measurement id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "measurements" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.measurement+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-MeasurementCollection { <# .SYNOPSIS Get a collection of measurements based on filter parameters .DESCRIPTION Get a collection of measurements based on filter parameters .EXAMPLE PS> Get-MeasurementCollection Get a list of measurements .EXAMPLE PS> Get-MeasurementCollection -Device $Device.id -Type "TempReading" Get a list of measurements for a particular device .EXAMPLE PS> Get-DeviceCollection -Name $Device.name | Get-MeasurementCollection Get measurements from a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Measurement type. [Parameter()] [string] $Type, # value fragment type [Parameter()] [string] $ValueFragmentType, # value fragment series [Parameter()] [string] $ValueFragmentSeries, # Fragment name from measurement (deprecated). [Parameter()] [string] $FragmentType, # Start date or date and time of measurement occurrence. [Parameter()] [string] $DateFrom, # End date or date and time of measurement occurrence. [Parameter()] [string] $DateTo, # Return the newest instead of the oldest measurements. Must be used with dateFrom and dateTo parameters [Parameter()] [switch] $Revert, # Results will be displayed in csv format [Parameter()] [switch] $Csv, # Results will be displayed in Excel format [Parameter()] [switch] $Excel, # Every measurement fragment which contains 'unit' property will be transformed to use required system of units. [Parameter()] [ValidateSet('imperial','metric')] [string] $Unit, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("ValueFragmentType")) { $Parameters["valueFragmentType"] = $ValueFragmentType } if ($PSBoundParameters.ContainsKey("ValueFragmentSeries")) { $Parameters["valueFragmentSeries"] = $ValueFragmentSeries } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("Revert")) { $Parameters["revert"] = $Revert } if ($PSBoundParameters.ContainsKey("Csv")) { $Parameters["csv"] = $Csv } if ($PSBoundParameters.ContainsKey("Excel")) { $Parameters["excel"] = $Excel } if ($PSBoundParameters.ContainsKey("Unit")) { $Parameters["unit"] = $Unit } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["device"] = PSc8y\Expand-Id $Device if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "measurements" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.measurementCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.measurement+json" ` -ResultProperty "measurements" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-MeasurementSeries { <# .SYNOPSIS Get a collection of measurements based on filter parameters .DESCRIPTION Get a collection of measurements based on filter parameters .EXAMPLE PS> Get-MeasurementSeries -Device $Device.id -Series "c8y_Temperature.T" -DateFrom "1970-01-01" -DateTo "0s" Get a list of measurements for a particular device .EXAMPLE PS> Get-MeasurementSeries -Device $Measurement2.source.id -Series "c8y_Temperature.T" -DateFrom "1970-01-01" -DateTo "0s" Get measurement series c8y_Temperature.T on a device .EXAMPLE PS> Get-DeviceCollection -Name $Device.name | Get-MeasurementSeries -Series "c8y_Temperature.T" Get measurement series from a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # measurement type and series name, e.g. c8y_AccelerationMeasurement.acceleration [Parameter()] [string[]] $Series, # Fragment name from measurement. [Parameter()] [ValidateSet('DAILY','HOURLY','MINUTELY')] [string] $AggregationType, # Start date or date and time of measurement occurrence. Defaults to last 7 days [Parameter()] [string] $DateFrom, # End date or date and time of measurement occurrence. Defaults to the current time [Parameter()] [string] $DateTo, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Series")) { $Parameters["series"] = $Series } if ($PSBoundParameters.ContainsKey("AggregationType")) { $Parameters["aggregationType"] = $AggregationType } if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["device"] = PSc8y\Expand-Id $Device if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "measurements" ` -Verb "getSeries" ` -Parameters $Parameters ` -Type "application/json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Microservice { <# .SYNOPSIS Get microservice .DESCRIPTION Get an existing microservice by id or name .EXAMPLE PS> Get-Microservice -Id $App.id Get an microservice by id .EXAMPLE PS> Get-Microservice -Id $App.name Get an microservice by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Microservice id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Microservice $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "microservices" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-MicroserviceBootstrapUser { <# .SYNOPSIS Get microservice bootstrap user .DESCRIPTION Get the bootstrap user associated to a microservice. The bootstrap user is required when running a microservice locally (i.e. during development) .EXAMPLE PS> Get-MicroserviceBootstrapUser -Id $App.name Get application bootstrap user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Microservice id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Microservice $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "microservices" ` -Verb "getBootstrapUser" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.bootstrapuser+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-MicroserviceCollection { <# .SYNOPSIS Get collection of microservices .DESCRIPTION Get a collection of microservices in the current tenant .EXAMPLE PS> Get-MicroserviceCollection -PageSize 100 Get microservices #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Application type [Parameter()] [ValidateSet('MICROSERVICE')] [string] $Type, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "microservices" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.applicationCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.application+json" ` -ResultProperty "applications" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Operation { <# .SYNOPSIS Get operation/s .DESCRIPTION Get an operation by id .EXAMPLE PS> Get-Operation -Id {{ NewOperation }} Get operation by id #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Operation id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "operations" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.operation+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-OperationCollection { <# .SYNOPSIS Get a collection of operations based on filter parameters .DESCRIPTION Get a collection of operations based on filter parameters .EXAMPLE PS> Get-OperationCollection -Status PENDING Get a list of pending operations .EXAMPLE PS> Get-OperationCollection -Agent $Agent.id -Status PENDING Get a list of pending operations for a given agent and all of its child devices .EXAMPLE PS> Get-OperationCollection -Device $Device.id -Status PENDING Get a list of pending operations for a device .EXAMPLE PS> Get-DeviceCollection -Name $Agent2.name | Get-OperationCollection Get operations from a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Agent ID [Parameter()] [object[]] $Agent, # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Start date or date and time of operation. [Parameter()] [string] $DateFrom, # End date or date and time of operation. [Parameter()] [string] $DateTo, # Operation status, can be one of SUCCESSFUL, FAILED, EXECUTING or PENDING. [Parameter()] [ValidateSet('PENDING','EXECUTING','SUCCESSFUL','FAILED')] [string] $Status, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Agent")) { $Parameters["agent"] = $Agent } if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("Status")) { $Parameters["status"] = $Status } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["device"] = PSc8y\Expand-Id $Device if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "operations" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.operationCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.operation+json" ` -ResultProperty "operations" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-RetentionRule { <# .SYNOPSIS Get retention rule .DESCRIPTION Get an existing retention by id .EXAMPLE PS> Get-RetentionRule -Id $RetentionRule.id Get a retention rule #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Retention rule id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "retentionRules" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.retentionRule+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-RetentionRuleCollection { <# .SYNOPSIS Get collection of retention rules .DESCRIPTION Get a collection of retention rules configured in the current tenant .EXAMPLE PS> Get-RetentionRuleCollection Get a list of retention rules #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "retentionRules" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.retentionRuleCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.retentionRule+json" ` -ResultProperty "retentionRules" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-RoleCollection { <# .SYNOPSIS Get collection of user roles .DESCRIPTION Get collection of user roles .EXAMPLE PS> Get-RoleCollection -PageSize 100 Get a list of roles #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "userRoles" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.roleCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.role+json" ` -ResultProperty "roles" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-RoleReferenceCollectionFromGroup { <# .SYNOPSIS Get collection of user role references from a group .DESCRIPTION Get collection of user role references from a group .EXAMPLE PS> Get-RoleReferenceCollectionFromGroup -Group $Group.id Get a list of role references for a user group #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Group id (required) [Parameter(Mandatory = $true)] [object[]] $Group, # Tenant [Parameter()] [object] $Tenant, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Group")) { $Parameters["group"] = PSc8y\Expand-Id $Group } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "userRoles" ` -Verb "getRoleReferenceCollectionFromGroup" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.roleReferenceCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.roleReference+json" ` -ResultProperty "references" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-RoleReferenceCollectionFromUser { <# .SYNOPSIS Get collection of user role references from a user .DESCRIPTION Get collection of user role references from a user .EXAMPLE PS> Get-RoleReferenceCollectionFromUser -User $User.id Get a list of role references for a user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # User (required) [Parameter(Mandatory = $true)] [object[]] $User, # Tenant [Parameter()] [object] $Tenant, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("User")) { $Parameters["user"] = $User } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "userRoles" ` -Verb "getRoleReferenceCollectionFromUser" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.roleReferenceCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.roleReference+json" ` -ResultProperty "references" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-SupportedMeasurements { <# .SYNOPSIS Get supported measurements/s of a device .DESCRIPTION Returns a list of fragments (valueFragmentTypes) related to the device .EXAMPLE PS> Get-SupportedMeasurements -Device $device.id Get the supported measurements of a device by name .EXAMPLE PS> Get-SupportedMeasurements -Device $device.id Get the supported measurements of a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Device)) { if ($item) { $Parameters["device"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "devices" ` -Verb "getSupportedMeasurements" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.inventory+json" ` -ItemType "" ` -ResultProperty "c8y_SupportedMeasurements" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-SupportedOperations { <# .SYNOPSIS Get supported operations of a device .DESCRIPTION Returns a list of supported operations (fragments) for a device. The supported fragments list is returned from the c8y_SupportedOperations fragment of the device managed object. .EXAMPLE PS> Get-SupportedOperations -Device $device.id Get the supported operations of a device by name .EXAMPLE PS> Get-SupportedOperations -Device $device.id Get the supported operations of a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Device)) { if ($item) { $Parameters["device"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "devices" ` -Verb "getSupportedOperations" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.inventory+json" ` -ItemType "" ` -ResultProperty "c8y_SupportedOperations" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-SupportedSeries { <# .SYNOPSIS Get supported measurement series/s of a device .DESCRIPTION Returns a list of supported measurement series .EXAMPLE PS> Get-SupportedSeries -Device $device.id Get the supported measurement series of a device by name .EXAMPLE PS> Get-SupportedSeries -Device $device.id Get the supported measurement series of a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Device)) { if ($item) { $Parameters["device"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "devices" ` -Verb "getSupportedSeries" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.inventory+json" ` -ItemType "" ` -ResultProperty "c8y_SupportedSeries" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-SystemOption { <# .SYNOPSIS Get system option .DESCRIPTION Get a system option by category and key .EXAMPLE PS> Get-SystemOption -Category "system" -Key "version" Get system option value #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # System Option category (required) [Parameter(Mandatory = $true)] [string] $Category, # System Option key (required) [Parameter(Mandatory = $true)] [string] $Key, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Category")) { $Parameters["category"] = $Category } if ($PSBoundParameters.ContainsKey("Key")) { $Parameters["key"] = $Key } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "systemOptions" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.option+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-SystemOptionCollection { <# .SYNOPSIS Get collection of system options .DESCRIPTION This endpoint provides a set of read-only properties pre-defined in platform configuration. The response format is exactly the same as for OptionCollection. .EXAMPLE PS> Get-SystemOptionCollection Get a list of system options #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "systemOptions" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.optionCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.option+json" ` -ResultProperty "options" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-Tenant { <# .SYNOPSIS Get tenant .DESCRIPTION Get tenant .EXAMPLE PS> Get-Tenant -Id mycompany Get a tenant by name (from the management tenant) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Tenant id [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["id"] = PSc8y\Expand-Id $Id if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "tenants" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.tenant+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-TenantCollection { <# .SYNOPSIS Get collection of tenants .DESCRIPTION Get collection of tenants .EXAMPLE PS> Get-TenantCollection Get a list of tenants #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "tenants" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.tenantCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.tenant+json" ` -ResultProperty "tenants" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-TenantOption { <# .SYNOPSIS Get tenant option .DESCRIPTION Get tenant option .EXAMPLE PS> Get-TenantOption -Category "c8y_cli_tests" -Key "$option2" Get a tenant option #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Tenant Option category (required) [Parameter(Mandatory = $true)] [string] $Category, # Tenant Option key (required) [Parameter(Mandatory = $true)] [string] $Key, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Category")) { $Parameters["category"] = $Category } if ($PSBoundParameters.ContainsKey("Key")) { $Parameters["key"] = $Key } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "tenantOptions" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.option+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-TenantOptionCollection { <# .SYNOPSIS Get collection of tenant options .DESCRIPTION Get collection of tenant options .EXAMPLE PS> Get-TenantOptionCollection Get a list of tenant options #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "tenantOptions" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.optionCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.option+json" ` -ResultProperty "options" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-TenantOptionForCategory { <# .SYNOPSIS Get tenant options for category .DESCRIPTION Get tenant options for category .EXAMPLE PS> Get-TenantOptionForCategory -Category "c8y_cli_tests" Get a list of options for a category #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Tenant Option category (required) [Parameter(Mandatory = $true)] [string] $Category, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Category")) { $Parameters["category"] = $Category } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "tenantOptions" ` -Verb "getForCategory" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.optionCollection+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-TenantStatisticsCollection { <# .SYNOPSIS Get collection of tenant usage statistics .DESCRIPTION Get collection of tenant usage statistics .EXAMPLE PS> Get-TenantStatisticsCollection Get tenant statistics collection .EXAMPLE PS> Get-TenantStatisticsCollection -DateFrom "-30d" -PageSize 30 Get tenant statistics collection for the last 30 days .EXAMPLE PS> Get-TenantStatisticsCollection -DateFrom "-3d" -DateTo "-2d" Get tenant statistics collection for the day before yesterday #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Start date or date and time of the statistics. [Parameter()] [string] $DateFrom, # End date or date and time of the statistics. [Parameter()] [string] $DateTo, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "tenantStatistics" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.tenantUsageStatisticsCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.tenantUsageStatisticsSummary+json" ` -ResultProperty "usageStatistics" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-TenantUsageSummaryStatistics { <# .SYNOPSIS Get collection of tenant usage statistics summary .DESCRIPTION Get summary of requests and database usage from the start of this month until now .EXAMPLE PS> Get-TenantUsageSummaryStatistics Get tenant summary statistics for the current tenant .EXAMPLE PS> Get-TenantUsageSummaryStatistics -DateFrom "-30d" Get tenant summary statistics collection for the last 30 days .EXAMPLE PS> Get-TenantUsageSummaryStatistics -DateFrom "-10d" -DateTo "-9d" Get tenant summary statistics collection for the last 10 days, only return until the last 9 days #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Start date or date and time of the statistics. [Parameter()] [string] $DateFrom, # End date or date and time of the statistics. [Parameter()] [string] $DateTo, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "tenantStatistics" ` -Verb "listSummaryForTenant" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.tenantUsageStatisticsSummary+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-TenantVersion { <# .SYNOPSIS Get tenant platform (backend) version .DESCRIPTION Get tenant platform (backend) version .EXAMPLE PS> Get-TenantVersion Get the Cumulocity backend version #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "tenants" ` -Verb "getVersion" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.option+json" ` -ItemType "" ` -ResultProperty "value" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-User { <# .SYNOPSIS Get user .DESCRIPTION Get information about a user .EXAMPLE PS> Get-User -Id $User.id Get a user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # User id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-User $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "users" ` -Verb "get" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.user+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-UserByName { <# .SYNOPSIS Get user by username .DESCRIPTION Get the user details by referencing their username instead of id .EXAMPLE PS> Get-UserByName -Name $User.userName Get a user by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Username (required) [Parameter(Mandatory = $true)] [string] $Name, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "users" ` -Verb "getUserByName" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.user+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-UserCollection { <# .SYNOPSIS Get a collection of users based on filter parameters .DESCRIPTION Get a collection of users based on filter parameters .EXAMPLE PS> Get-UserCollection Get a list of users #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # prefix or full username [Parameter()] [string] $Username, # numeric group identifiers separated by commas; result will contain only users which belong to at least one of specified groups [Parameter()] [string] $Groups, # exact username [Parameter()] [string] $Owner, # If set to 'true', result will contain only users created during bootstrap process (starting with 'device_'). If flag is absent (or false) the result will not contain 'device_' users. [Parameter()] [switch] $OnlyDevices, # if set to 'true', then each of returned users will contain additional field 'subusersCount' - number of direct subusers (users with corresponding 'owner'). [Parameter()] [switch] $WithSubusersCount, # Include applications related to the user [Parameter()] [switch] $WithApps, # Include group information [Parameter()] [switch] $WithGroups, # Include role information [Parameter()] [switch] $WithRoles, # Tenant [Parameter()] [object] $Tenant, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Username")) { $Parameters["username"] = $Username } if ($PSBoundParameters.ContainsKey("Groups")) { $Parameters["groups"] = $Groups } if ($PSBoundParameters.ContainsKey("Owner")) { $Parameters["owner"] = $Owner } if ($PSBoundParameters.ContainsKey("OnlyDevices")) { $Parameters["onlyDevices"] = $OnlyDevices } if ($PSBoundParameters.ContainsKey("WithSubusersCount")) { $Parameters["withSubusersCount"] = $WithSubusersCount } if ($PSBoundParameters.ContainsKey("WithApps")) { $Parameters["withApps"] = $WithApps } if ($PSBoundParameters.ContainsKey("WithGroups")) { $Parameters["withGroups"] = $WithGroups } if ($PSBoundParameters.ContainsKey("WithRoles")) { $Parameters["withRoles"] = $WithRoles } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { Invoke-ClientCommand ` -Noun "users" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.userCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.user+json" ` -ResultProperty "users" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Get-UserMembershipCollection { <# .SYNOPSIS Get information about all groups that a user is a member of .DESCRIPTION Get information about all groups that a user is a member of .EXAMPLE PS> Get-UserMembershipCollection -Id $User.id Get a list of groups that a user belongs to #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # User (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Tenant [Parameter()] [object] $Tenant, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-User $Id)) { if ($item) { $Parameters["id"] = if ($item.id) { $item.id } else { $item } } Invoke-ClientCommand ` -Noun "users" ` -Verb "listUserMembership" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.groupReferenceCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.groupReference+json" ` -ResultProperty "references.group" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-Agent { <# .SYNOPSIS Create an agent .DESCRIPTION Create an agent managed object. An agent is a special device managed object with both the c8y_IsDevice and com_cumulocity_model_Agent fragments. .EXAMPLE PS> New-Agent -Name $AgentName Create agent .EXAMPLE PS> New-Agent -Name $AgentName -Data @{ myValue = @{ value1 = $true } } Create agent with custom properties #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Agent name (required) [Parameter(Mandatory = $true)] [string] $Name, # Agent type [Parameter()] [string] $Type, # Custom agent properties. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "agents" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customAgent+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-Alarm { <# .SYNOPSIS Create a new alarm .DESCRIPTION Create a new alarm on a device or agent. .EXAMPLE PS> New-Alarm -Device $device.id -Type c8y_TestAlarm -Time "-0s" -Text "Test alarm" -Severity MAJOR Create a new alarm for device .EXAMPLE PS> Get-Device -Id $device.id | PSc8y\New-Alarm -Type c8y_TestAlarm -Time "-0s" -Text "Test alarm" -Severity MAJOR Create a new alarm for device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # The ManagedObject that the alarm originated from (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Identifies the type of this alarm, e.g. 'com_cumulocity_events_TamperEvent'. (required) [Parameter(Mandatory = $true)] [string] $Type, # Time of the alarm. [Parameter()] [string] $Time, # Text description of the alarm. (required) [Parameter(Mandatory = $true)] [string] $Text, # The severity of the alarm: CRITICAL, MAJOR, MINOR or WARNING. Must be upper-case. (required) [Parameter(Mandatory = $true)] [ValidateSet('CRITICAL','MAJOR','MINOR','WARNING')] [string] $Severity, # The status of the alarm: ACTIVE, ACKNOWLEDGED or CLEARED. If status was not appeared, new alarm will have status ACTIVE. Must be upper-case. [Parameter()] [ValidateSet('ACTIVE','ACKNOWLEDGED','CLEARED')] [string] $Status, # Additional properties of the alarm. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Time")) { $Parameters["time"] = $Time } if ($PSBoundParameters.ContainsKey("Text")) { $Parameters["text"] = $Text } if ($PSBoundParameters.ContainsKey("Severity")) { $Parameters["severity"] = $Severity } if ($PSBoundParameters.ContainsKey("Status")) { $Parameters["status"] = $Status } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } 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-ClientCommand ` -Noun "alarms" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.alarm+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-Application { <# .SYNOPSIS Create a new application .DESCRIPTION Create a new application using explicit settings .EXAMPLE PS> New-Application -Name $AppName -Key "${AppName}-key" -ContextPath $AppName -Type HOSTED Create a new hosted application #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # data [Parameter()] [object] $Data, # Name of application (required) [Parameter(Mandatory = $true)] [string] $Name, # Shared secret of application (required) [Parameter(Mandatory = $true)] [string] $Key, # Type of application. Possible values are EXTERNAL, HOSTED, MICROSERVICE (required) [Parameter(Mandatory = $true)] [ValidateSet('EXTERNAL','HOSTED','MICROSERVICE')] [string] $Type, # Access level for other tenants. Possible values are : MARKET, PRIVATE (default) [Parameter()] [ValidateSet('MARKET','PRIVATE')] [string] $Availability, # contextPath of the hosted application. Required when application type is HOSTED [Parameter()] [string] $ContextPath, # URL to application base directory hosted on an external server. Required when application type is HOSTED [Parameter()] [string] $ResourcesUrl, # authorization username to access resourcesUrl [Parameter()] [string] $ResourcesUsername, # authorization password to access resourcesUrl [Parameter()] [string] $ResourcesPassword, # URL to the external application. Required when application type is EXTERNAL [Parameter()] [string] $ExternalUrl, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Key")) { $Parameters["key"] = $Key } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Availability")) { $Parameters["availability"] = $Availability } if ($PSBoundParameters.ContainsKey("ContextPath")) { $Parameters["contextPath"] = $ContextPath } if ($PSBoundParameters.ContainsKey("ResourcesUrl")) { $Parameters["resourcesUrl"] = $ResourcesUrl } if ($PSBoundParameters.ContainsKey("ResourcesUsername")) { $Parameters["resourcesUsername"] = $ResourcesUsername } if ($PSBoundParameters.ContainsKey("ResourcesPassword")) { $Parameters["resourcesPassword"] = $ResourcesPassword } if ($PSBoundParameters.ContainsKey("ExternalUrl")) { $Parameters["externalUrl"] = $ExternalUrl } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "applications" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-ApplicationBinary { <# .SYNOPSIS New application binary .DESCRIPTION For the applications of type microservice and web application to be available for Cumulocity platform users, a binary zip file must be uploaded. For the microservice application, the zip file must consist of * cumulocity.json - file describing the deployment * image.tar - executable docker image For the web application, the zip file must include index.html in the root directory. .EXAMPLE PS> New-ApplicationBinary -Id $App.id -File $MicroserviceZip Upload application microservice binary #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Application id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # File to be uploaded as a binary (required) [Parameter(Mandatory = $true)] [string] $File, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("File")) { $Parameters["file"] = $File } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Application $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "applications" ` -Verb "createBinary" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-AuditRecord { <# .SYNOPSIS Create a new audit record .DESCRIPTION Create a new audit record for a given action .EXAMPLE PS> New-AuditRecord -Type "ManagedObject" -Time "0s" -Text "Managed Object updated: my_Prop: value" -Source $Device.id -Activity "Managed Object updated" -Severity "information" Create an audit record for a custom managed object update #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Identifies the type of this audit record. (required) [Parameter(Mandatory = $true)] [string] $Type, # Time of the audit record. [Parameter()] [string] $Time, # Text description of the audit record. (required) [Parameter(Mandatory = $true)] [string] $Text, # An optional ManagedObject that the audit record originated from (required) [Parameter(Mandatory = $true)] [string] $Source, # The activity that was carried out. (required) [Parameter(Mandatory = $true)] [string] $Activity, # The severity of action: critical, major, minor, warning or information. (required) [Parameter(Mandatory = $true)] [ValidateSet('critical','major','minor','warning','information')] [string] $Severity, # The user responsible for the audited action. [Parameter()] [string] $User, # The application used to carry out the audited action. [Parameter()] [string] $Application, # Additional properties of the audit record. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Time")) { $Parameters["time"] = $Time } if ($PSBoundParameters.ContainsKey("Text")) { $Parameters["text"] = $Text } if ($PSBoundParameters.ContainsKey("Source")) { $Parameters["source"] = $Source } if ($PSBoundParameters.ContainsKey("Activity")) { $Parameters["activity"] = $Activity } if ($PSBoundParameters.ContainsKey("Severity")) { $Parameters["severity"] = $Severity } if ($PSBoundParameters.ContainsKey("User")) { $Parameters["user"] = $User } if ($PSBoundParameters.ContainsKey("Application")) { $Parameters["application"] = $Application } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "auditRecords" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.auditRecord+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-Binary { <# .SYNOPSIS New inventory binary .DESCRIPTION Upload a new binary to Cumulocity .EXAMPLE PS> New-Binary -File $File Upload a log file #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # File to be uploaded as a binary (required) [Parameter(Mandatory = $true)] [string] $File, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("File")) { $Parameters["file"] = $File } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "binaries" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-Device { <# .SYNOPSIS Create a device .DESCRIPTION Create a device (managed object) with the special c8y_IsDevice fragment. .EXAMPLE PS> New-Device -Name $DeviceName Create device .EXAMPLE PS> New-Device -Name $DeviceName -Data @{ myValue = @{ value1 = $true } } Create device with custom properties #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device name (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string[]] $Name, # Device type [Parameter()] [string] $Type, # Custom device properties. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Name)) { if ($item) { $Parameters["name"] = 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-ClientCommand ` -Noun "devices" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customDevice+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-DeviceGroup { <# .SYNOPSIS Create device group .DESCRIPTION Create a new device group to logically group one or more devices .EXAMPLE PS> New-DeviceGroup -Name $GroupName Create device group .EXAMPLE PS> New-DeviceGroup -Name $GroupName -Data @{ "myValue" = @{ value1 = $true } } Create device group with custom properties #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device group name (required) [Parameter(Mandatory = $true)] [string] $Name, # Device group type (c8y_DeviceGroup (root folder) or c8y_DeviceSubGroup (sub folder)). Defaults to c8y_DeviceGroup [Parameter()] [ValidateSet('c8y_DeviceGroup','c8y_DeviceSubGroup')] [string] $Type, # Custom group properties. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "devices" ` -Verb "createGroup" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customDeviceGroup+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-Event { <# .SYNOPSIS Create event .DESCRIPTION Create a new event for a device .EXAMPLE PS> New-Event -Device $device.id -Type c8y_TestAlarm -Text "Test event" Create a new event for a device .EXAMPLE PS> Get-Device -Id $device.id | PSc8y\New-Event -Type c8y_TestAlarm -Time "-0s" -Text "Test event" Create a new event for a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # The ManagedObject which is the source of this event. (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Time of the event. [Parameter()] [string] $Time, # Identifies the type of this event. (required) [Parameter(Mandatory = $true)] [string] $Type, # Text description of the event. (required) [Parameter(Mandatory = $true)] [string] $Text, # Additional properties of the event. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Time")) { $Parameters["time"] = $Time } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Text")) { $Parameters["text"] = $Text } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } 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-ClientCommand ` -Noun "events" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.event+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-EventBinary { <# .SYNOPSIS New event binary .DESCRIPTION Upload a new binary file to an event .EXAMPLE PS> New-EventBinary -Id $Event.id -File $TestFile Add a binary to an event #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Event id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # File to be uploaded as a binary (required) [Parameter(Mandatory = $true)] [string] $File, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("File")) { $Parameters["file"] = $File } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "events" ` -Verb "createBinary" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.event+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-ExternalId { <# .SYNOPSIS Create a new external id .DESCRIPTION Create a new external id .EXAMPLE PS> New-ExternalId -Device {{ randomdevice }} -Type "$my_SerialNumber" -Name "myserialnumber" Get external identity #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # The ManagedObject linked to the external ID. (required) [Parameter(Mandatory = $true)] [object[]] $Device, # The type of the external identifier as string, e.g. 'com_cumulocity_model_idtype_SerialNumber'. (required) [Parameter(Mandatory = $true)] [string] $Type, # The identifier used in the external system that Cumulocity interfaces with. (required) [Parameter(Mandatory = $true)] [string] $Name, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Device")) { $Parameters["device"] = $Device } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "identity" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.externalId+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-Group { <# .SYNOPSIS Create a new group .DESCRIPTION Create a new group .EXAMPLE PS> New-Group -Name "$GroupName" Create a user group #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Group name [Parameter()] [string] $Name, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "userGroups" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.group+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-ManagedObject { <# .SYNOPSIS Create a new inventory .DESCRIPTION Create a new inventory managed object .EXAMPLE PS> New-ManagedObject -Name "testMO" -Type $type -Data @{ custom_data = @{ value = 1 } } Create a managed object #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # name [Parameter()] [string] $Name, # type [Parameter()] [string] $Type, # Additional properties of the inventory. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "inventory" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.inventory+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-Measurement { <# .SYNOPSIS Create a new measurement .DESCRIPTION Create a new measurement .EXAMPLE PS> New-Measurement -Device {{ randomdevice }} -Time "0s" -Type "myType" -Data @{ c8y_Winding = @{ temperature = @{ value = 1.2345; unit = "°C" } } } Create measurement #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # The ManagedObject which is the source of this measurement. (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Time of the measurement. (required) [Parameter(Mandatory = $true)] [string] $Time, # The most specific type of this entire measurement. (required) [Parameter(Mandatory = $true)] [string] $Type, # List of measurement fragments. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Time")) { $Parameters["time"] = $Time } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } 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-ClientCommand ` -Noun "measurements" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.measurement+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-MicroserviceBinary { <# .SYNOPSIS Create/upload a new microservice binary .DESCRIPTION For the applications of type 'MICROSERVICE' to be available for Cumulocity platform users, a binary zip file must be uploaded. For the microservice application, the zip file must consist of * cumulocity.json - file describing the deployment * image.tar - executable docker image For the web application, the zip file must include index.html in the root directory. .EXAMPLE PS> New-MicroserviceBinary -Id $App.id -File $MicroserviceZip Upload microservice binary #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Microservice id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # File to be uploaded as a binary (required) [Parameter(Mandatory = $true)] [string] $File, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("File")) { $Parameters["file"] = $File } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Microservice $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "microservices" ` -Verb "createBinary" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-Operation { <# .SYNOPSIS Create a new operation .DESCRIPTION Create a new operation for an agent or device .EXAMPLE PS> New-Operation -Device $device.id -Description "Restart device" -Data @{ c8y_Restart = @{} } Create operation for a device .EXAMPLE PS> Get-Device $device.id | New-Operation -Description "Restart device" -Data @{ c8y_Restart = @{} } Create operation for a device (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Identifies the target device on which this operation should be performed. (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Text description of the operation. [Parameter()] [string] $Description, # Additional properties describing the operation which will be performed on the device. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Description")) { $Parameters["description"] = $Description } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } 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-ClientCommand ` -Noun "operations" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.operation+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-RetentionRule { <# .SYNOPSIS New retention rule .DESCRIPTION Create a new retention rule to managed when data is deleted in the tenant .EXAMPLE PS> New-RetentionRule -DataType ALARM -MaximumAge 180 Create a retention rule to delete all alarms after 180 days #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # RetentionRule will be applied to this type of documents, possible values [ALARM, AUDIT, EVENT, MEASUREMENT, OPERATION, *]. (required) [Parameter(Mandatory = $true)] [ValidateSet('ALARM','AUDIT','EVENT','MEASUREMENT','OPERATION','*')] [string] $DataType, # RetentionRule will be applied to documents with fragmentType. [Parameter()] [string] $FragmentType, # RetentionRule will be applied to documents with type. [Parameter()] [string] $Type, # RetentionRule will be applied to documents with source. [Parameter()] [string] $Source, # Maximum age of document in days. (required) [Parameter(Mandatory = $true)] [long] $MaximumAge, # Whether the rule is editable. Can be updated only by management tenant. [Parameter()] [switch] $Editable, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DataType")) { $Parameters["dataType"] = $DataType } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Source")) { $Parameters["source"] = $Source } if ($PSBoundParameters.ContainsKey("MaximumAge")) { $Parameters["maximumAge"] = $MaximumAge } if ($PSBoundParameters.ContainsKey("Editable")) { $Parameters["editable"] = $Editable } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "retentionRules" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.retentionRule+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-Tenant { <# .SYNOPSIS New tenant .DESCRIPTION New tenant .EXAMPLE PS> New-Tenant -Company "mycompany" -Domain "mycompany" -AdminName "admin" -Password "mys3curep9d8" Create a new tenant (from the management tenant) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Company name. Maximum 256 characters (required) [Parameter(Mandatory = $true)] [string] $Company, # Domain name to be used for the tenant. Maximum 256 characters (required) [Parameter(Mandatory = $true)] [string] $Domain, # Username of the tenant administrator [Parameter()] [string] $AdminName, # Password of the tenant administrator [Parameter()] [string] $AdminPass, # A contact name, for example an administrator, of the tenant [Parameter()] [string] $ContactName, # An international contact phone number [Parameter()] [string] $ContactPhone, # The tenant ID. This should be left bank unless you know what you are doing. Will be auto-generated if not present. [Parameter()] [string] $TenantId, # A set of custom properties of the tenant [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Company")) { $Parameters["company"] = $Company } if ($PSBoundParameters.ContainsKey("Domain")) { $Parameters["domain"] = $Domain } if ($PSBoundParameters.ContainsKey("AdminName")) { $Parameters["adminName"] = $AdminName } if ($PSBoundParameters.ContainsKey("AdminPass")) { $Parameters["adminPass"] = $AdminPass } if ($PSBoundParameters.ContainsKey("ContactName")) { $Parameters["contactName"] = $ContactName } if ($PSBoundParameters.ContainsKey("ContactPhone")) { $Parameters["contactPhone"] = $ContactPhone } if ($PSBoundParameters.ContainsKey("TenantId")) { $Parameters["tenantId"] = $TenantId } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "tenants" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.tenant+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-TenantOption { <# .SYNOPSIS New tenant option .DESCRIPTION New tenant option .EXAMPLE PS> New-TenantOption -Category "c8y_cli_tests" -Key "$option1" -Value "1" Create a tenant option #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Category of option (required) [Parameter(Mandatory = $true)] [string] $Category, # Key of option (required) [Parameter(Mandatory = $true)] [string] $Key, # Value of option (required) [Parameter(Mandatory = $true)] [string] $Value, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Category")) { $Parameters["category"] = $Category } if ($PSBoundParameters.ContainsKey("Key")) { $Parameters["key"] = $Key } if ($PSBoundParameters.ContainsKey("Value")) { $Parameters["value"] = $Value } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "tenantOptions" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.option+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function New-User { <# .SYNOPSIS Create a new user within the collection .DESCRIPTION This command can be used to grant a new user to the tenant .EXAMPLE PS> New-user -Username "$Username" -Password "$NewPassword" Create a user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # User name, unique for a given domain. Max: 1000 characters (required) [Parameter(Mandatory = $true)] [string] $UserName, # User first name [Parameter()] [string] $FirstName, # User last name [Parameter()] [string] $LastName, # User phone number. Format: '+[country code][number]', has to be a valid MSISDN [Parameter()] [string] $Phone, # User email address [Parameter()] [string] $Email, # User activation status (true/false) [Parameter()] [switch] $Enabled, # User password. Min: 6, max: 32 characters. Only Latin1 chars allowed [Parameter()] [string] $Password, # User activation status (true/false) [Parameter()] [ValidateSet('true','false')] [switch] $SendPasswordResetEmail, # Custom properties to be added to the user [Parameter()] [object] $CustomProperties, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("UserName")) { $Parameters["userName"] = $UserName } if ($PSBoundParameters.ContainsKey("FirstName")) { $Parameters["firstName"] = $FirstName } if ($PSBoundParameters.ContainsKey("LastName")) { $Parameters["lastName"] = $LastName } if ($PSBoundParameters.ContainsKey("Phone")) { $Parameters["phone"] = $Phone } if ($PSBoundParameters.ContainsKey("Email")) { $Parameters["email"] = $Email } if ($PSBoundParameters.ContainsKey("Enabled")) { $Parameters["enabled"] = $Enabled } if ($PSBoundParameters.ContainsKey("Password")) { $Parameters["password"] = $Password } if ($PSBoundParameters.ContainsKey("SendPasswordResetEmail")) { $Parameters["sendPasswordResetEmail"] = $SendPasswordResetEmail } if ($PSBoundParameters.ContainsKey("CustomProperties")) { $Parameters["customProperties"] = ConvertTo-JsonArgument $CustomProperties } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "users" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.user+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Register-Device { <# .SYNOPSIS Register a new device (request) .DESCRIPTION Register a new device (request) .EXAMPLE PS> Register-Device -Id "ASDF098SD1J10912UD92JDLCNCU8" Register a new device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device identifier. Max: 1000 characters. E.g. IMEI (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Id")) { $Parameters["id"] = $Id } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "deviceCredentials" ` -Verb "registerNewDevice" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.newDeviceRequest+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-Agent { <# .SYNOPSIS Delete agent .DESCRIPTION Delete an agent from the platform. This will delete all data associated to the agent (i.e. alarms, events, operations and measurements) .EXAMPLE PS> Remove-Agent -Id $agent.id Remove agent by id .EXAMPLE PS> Remove-Agent -Id $agent.name Remove agent by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Agent ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "agents" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-AlarmCollection { <# .SYNOPSIS Delete a collection of alarms .DESCRIPTION Delete a collection of alarms by a given filter .EXAMPLE PS> Remove-AlarmCollection -Device "{{ randomdevice }}" -Severity MAJOR Remove alarms on the device with the severity set to MAJOR .EXAMPLE PS> Remove-AlarmCollection -Device $device.id -DateFrom "-10m" -Status ACTIVE Remove alarms on the device which are active and created in the last 10 minutes .EXAMPLE PS> Get-Device -Id $device.id | PSc8y\Remove-AlarmCollection -DateFrom "-10m" -Status ACTIVE Remove alarms on the device which are active and created in the last 10 minutes (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Source device id. [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Start date or date and time of alarm occurrence. [Parameter()] [string] $DateFrom, # End date or date and time of alarm occurrence. [Parameter()] [string] $DateTo, # Alarm type. [Parameter()] [string] $Type, # Alarm fragment type. [Parameter()] [string] $FragmentType, # Comma separated alarm statuses, for example ACTIVE,CLEARED. [Parameter()] [ValidateSet('ACTIVE','ACKNOWLEDGED','CLEARED')] [string] $Status, # Alarm severity, for example CRITICAL, MAJOR, MINOR or WARNING. [Parameter()] [ValidateSet('CRITICAL','MAJOR','MINOR','WARNING')] [string] $Severity, # When set to true only resolved alarms will be removed (the one with status CLEARED), false means alarms with status ACTIVE or ACKNOWLEDGED. [Parameter()] [switch] $Resolved, # When set to true also alarms for related source assets will be removed. When this parameter is provided also source must be defined. [Parameter()] [switch] $WithSourceAssets, # When set to true also alarms for related source devices will be removed. When this parameter is provided also source must be defined. [Parameter()] [switch] $WithSourceDevices, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("Status")) { $Parameters["status"] = $Status } if ($PSBoundParameters.ContainsKey("Severity")) { $Parameters["severity"] = $Severity } if ($PSBoundParameters.ContainsKey("Resolved")) { $Parameters["resolved"] = $Resolved } if ($PSBoundParameters.ContainsKey("WithSourceAssets")) { $Parameters["withSourceAssets"] = $WithSourceAssets } if ($PSBoundParameters.ContainsKey("WithSourceDevices")) { $Parameters["withSourceDevices"] = $WithSourceDevices } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["device"] = PSc8y\Expand-Id $Device if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "alarms" ` -Verb "deleteCollection" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-Application { <# .SYNOPSIS Delete application .DESCRIPTION The application can only be removed when its availability is PRIVATE or in other case when it has no subscriptions. .EXAMPLE PS> Remove-Application -Id $App.id Delete an application by id .EXAMPLE PS> Remove-Application -Id $App.name Delete an application by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Application id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Application $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "applications" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-AssetFromGroup { <# .SYNOPSIS Delete child asset reference .DESCRIPTION Unassign an asset (device or group) from a group .EXAMPLE PS> Remove-AssetFromGroup -Group $Group.id -ChildDevice $ChildDevice.id Unassign a child device from its parent asset #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Asset id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Group, # Child device [Parameter()] [object[]] $ChildDevice, # Child device group [Parameter()] [object[]] $ChildGroup, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("ChildDevice")) { $Parameters["childDevice"] = $ChildDevice } if ($PSBoundParameters.ContainsKey("ChildGroup")) { $Parameters["childGroup"] = $ChildGroup } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Group)) { if ($item) { $Parameters["group"] = 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-ClientCommand ` -Noun "inventoryReferences" ` -Verb "unassignAssetFromGroup" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-Binary { <# .SYNOPSIS Delete binary .DESCRIPTION Delete a binary from the tenant. This delete operation can not be undone. .EXAMPLE PS> Remove-Binary -Id $Binary.id Delete a binary #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Inventory binary id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "binaries" ` -Verb "deleteBinary" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-ChildDeviceFromDevice { <# .SYNOPSIS Delete child device reference .DESCRIPTION Delete child device reference .EXAMPLE PS> Remove-ChildDeviceFromDevice -Device $Device.id -ChildDevice $ChildDevice.id Unassign a child device from its parent device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # ManagedObject id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Child device reference (required) [Parameter(Mandatory = $true)] [object[]] $ChildDevice, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("ChildDevice")) { $Parameters["childDevice"] = $ChildDevice } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } 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-ClientCommand ` -Noun "inventoryReferences" ` -Verb "unassignChildDevice" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-Device { <# .SYNOPSIS Delete device .DESCRIPTION Delete an existing device by id or name. Deleting the object will remove all of its data (i.e. alarms, events, operations and measurements) .EXAMPLE PS> Remove-Device -Id $device.id Remove device by id .EXAMPLE PS> Remove-Device -Id $device.name Remove device by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Remove all child devices and child assets will be deleted recursively. By default, the delete operation is propagated to the subgroups only if the deleted object is a group [Parameter()] [switch] $Cascade, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Cascade")) { $Parameters["cascade"] = $Cascade } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "devices" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-DeviceFromGroup { <# .SYNOPSIS Delete child asset reference .DESCRIPTION Unassign a device from a group .EXAMPLE PS> Remove-DeviceFromGroup -Group $Group.id -ChildDevice $ChildDevice.id Unassign a child device from its parent asset #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Asset id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Group, # Child device (required) [Parameter(Mandatory = $true)] [object[]] $ChildDevice, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("ChildDevice")) { $Parameters["childDevice"] = $ChildDevice } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Group)) { if ($item) { $Parameters["group"] = 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-ClientCommand ` -Noun "inventoryReferences" ` -Verb "unassignDeviceFromGroup" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-DeviceGroup { <# .SYNOPSIS Delete device group .DESCRIPTION Delete an existing device group, and optional .EXAMPLE PS> Remove-DeviceGroup -Id $group.id Remove device group by id .EXAMPLE PS> Remove-DeviceGroup -Id $group.name Remove device group by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device group ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Remove all child devices and child assets will be deleted recursively. By default, the delete operation is propagated to the subgroups only if the deleted object is a group [Parameter()] [switch] $Cascade, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Cascade")) { $Parameters["cascade"] = $Cascade } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "devices" ` -Verb "deleteGroup" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-DeviceRequest { <# .SYNOPSIS Delete a new device requests .DESCRIPTION Delete a new device requests .EXAMPLE PS> Remove-DeviceRequest -Id "91019192078" Delete a new device request #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # New Device Request ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "deviceCredentials" ` -Verb "deleteNewDeviceRequest" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-Event { <# .SYNOPSIS Delete event/s .DESCRIPTION Delete an event by id .EXAMPLE PS> Remove-Event -Id {{ NewEvent }} Delete an event #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Event id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "events" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-EventBinary { <# .SYNOPSIS Delete event binary .DESCRIPTION Delete a binary which has been attached to an event .EXAMPLE PS> Remove-EventBinary -Id $Event.id Delete an binary attached to an event #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Event id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "events" ` -Verb "deleteBinary" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-EventCollection { <# .SYNOPSIS Delete a collection of events .DESCRIPTION Delete a collection of events by using a filter .EXAMPLE PS> Remove-EventCollection -Type my_CustomType -DateFrom "-10d" Remove events with type 'my_CustomType' that were created in the last 10 days .EXAMPLE PS> Remove-EventCollection -Device "{{ randomdevice }}" Remove events from a device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter()] [object[]] $Device, # Event type. [Parameter()] [string] $Type, # Fragment name from event. [Parameter()] [string] $FragmentType, # Start date or date and time of event occurrence. [Parameter()] [string] $DateFrom, # End date or date and time of event occurrence. [Parameter()] [string] $DateTo, # Return the newest instead of the oldest events. Must be used with dateFrom and dateTo parameters [Parameter()] [switch] $Revert, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Device")) { $Parameters["device"] = $Device } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("Revert")) { $Parameters["revert"] = $Revert } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "events" ` -Verb "deleteCollection" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-ExternalId { <# .SYNOPSIS Delete external id .DESCRIPTION Delete an existing external id. This does not delete the device managed object .EXAMPLE PS> Remove-ExternalId -Type "my_SerialNumber" -Name "myserialnumber2" Delete external identity #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # External identity type (required) [Parameter(Mandatory = $true)] [string] $Type, # External identity id/name (required) [Parameter(Mandatory = $true)] [string] $Name, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "identity" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-Group { <# .SYNOPSIS Delete a new group .DESCRIPTION Delete a new group .EXAMPLE PS> Remove-Group -Id $Group.id Delete a user group .EXAMPLE PS> Get-GroupByName -Name $Group.name | Remove-Group Delete a user group (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Group id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "userGroups" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-ManagedObject { <# .SYNOPSIS Delete inventory/s .DESCRIPTION Delete a managed object by id .EXAMPLE PS> Remove-ManagedObject -Id $mo.id Delete a managed object .EXAMPLE PS> Get-ManagedObject -Id $mo.id | Remove-ManagedObject Delete a managed object (using pipeline) .EXAMPLE PS> Get-ManagedObject -Id $Device.id | Remove-ManagedObject -Cascade Delete a managed object and all child devices #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # ManagedObject id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Remove all child devices and child assets will be deleted recursively. By default, the delete operation is propagated to the subgroups only if the deleted object is a group [Parameter()] [switch] $Cascade, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Cascade")) { $Parameters["cascade"] = $Cascade } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "inventory" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-Measurement { <# .SYNOPSIS Delete measurement/s .DESCRIPTION Delete individual measurements .EXAMPLE PS> Remove-Measurement -id $Measurement.id Delete measurement #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Measurement id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "measurements" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-MeasurementCollection { <# .SYNOPSIS Delete a collection of measurements .DESCRIPTION Delete measurements using a filter .EXAMPLE PS> Remove-MeasurementCollection -Device $Measurement.source.id Delete measurement collection for a device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Measurement type. [Parameter()] [string] $Type, # Fragment name from measurement (deprecated). [Parameter()] [string] $FragmentType, # Start date or date and time of measurement occurrence. [Parameter()] [string] $DateFrom, # End date or date and time of measurement occurrence. [Parameter()] [string] $DateTo, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["device"] = PSc8y\Expand-Id $Device if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "measurements" ` -Verb "deleteCollection" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-Microservice { <# .SYNOPSIS Delete microservice .DESCRIPTION Info: The application can only be removed when its availability is PRIVATE or in other case when it has no subscriptions. .EXAMPLE PS> Remove-Microservice -Id $App.id Delete a microservice by id .EXAMPLE PS> Remove-Microservice -Id $App.name Delete a microservice by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Microservice id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Microservice $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "microservices" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-OperationCollection { <# .SYNOPSIS Delete a collection of operations .DESCRIPTION Delete a collection of operations using a set of filter criteria. Be careful when deleting operations. Where possible update operations to FAILED (with a failure reason) instead of deleting them as it is easier to track. .EXAMPLE PS> Remove-OperationCollection -Device "{{ randomdevice }}" -Status PENDING Remove all pending operations for a given device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Agent ID [Parameter()] [object[]] $Agent, # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Start date or date and time of operation. [Parameter()] [string] $DateFrom, # End date or date and time of operation. [Parameter()] [string] $DateTo, # Operation status, can be one of SUCCESSFUL, FAILED, EXECUTING or PENDING. [Parameter()] [ValidateSet('PENDING','EXECUTING','SUCCESSFUL','FAILED')] [string] $Status, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Agent")) { $Parameters["agent"] = $Agent } if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("Status")) { $Parameters["status"] = $Status } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["device"] = PSc8y\Expand-Id $Device if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "operations" ` -Verb "deleteCollection" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-RetentionRule { <# .SYNOPSIS Delete retention rule .DESCRIPTION Delete an existing retention rule .EXAMPLE PS> Remove-RetentionRule -Id $RetentionRule.id Delete a retention rule .EXAMPLE PS> Get-RetentionRule -Id $RetentionRule.id | Remove-RetentionRule Delete a retention rule (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Retention rule id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "retentionRules" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-RoleFromGroup { <# .SYNOPSIS Unassign/Remove role from a group .DESCRIPTION Unassign/Remove role from a group .EXAMPLE PS> Remove-RoleFromGroup -Group $UserGroup.id -Role "ROLE_MEASUREMENT_READ" Remove a role from the given user group #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Group id (required) [Parameter(Mandatory = $true)] [object[]] $Group, # Role name, e.g. ROLE_TENANT_MANAGEMENT_ADMIN (required) [Parameter(Mandatory = $true)] [object[]] $Role, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Group")) { $Parameters["group"] = PSc8y\Expand-Id $Group } if ($PSBoundParameters.ContainsKey("Role")) { $Parameters["role"] = $Role } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "userRoles" ` -Verb "deleteRoleFromGroup" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-RoleFromUser { <# .SYNOPSIS Unassign/Remove role from a user .DESCRIPTION Unassign/Remove role from a user .EXAMPLE PS> Remove-RoleFromUser -User $User.id -Role "ROLE_MEASUREMENT_READ" Remove a role from the given user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # User (required) [Parameter(Mandatory = $true)] [object[]] $User, # Role name (required) [Parameter(Mandatory = $true)] [object[]] $Role, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("User")) { $Parameters["user"] = $User } if ($PSBoundParameters.ContainsKey("Role")) { $Parameters["role"] = $Role } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "userRoles" ` -Verb "deleteRoleFromUser" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-Tenant { <# .SYNOPSIS Delete tenant .DESCRIPTION Delete tenant .EXAMPLE PS> Remove-Tenant -Id mycompany Delete a tenant by name (from the mangement tenant) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant id [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["id"] = PSc8y\Expand-Id $Id if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "tenants" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-TenantOption { <# .SYNOPSIS Delete tenant option .DESCRIPTION Delete tenant option .EXAMPLE PS> Remove-TenantOption -Category "c8y_cli_tests" -Key "$option3" Delete a tenant option #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant Option category (required) [Parameter(Mandatory = $true)] [string] $Category, # Tenant Option key (required) [Parameter(Mandatory = $true)] [string] $Key, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Category")) { $Parameters["category"] = $Category } if ($PSBoundParameters.ContainsKey("Key")) { $Parameters["key"] = $Key } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "tenantOptions" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-User { <# .SYNOPSIS Delete user .DESCRIPTION Delete a user from the a tenant. This will remove the user completely from the tenant and can not be reversed. Alternatively a user can be disabled via updating the users properties instead of deleting the user. .EXAMPLE PS> Remove-User -Id $User.id Delete a user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # User id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "users" ` -Verb "delete" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-UserFromGroup { <# .SYNOPSIS Delete a user from a group .DESCRIPTION Delete a user from a group .EXAMPLE PS> Remove-UserFromGroup -Group $Group.id -User $User.id Add a user to a user group #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Group ID (required) [Parameter(Mandatory = $true)] [object[]] $Group, # User id/username (required) [Parameter(Mandatory = $true)] [object[]] $User, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Group")) { $Parameters["group"] = PSc8y\Expand-Id $Group } if ($PSBoundParameters.ContainsKey("User")) { $Parameters["user"] = $User } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "userReferences" ` -Verb "deleteUserFromGroup" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Request-DeviceCredentials { <# .SYNOPSIS Request credentials for a new device .DESCRIPTION Device credentials can be enquired by devices that do not have credentials for accessing a tenant yet. Since the device does not have credentials yet, a set of fixed credentials is used for this API. The credentials can be obtained by contacting support. Do not use your tenant credentials with this API. .EXAMPLE PS> Request-DeviceCredentials -Id "device-AD76-matrixer" Request credentials for a new device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device identifier. Max: 1000 characters. E.g. IMEI (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Id")) { $Parameters["id"] = $Id } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "deviceCredentials" ` -Verb "requestDeviceCredentials" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.deviceCredentials+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Reset-UserPassword { <# .SYNOPSIS Reset a user's password .DESCRIPTION The password can be reset either by issuing a password reset email (default), or be specifying a new password. .EXAMPLE PS> Reset-UserPassword -Id $User.id -WhatIf 2>&1 Resets a user's password by sending a reset email to the user .EXAMPLE PS> Reset-UserPassword -Id $User.id -NewPassword (New-RandomPassword) Resets a user's password by generating a new password #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # User id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # New user password. Min: 6, max: 32 characters. Only Latin1 chars allowed [Parameter()] [string] $NewPassword, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("NewPassword")) { $Parameters["newPassword"] = $NewPassword } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-User $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "users" ` -Verb "resetUserPassword" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.user+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # 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, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # 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 } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } 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-ClientCommand ` -Noun "devices" ` -Verb "setRequiredAvailability" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.inventory+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-Agent { <# .SYNOPSIS Update agent .DESCRIPTION Update properties of an agent .EXAMPLE PS> Update-Agent -Id $agent.id -NewName "MyNewName" Update agent by id .EXAMPLE PS> Update-Agent -Id $agent.name -NewName "MyNewName" Update agent by name .EXAMPLE PS> Update-Agent -Id $agent.name -Data @{ "myValue" = @{ value1 = $true } } Update agent custom properties #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Agent ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Agent name [Parameter()] [string] $NewName, # Additional properties of the inventory. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("NewName")) { $Parameters["newName"] = $NewName } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "agents" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customAgent+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-Alarm { <# .SYNOPSIS Update an alarm .DESCRIPTION Update an alarm by its id .EXAMPLE PS> Update-Alarm -Id $Alarm.id -Status ACKNOWLEDGED Acknowledge an existing alarm .EXAMPLE PS> Get-Alarm -Id $Alarm.id | PSc8y\Update-Alarm -Status ACKNOWLEDGED Acknowledge an existing alarm (using pipeline) .EXAMPLE PS> Update-Alarm -Id $Alarm.id -Severity CRITICAL Update severity of an existing alarm to CRITICAL #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Alarm id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Comma separated alarm statuses, for example ACTIVE,CLEARED. [Parameter()] [ValidateSet('ACTIVE','ACKNOWLEDGED','CLEARED')] [string] $Status, # Alarm severity, for example CRITICAL, MAJOR, MINOR or WARNING. [Parameter()] [ValidateSet('CRITICAL','MAJOR','MINOR','WARNING')] [string] $Severity, # Text description of the alarm. [Parameter()] [string] $Text, # Additional properties of the alarm. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Status")) { $Parameters["status"] = $Status } if ($PSBoundParameters.ContainsKey("Severity")) { $Parameters["severity"] = $Severity } if ($PSBoundParameters.ContainsKey("Text")) { $Parameters["text"] = $Text } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "alarms" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.alarm+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-AlarmCollection { <# .SYNOPSIS Update a collection of alarms. Currently only the status of alarms can be changed .DESCRIPTION Update the status of a collection of alarms by using a filter .EXAMPLE PS> Update-AlarmCollection -Device $Device.id -Status ACTIVE -NewStatus ACKNOWLEDGED Update the status of all active alarms on a device to ACKNOWLEDGED .EXAMPLE PS> Get-Device -Id $Device.id | PSc8y\Update-AlarmCollection -Status ACTIVE -NewStatus ACKNOWLEDGED Update the status of all active alarms on a device to ACKNOWLEDGED (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # The ManagedObject that the alarm originated from [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # The status of the alarm: ACTIVE, ACKNOWLEDGED or CLEARED. If status was not appeared, new alarm will have status ACTIVE. Must be upper-case. [Parameter()] [ValidateSet('ACTIVE','ACKNOWLEDGED','CLEARED')] [string] $Status, # The severity of the alarm: CRITICAL, MAJOR, MINOR or WARNING. Must be upper-case. [Parameter()] [ValidateSet('CRITICAL','MAJOR','MINOR','WARNING')] [string] $Severity, # When set to true only resolved alarms will be removed (the one with status CLEARED), false means alarms with status ACTIVE or ACKNOWLEDGED. [Parameter()] [switch] $Resolved, # Start date or date and time of alarm occurrence. [Parameter()] [string] $DateFrom, # End date or date and time of alarm occurrence. [Parameter()] [string] $DateTo, # New status to be applied to all of the matching alarms (required) [Parameter(Mandatory = $true)] [ValidateSet('ACTIVE','ACKNOWLEDGED','CLEARED')] [string] $NewStatus, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Status")) { $Parameters["status"] = $Status } if ($PSBoundParameters.ContainsKey("Severity")) { $Parameters["severity"] = $Severity } if ($PSBoundParameters.ContainsKey("Resolved")) { $Parameters["resolved"] = $Resolved } if ($PSBoundParameters.ContainsKey("DateFrom")) { $Parameters["dateFrom"] = $DateFrom } if ($PSBoundParameters.ContainsKey("DateTo")) { $Parameters["dateTo"] = $DateTo } if ($PSBoundParameters.ContainsKey("NewStatus")) { $Parameters["newStatus"] = $NewStatus } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["device"] = PSc8y\Expand-Id $Device if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "alarms" ` -Verb "updateCollection" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "alarms" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-Application { <# .SYNOPSIS Update application meta information .DESCRIPTION Update an application by its id .EXAMPLE PS> Update-Application -Id $App.name -Availability "MARKET" Update application availability to MARKET #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Application id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # data [Parameter()] [object] $Data, # Name of application [Parameter()] [string] $Name, # Shared secret of application [Parameter()] [string] $Key, # Access level for other tenants. Possible values are : MARKET, PRIVATE (default) [Parameter()] [ValidateSet('MARKET','PRIVATE')] [string] $Availability, # contextPath of the hosted application [Parameter()] [string] $ContextPath, # URL to application base directory hosted on an external server [Parameter()] [string] $ResourcesUrl, # authorization username to access resourcesUrl [Parameter()] [string] $ResourcesUsername, # authorization password to access resourcesUrl [Parameter()] [string] $ResourcesPassword, # URL to the external application [Parameter()] [string] $ExternalUrl, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Key")) { $Parameters["key"] = $Key } if ($PSBoundParameters.ContainsKey("Availability")) { $Parameters["availability"] = $Availability } if ($PSBoundParameters.ContainsKey("ContextPath")) { $Parameters["contextPath"] = $ContextPath } if ($PSBoundParameters.ContainsKey("ResourcesUrl")) { $Parameters["resourcesUrl"] = $ResourcesUrl } if ($PSBoundParameters.ContainsKey("ResourcesUsername")) { $Parameters["resourcesUsername"] = $ResourcesUsername } if ($PSBoundParameters.ContainsKey("ResourcesPassword")) { $Parameters["resourcesPassword"] = $ResourcesPassword } if ($PSBoundParameters.ContainsKey("ExternalUrl")) { $Parameters["externalUrl"] = $ExternalUrl } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Application $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "applications" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-Binary { <# .SYNOPSIS Update inventory binary .DESCRIPTION Update an existing binary .EXAMPLE PS> Update-Binary -Id $Binary1.id -File $File2 Update an existing binary file #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Inventory binary id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # File to be uploaded as a binary (required) [Parameter(Mandatory = $true)] [string] $File, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("File")) { $Parameters["file"] = $File } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "binaries" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-CurrentApplication { <# .SYNOPSIS Update current application .DESCRIPTION Required authentication with bootstrap user .EXAMPLE PS> Update-CurrentApplication -Data @{ mycustomProp = @{ value1 = 1}} Update custom properties of the current application (requires using application credentials) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # data [Parameter()] [object] $Data, # Name of application [Parameter()] [string] $Name, # Shared secret of application [Parameter()] [string] $Key, # Application will be applied to this type of documents, possible values [ALARM, AUDIT, EVENT, MEASUREMENT, OPERATION, *]. [Parameter()] [ValidateSet('MARKET','PRIVATE')] [string] $Availability, # contextPath of the hosted application [Parameter()] [string] $ContextPath, # URL to application base directory hosted on an external server [Parameter()] [string] $ResourcesUrl, # authorization username to access resourcesUrl [Parameter()] [string] $ResourcesUsername, # authorization password to access resourcesUrl [Parameter()] [string] $ResourcesPassword, # URL to the external application [Parameter()] [string] $ExternalUrl, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Key")) { $Parameters["key"] = $Key } if ($PSBoundParameters.ContainsKey("Availability")) { $Parameters["availability"] = $Availability } if ($PSBoundParameters.ContainsKey("ContextPath")) { $Parameters["contextPath"] = $ContextPath } if ($PSBoundParameters.ContainsKey("ResourcesUrl")) { $Parameters["resourcesUrl"] = $ResourcesUrl } if ($PSBoundParameters.ContainsKey("ResourcesUsername")) { $Parameters["resourcesUsername"] = $ResourcesUsername } if ($PSBoundParameters.ContainsKey("ResourcesPassword")) { $Parameters["resourcesPassword"] = $ResourcesPassword } if ($PSBoundParameters.ContainsKey("ExternalUrl")) { $Parameters["externalUrl"] = $ExternalUrl } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "currentApplication" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-CurrentUser { <# .SYNOPSIS Update the current user .DESCRIPTION Update properties or settings of your user such as first/last name, email or password .EXAMPLE PS> Update-CurrentUser -LastName "Smith" Update the current user's lastname #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # User first name [Parameter()] [string] $FirstName, # User last name [Parameter()] [string] $LastName, # User phone number. Format: '+[country code][number]', has to be a valid MSISDN [Parameter()] [string] $Phone, # User email address [Parameter()] [string] $Email, # User activation status (true/false) [Parameter()] [ValidateSet('true','false')] [string] $Enabled, # User password. Min: 6, max: 32 characters. Only Latin1 chars allowed [Parameter()] [string] $Password, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("FirstName")) { $Parameters["firstName"] = $FirstName } if ($PSBoundParameters.ContainsKey("LastName")) { $Parameters["lastName"] = $LastName } if ($PSBoundParameters.ContainsKey("Phone")) { $Parameters["phone"] = $Phone } if ($PSBoundParameters.ContainsKey("Email")) { $Parameters["email"] = $Email } if ($PSBoundParameters.ContainsKey("Enabled")) { $Parameters["enabled"] = $Enabled } if ($PSBoundParameters.ContainsKey("Password")) { $Parameters["password"] = $Password } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "users" ` -Verb "updateCurrentUser" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.currentUser+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-DataBrokerConnector { <# .SYNOPSIS Update data broker connector .DESCRIPTION Update data broker connector .EXAMPLE PS> Update-DataBroker -Id 12345 -Status SUSPENDED Change the status of a specific data broker connector by given connector id #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Data broker connector id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # DataBroker status [SUSPENDED]. (required) [Parameter(Mandatory = $true)] [ValidateSet('SUSPENDED')] [string] $Status, # Data [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Status")) { $Parameters["status"] = $Status } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "databroker" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.databrokerConnector+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-Device { <# .SYNOPSIS Update device .DESCRIPTION Update properties of an existing device .EXAMPLE PS> Update-Device -Id $device.id -NewName "MyNewName" Update device by id .EXAMPLE PS> Update-Device -Id $device.name -NewName "MyNewName" Update device by name .EXAMPLE PS> Update-Device -Id $device.name -Data @{ "myValue" = @{ value1 = $true } } Update device custom properties #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Device name [Parameter()] [string] $NewName, # Additional properties of the inventory. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("NewName")) { $Parameters["newName"] = $NewName } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Device $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "devices" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customDevice+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-DeviceGroup { <# .SYNOPSIS Update device group .DESCRIPTION Update properties of an existing device group, for example name or any other custom properties. .EXAMPLE PS> Update-DeviceGroup -Id $group.id -Name "MyNewName" Update device group by id .EXAMPLE PS> Update-DeviceGroup -Id $group.name -Name "MyNewName" Update device group by name .EXAMPLE PS> Update-DeviceGroup -Id $group.name -Data @{ "myValue" = @{ value1 = $true } } Update device group custom properties #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Device group ID (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # Device group name [Parameter()] [string] $Name, # Additional properties of the inventory. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "devices" ` -Verb "updateGroup" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customDeviceGroup+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-Event { <# .SYNOPSIS Update an event .DESCRIPTION Update an event .EXAMPLE PS> Update-Event -Id $Event.id -Text "example text 1" Update the text field of an existing event .EXAMPLE PS> Update-Event -Id $Event.id -Data @{ my_event = @{ active = $true } } Update custom properties of an existing event .EXAMPLE PS> Get-Event -Id $Event.id | Update-Event -Data @{ my_event = @{ active = $true } } Update custom properties of an existing event (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Event id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Text description of the event. [Parameter()] [string] $Text, # Additional properties of the event. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Text")) { $Parameters["text"] = $Text } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "events" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.event+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-EventBinary { <# .SYNOPSIS Update event binary .DESCRIPTION Update an existing event binary .EXAMPLE PS> Update-EventBinary -Id $Event.id -File $TestFile Update a binary related to an event #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Event id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # File to be uploaded as a binary (required) [Parameter(Mandatory = $true)] [string] $File, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("File")) { $Parameters["file"] = $File } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "events" ` -Verb "updateBinary" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.event+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-Group { <# .SYNOPSIS Update a new group .DESCRIPTION Update a new group .EXAMPLE PS> Update-Group -Id $Group -Name "customGroup2" Update a user group .EXAMPLE PS> Get-GroupByName -Name $Group.name | Update-Group -Name "customGroup2" Update a user group (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Group id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # name [Parameter()] [string] $Name, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "userGroups" ` -Verb "update" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-ManagedObject { <# .SYNOPSIS Update inventory .DESCRIPTION Update a managed object by id .EXAMPLE PS> Update-ManagedObject -Id $mo.id -Data @{ com_my_props = @{ value = 1 } } Update a managed object .EXAMPLE PS> Get-ManagedObject -Id $mo.id | Update-ManagedObject -Data @{ com_my_props = @{ value = 1 } } Update a managed object (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # ManagedObject id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # name [Parameter()] [string] $NewName, # Additional properties of the inventory. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("NewName")) { $Parameters["newName"] = $NewName } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "inventory" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.inventory+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-Microservice { <# .SYNOPSIS Update microservice meta information .DESCRIPTION Update microservice properties such as availability, context path etc. .EXAMPLE PS> Update-Microservice -Id $App.id -Availability "MARKET" Update microservice availability to MARKET #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Microservice id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # data [Parameter()] [object] $Data, # Shared secret of microservice [Parameter()] [string] $Key, # Access level for other tenants. Possible values are : MARKET, PRIVATE (default) [Parameter()] [ValidateSet('MARKET','PRIVATE')] [string] $Availability, # contextPath of the hosted application [Parameter()] [string] $ContextPath, # URL to microservice base directory hosted on an external server [Parameter()] [string] $ResourcesUrl, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("Key")) { $Parameters["key"] = $Key } if ($PSBoundParameters.ContainsKey("Availability")) { $Parameters["availability"] = $Availability } if ($PSBoundParameters.ContainsKey("ContextPath")) { $Parameters["contextPath"] = $ContextPath } if ($PSBoundParameters.ContainsKey("ResourcesUrl")) { $Parameters["resourcesUrl"] = $ResourcesUrl } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Microservice $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "microservices" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-Operation { <# .SYNOPSIS Update operation .DESCRIPTION Update an operation. This is commonly used to change an operation's status. For example the operation can be set to FAILED along with a failure reason. .EXAMPLE PS> Update-Operation -Id {{ NewOperation }} -Status EXECUTING Update an operation .EXAMPLE PS> Get-OperationCollection -Device $Agent.id -Status PENDING | Update-Operation -Status FAILED -FailureReason "manually cancelled" Update multiple operations #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Operation id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # Operation status, can be one of SUCCESSFUL, FAILED, EXECUTING or PENDING. (required) [Parameter(Mandatory = $true)] [ValidateSet('PENDING','EXECUTING','SUCCESSFUL','FAILED')] [string] $Status, # Reason for the failure. Use when setting status to FAILED [Parameter()] [string] $FailureReason, # Additional properties describing the operation which will be performed on the device. [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Status")) { $Parameters["status"] = $Status } if ($PSBoundParameters.ContainsKey("FailureReason")) { $Parameters["failureReason"] = $FailureReason } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "operations" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.operation+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-RetentionRule { <# .SYNOPSIS Update retention rule .DESCRIPTION Update an existing retentule rule, i.e. change maximum number of days or the data type. .EXAMPLE PS> Update-RetentionRule -Id $RetentionRule.id -DataType MEASUREMENT -FragmentType "custom_FragmentType" Update a retention rule .EXAMPLE PS> Get-RetentionRule -Id $RetentionRule.id | Update-RetentionRule -DataType MEASUREMENT -FragmentType "custom_FragmentType" Update a retention rule (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Retention rule id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # RetentionRule will be applied to this type of documents, possible values [ALARM, AUDIT, EVENT, MEASUREMENT, OPERATION, *]. (required) [Parameter(Mandatory = $true)] [ValidateSet('ALARM','AUDIT','EVENT','MEASUREMENT','OPERATION','*')] [string] $DataType, # RetentionRule will be applied to documents with fragmentType. [Parameter()] [string] $FragmentType, # RetentionRule will be applied to documents with type. [Parameter()] [string] $Type, # RetentionRule will be applied to documents with source. [Parameter()] [string] $Source, # Maximum age of document in days. [Parameter()] [long] $MaximumAge, # Whether the rule is editable. Can be updated only by management tenant. [Parameter()] [switch] $Editable, # Data [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DataType")) { $Parameters["dataType"] = $DataType } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("Source")) { $Parameters["source"] = $Source } if ($PSBoundParameters.ContainsKey("MaximumAge")) { $Parameters["maximumAge"] = $MaximumAge } if ($PSBoundParameters.ContainsKey("Editable")) { $Parameters["editable"] = $Editable } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-Id $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "retentionRules" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.retentionRule+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-Tenant { <# .SYNOPSIS Update tenant .DESCRIPTION Update tenant .EXAMPLE PS> Update-Tenant -Id mycompany -ContactName "John Smith" Update a tenant by name (from the mangement tenant) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant id [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object] $Id, # Company name. Maximum 256 characters [Parameter()] [string] $Company, # Domain name to be used for the tenant. Maximum 256 characters (required) [Parameter(Mandatory = $true)] [string] $Domain, # Username of the tenant administrator [Parameter()] [string] $AdminName, # Password of the tenant administrator [Parameter()] [string] $AdminPass, # A contact name, for example an administrator, of the tenant [Parameter()] [string] $ContactName, # An international contact phone number [Parameter()] [string] $ContactPhone, # A set of custom properties of the tenant [Parameter()] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Company")) { $Parameters["company"] = $Company } if ($PSBoundParameters.ContainsKey("Domain")) { $Parameters["domain"] = $Domain } if ($PSBoundParameters.ContainsKey("AdminName")) { $Parameters["adminName"] = $AdminName } if ($PSBoundParameters.ContainsKey("AdminPass")) { $Parameters["adminPass"] = $AdminPass } if ($PSBoundParameters.ContainsKey("ContactName")) { $Parameters["contactName"] = $ContactName } if ($PSBoundParameters.ContainsKey("ContactPhone")) { $Parameters["contactPhone"] = $ContactPhone } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { $Parameters["id"] = PSc8y\Expand-Id $Id if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "tenants" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.tenant+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-TenantOption { <# .SYNOPSIS Update tenant option .DESCRIPTION Update tenant option .EXAMPLE PS> Update-TenantOption -Category "c8y_cli_tests" -Key "$option4" -Value "0" Update a tenant option #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant Option category (required) [Parameter(Mandatory = $true)] [string] $Category, # Tenant Option key (required) [Parameter(Mandatory = $true)] [string] $Key, # New value (required) [Parameter(Mandatory = $true)] [string] $Value, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Category")) { $Parameters["category"] = $Category } if ($PSBoundParameters.ContainsKey("Key")) { $Parameters["key"] = $Key } if ($PSBoundParameters.ContainsKey("Value")) { $Parameters["value"] = $Value } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "tenantOptions" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.option+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-TenantOptionBulk { <# .SYNOPSIS Update multiple tenant options in provided category .DESCRIPTION Update multiple tenant options in provided category .EXAMPLE PS> Update-TenantOptionBulk -Category "c8y_cli_tests" -Data @{ $option5 = 0; $option6 = 1 } Update multiple tenant options #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant Option category (required) [Parameter(Mandatory = $true)] [string] $Category, # Key/value pairs (required) [Parameter(Mandatory = $true)] [object] $Data, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Category")) { $Parameters["category"] = $Category } if ($PSBoundParameters.ContainsKey("Data")) { $Parameters["data"] = ConvertTo-JsonArgument $Data } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "tenantOptions" ` -Verb "updateBulk" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.option+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-TenantOptionEditable { <# .SYNOPSIS Update tenant option editibility .DESCRIPTION Required role:: ROLE_OPTION_MANAGEMENT_ADMIN, Required tenant management Example Request:: Update access.control.allow.origin option. .EXAMPLE PS> Update-TenantOptionEditable -Category "c8y_cli_tests" -Key "$option8" -Editable "true" Update editable property for an existing tenant option #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant Option category (required) [Parameter(Mandatory = $true)] [string] $Category, # Tenant Option key (required) [Parameter(Mandatory = $true)] [string] $Key, # Whether the tenant option should be editable or not (required) [Parameter(Mandatory = $true)] [ValidateSet('true','false')] [string] $Editable, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Category")) { $Parameters["category"] = $Category } if ($PSBoundParameters.ContainsKey("Key")) { $Parameters["key"] = $Key } if ($PSBoundParameters.ContainsKey("Editable")) { $Parameters["editable"] = $Editable } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "tenantOptions" ` -Verb "updateEdit" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.option+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Update-User { <# .SYNOPSIS Update user .DESCRIPTION Update properties, reset password or enable/disable for a user in a tenant .EXAMPLE PS> Update-User -Id $User.id -FirstName "Simon" Update a user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # User id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # User first name [Parameter()] [string] $FirstName, # User last name [Parameter()] [string] $LastName, # User phone number. Format: '+[country code][number]', has to be a valid MSISDN [Parameter()] [string] $Phone, # User email address [Parameter()] [string] $Email, # User activation status (true/false) [Parameter()] [switch] $Enabled, # User password. Min: 6, max: 32 characters. Only Latin1 chars allowed [Parameter()] [string] $Password, # User activation status (true/false) [Parameter()] [ValidateSet('true','false')] [switch] $SendPasswordResetEmail, # Custom properties to be added to the user [Parameter()] [object] $CustomProperties, # Tenant [Parameter()] [object] $Tenant, # Show the full (raw) response from Cumulocity including pagination information [Parameter()] [switch] $Raw, # Write the response to file [Parameter()] [string] $OutputFile, # Ignore any proxy settings when running the cmdlet [Parameter()] [switch] $NoProxy, # Specifiy alternative Cumulocity session to use when running the cmdlet [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("FirstName")) { $Parameters["firstName"] = $FirstName } if ($PSBoundParameters.ContainsKey("LastName")) { $Parameters["lastName"] = $LastName } if ($PSBoundParameters.ContainsKey("Phone")) { $Parameters["phone"] = $Phone } if ($PSBoundParameters.ContainsKey("Email")) { $Parameters["email"] = $Email } if ($PSBoundParameters.ContainsKey("Enabled")) { $Parameters["enabled"] = $Enabled } if ($PSBoundParameters.ContainsKey("Password")) { $Parameters["password"] = $Password } if ($PSBoundParameters.ContainsKey("SendPasswordResetEmail")) { $Parameters["sendPasswordResetEmail"] = $SendPasswordResetEmail } if ($PSBoundParameters.ContainsKey("CustomProperties")) { $Parameters["customProperties"] = ConvertTo-JsonArgument $CustomProperties } if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in (PSc8y\Expand-User $Id)) { if ($item) { $Parameters["id"] = 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-ClientCommand ` -Noun "users" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.user+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } Function Add-PowershellType { <# .SYNOPSIS Add a powershell type name to a powershell object .DESCRIPTION This allows a custom type name to be given to powershell objects, so that the view formatting can be used (i.e. .ps1xml) .EXAMPLE $data | Add-PowershellType -Type "customType1" Add a type `customType1` to the input object .INPUTS Object[] .OUTPUTS Object[] #> [cmdletbinding()] Param( # Object to add the type name to [Parameter( Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] [Object[]] $InputObject, # Type name to assign to the input objects [Parameter( Mandatory = $true, Position = 1)] [string] $Type ) Process { foreach ($InObject in $InputObject) { [void]$InObject.PSObject.TypeNames.Insert(0, $Type) $InObject } } } Function Clear-Session { <# .SYNOPSIS Clear the active Cumulocity Session .DESCRIPTION Clear the active Cumulocity Session .EXAMPLE Clear-Session Clears the current Cumulocity session .OUTPUTS None #> [CmdletBinding()] Param() Write-Verbose "Clearing cumulocity session" $env:C8Y_SESSION = "" } Function ConvertFrom-Base64ToUtf8 { <# .SYNOPSIS Convert a base64 encoded string to UTF8 .DESCRIPTION Convert a base64 encoded string to UTF8 .NOTES If the the string has spaces in it, then only the last part of the string (with no spaces in it) will be used. This makes it easier when trying decode the basic auth string .PARAMETER InputObject Base64 encoded string .EXAMPLE ConvertFrom-Base64ToUtf8 ZWFzdGVyZWdn Convert the base64 to utf8 .EXAMPLE ConvertFrom-Base64ToUtf8 "Authorization: Basic s7sd81kkzyzldjkzkhejhug3kh" Convert the base64 to utf8 #> [CmdletBinding()] Param( [Parameter( Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Position=0)] [string[]] $InputObject ) Process { foreach ($Item in $InputObject) { $Base64 = ($Item -split "\s+") | Select-Object -Last 1 [System.Text.Encoding]::UTF8.Getstring([System.Convert]::FromBase64String($Base64)) } } } Function ConvertTo-JsonArgument { <# .SYNOPSIS Convert a powershell hashtable/object to a json escaped string .DESCRIPTION Helper function is used when passing Powershell hashtable or PSCustomObjects to the c8y binary. Before the c8y cli binary can accept it, it must be converted to json. The necessary character escaping of literal backslashed `\` will be done automatically. .EXAMPLE ConvertTo-JsonArgument @{ myValue = "1" } Converts the hashtable to an escaped json string ```json {\"myValue\":\"1\"} ``` #> [cmdletbinding()] Param( # Input object to be converted [Parameter( Mandatory = $true, Position = 0 )] [object] $Data ) if ($Data -is [string]) { # If string, then validate if json was provided $DataObj = (ConvertFrom-Json $Data) } else { $DataObj = $Data } # Note: replace \" with the unicode character to prevent intepretation errors on the command line $jsonRaw = (ConvertTo-Json $DataObj -Compress) -replace '\\"', '\u0022' $strArg = "{0}" -f ($jsonRaw -replace '(?<!\\)"', '\"') # Replace space with unicode char, as space can have console parsing problems $strArg = $strArg -replace " ", "\u0020" $strArg } Function Expand-Application { <# .SYNOPSIS Expand a list of applications replacing any ids or names with the actual application object. .DESCRIPTION The list of applications will be expanded to include the full application representation by fetching the data from Cumulocity. .NOTES If the given object is already an application object, then it is added with no additional lookup .PARAMETER InputObject List of ids, names or application objects .PARAMETER Type Limit the types of object by a specific type .EXAMPLE Expand-Application "app-name" Retrieve the application objects by name or id .EXAMPLE Get-C8yApplicationCollection *app* | Expand-Application Get all the application object (with app in their name). Note the Expand cmdlet won't do much here except for returning the input objects. .EXAMPLE Expand-Application * -Type MICROSERVICE Expand applications that match a name of "*" and have a type of "MICROSERVICE" #> [cmdletbinding()] Param( [Parameter( Mandatory=$true, ValueFromPipeline=$true, Position=0 )] [object[]] $InputObject ) Process { [array] $AllApplications = foreach ($iApp in $InputObject) { # Already an app object, so do nothing if ($iApp.id) { $iApp continue } if ($iApp.applicationId) { PSc8y\Get-Application -Id $iApp.applicationId -WhatIf:$false continue } if ("$iApp" -match "^\d+$") { # Provided with an id $iApp # PSc8y\Get-Application -Id $iApp -WhatIf:$false } else { # Provided with a query PSc8y\Get-ApplicationCollection -PageSize 2000 | Where-Object { $_.name -like "$iApp" } } } $AllApplications } } Function Expand-Device { <# .SYNOPSIS Expand a list of devices replacing any ids or names with the actual device object. .DESCRIPTION The list of devices will be expanded to include the full device representation by fetching the data from Cumulocity. .NOTES If the given object is already an device object, then it is added with no additional lookup .PARAMETER InputObject List of ids, names or device objects .EXAMPLE Expand-Device "mydevice" Retrieve the device objects by name or id .EXAMPLE Get-DeviceCollection *test* | Expand-Device Get all the device object (with app in their name). Note the Expand cmdlet won't do much here except for returning the input objects. #> [cmdletbinding( # SupportsShouldProcess = $true, # ConfirmImpact = "None" )] Param( [Parameter( Mandatory=$true, ValueFromPipeline=$true, Position=0 )] [object[]] $InputObject ) Process { [array] $AllDevices = foreach ($iDevice in $InputObject) { if ($iDevice.id) { $iDevice } else { if ($iDevice -match "^\d+$") { Get-ManagedObject -Id $iDevice } else { Get-DeviceCollection -Name $iDevice -WhatIf:$false } } } $AllDevices } } Function Expand-Id { <# .SYNOPSIS Expand a list of ids. .DESCRIPTION Expand the list of objects and only return the ids instead of the full objects. .EXAMPLE Expand-Id 12345 Normalize a list of ids .EXAMPLE "12345", "56789" | Expand-Id Normalize a list of ids #> [cmdletbinding()] Param( # List of ids [Parameter( Mandatory=$true, ValueFromPipeline=$true, Position=0 )] [AllowEmptyCollection()] [AllowNull()] [object[]] $InputObject ) Process { [array] $AllIds = foreach ($iID in $InputObject) { $currentID = $iID if ($null -ne $iID.id) { $currentID = $iID.id } # Allow for matching integer or strings types, hence the the quotes around the $currentID variable if ("$currentID" -match "^[0-9a-z_\-*]+$") { $currentID } } $AllIds } } Function Expand-Microservice { <# .SYNOPSIS Expand a list of microservices objects .DESCRIPTION Expand a list of microservices replacing any ids or names with the actual microservice object. .NOTES If the given object is already an microservice object, then it is added with no additional lookup .PARAMETER InputObject List of ids, names or microservice objects .EXAMPLE Expand-Microservice "app-name" Retrieve the microservice objects by name or id .EXAMPLE Get-C8yMicroserviceCollection *app* | Expand-Microservice Get all the microservice object (with app in their name). Note the Expand cmdlet won't do much here except for returning the input objects. #> [cmdletbinding()] Param( [Parameter( Mandatory=$true, ValueFromPipeline=$true, Position=0 )] [object[]] $InputObject ) Process { [array] $AllMicroservices = foreach ($iApp in $InputObject) { # Already an app object, so do nothing if ($iApp.id) { $iApp continue } if ($iApp.applicationId) { PSc8y\Get-Microservice -Id $iApp.applicationId -WhatIf:$false continue } if ("$iApp" -match "^\d+$") { # Provided with an id $iApp } else { # Provided with a query PSc8y\Get-MicroserviceCollection -PageSize 2000 | Where-Object { $_.name -like "$iApp" } } } $AllMicroservices } } Function Expand-PaginationObject { <# .SYNOPSIS Expand a Cumulocity pagination result .DESCRIPTION Iterate through a Cumulocity pagination result set, and keep fetching the results until the last page is found. The cmdlet will only return once the total result set has been fetched, and the items will be returned in one array. .EXAMPLE Invoke-ClientRequest -Uri "/inventory/managedObjects" -QueryParameters @{ pageSize = 2000 } -Raw | ConvertFrom-Json | Expand-PaginationObject Get all managed objects in the platform (rest requests will be done in chunks of 2000) .EXAMPLE $data = Get-MeasurementCollection -Device testDevice -Raw -PageSize 2000 | Expand-PaginationObject Get a measurement collection, then retrieve all the measurements by iterating through the pagination object #> [cmdletbinding()] Param( # Response from a Cumulocity rest request. It must have the next property. [Parameter( Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object] $InputObject, # Maximum number of pages to retrieve. If Zero or less, then it will retrieve all of the results [int] $MaxPage = 0 ) Begin { $InputCollection = New-Object System.Collections.ArrayList Function Get-ResultProperty { Param( [object] $InputObject ) # Detect the type of c8y object $Prop = $null if ($null -ne $InputObject.managedObjects) { $Prop = "managedObjects" } elseif ($null -ne $InputObject.operations) { $Prop = "operations" } elseif ($null -ne $InputObject.alarms) { $Prop = "alarms" } elseif ($null -ne $InputObject.measurements) { $Prop = "measurements" } elseif ($null -ne $InputObject.events) { $Prop = "events" } elseif ($null -ne $InputObject.auditRecords) { $Prop = "auditRecords" } elseif ($null -ne $InputObject.connectors) { $Prop = "connectors" } elseif ($null -ne $InputObject.newDeviceRequests) { $Prop = "newDeviceRequests" } elseif ($null -ne $InputObject.externalIds) { $Prop = "externalIds" } elseif ($null -ne $InputObject.retentionRules) { $Prop = "retentionRules" } elseif ($null -ne $InputObject.groups) { $Prop = "groups" } elseif ($null -ne $InputObject.roles) { $Prop = "roles" } elseif ($null -ne $InputObject.users) { $Prop = "users" } elseif ($null -ne $InputObject.references) { $Prop = "references" } elseif ($null -ne $InputObject.tenants) { $Prop = "tenants" } elseif ($null -ne $InputObject.options) { $Prop = "options" } $Prop } } Process { $null = $InputCollection.Add($InputObject) } End { $ProcessObject = $InputCollection | Select-Object -First 1 Write-Verbose "Input Collection Count: $($InputCollection.Count)" if (($InputCollection.Count -eq 0) -or (($InputCollection.Count -gt 1) -and !$InputCollection[0].next)) { Write-Warning "Input object is not a Cumulocity Pagination Object" $ProcessObject return; } $ResultCollection = New-Object System.Collections.ArrayList $Result = $ProcessObject $Prop = Get-ResultProperty -InputObject $Result if ($Result.$Prop -is [array]) { $null = $ResultCollection.AddRange($Result.$Prop) } else { $null = $ResultCollection.Add($Result.$Prop) } $Iteration = 1 $Done = $false if ($Result.next) { while (!$Done) { Write-Verbose "Requesting next item: (iteration $Iteration)" $Result = Invoke-ClientRequest -Method Get -Uri $Result.next -Raw | ConvertFrom-Json # Detect the type of c8y object $Prop = Get-ResultProperty -InputObject $Result if ($null -eq $Prop) { Write-Warning "Could not find the array object property. Only alarms, events, managedObjects, measurments and operations properties are supported" } else { Write-Verbose "Found array object property [$Prop]" } if ($Result -and $Prop) { if ($Result.$Prop -is [array]) { $null = $ResultCollection.AddRange($Result.$Prop) } else { $null = $ResultCollection.Add($Result.$Prop) } } $Done = !$Result -or !$Result.next -or ($Result.$Prop.Count -eq 0) ` -or ($MaxPage -gt 0 -and $Iteration -ge $MaxPage) ` -or ($Result.$Prop.Count -lt $Result.statistics.pageSize) $Iteration += 1 } } $ResultCollection } } Function Expand-Source { <# .SYNOPSIS Expand a list of source ids. .DESCRIPTION Expand the list of input objects and return the source using the following logic: 1. Look for a source.id property 2. Look for a deviceId property 3. Look for a id property 4. Check if the given is a string or int and is integer like .EXAMPLE Expand-Source 12345 Normalize a list of ids .EXAMPLE "12345", "56789" | Expand-Source Normalize a list of ids .EXAMPLE Get-OperationCollection -PageSize 1000 | Expand-Source | Select-Object -Unique Get a unique list of device ids from a list of operations #> [cmdletbinding()] Param( # List of objects which can either be operations, alarms, measurements or managed objects [Parameter( Mandatory=$true, ValueFromPipeline=$true, Position=0 )] [AllowEmptyCollection()] [AllowNull()] [object[]] $InputObject ) Process { [array] $AllIds = foreach ($iObject in $InputObject) { $currentID = $iObject if ($null -ne $iObject.source.id) { $currentID = $iObject.source.id } elseif ($null -ne $iObject.deviceId) { $currentID = $iObject.deviceId } elseif ($null -ne $iObject.id) { $currentID = $iObject.id } # Allow for matching integer or strings types, hence the the quotes around the $currentID variable if ("$currentID" -match "^[0-9]+$") { $currentID } } $AllIds } } Function Expand-Tenant { <# .SYNOPSIS Expand the tenants by id or name .DESCRIPTION Expand a list of tenants replacing any ids or names with the actual tenant object. .NOTES If the given object is already an tenant object, then it is added with no additional lookup .EXAMPLE Expand-Tenant "mytenant" Retrieve the tenant objects by name or id .EXAMPLE Get-Tenant *test* | Expand-Tenant Get all the tenant object (with app in their name). Note the Expand cmdlet won't do much here except for returning the input objects. #> [cmdletbinding()] Param( # List of ids, names or tenant objects [Parameter( Mandatory=$true, ValueFromPipeline=$true, Position=0 )] [object[]] $InputObject ) Process { [array] $AllTenants = foreach ($iTenant in $InputObject) { if ("$iTenant".Contains("*")) { Get-TenantCollection -PageSize 2000 | Where-Object { $_.id -like $iTenant } -WhatIf:$false } else { $iTenant } } $AllTenants } } Function Expand-User { <# .SYNOPSIS Expand a list of users .DESCRIPTION Expand a list of users replacing any ids or names with the actual user object. .NOTES If the given object is already an user object, then it is added with no additional lookup .EXAMPLE Expand-User "myuser" Retrieve the user objects by name or id .EXAMPLE Get-UserCollection *test* | Expand-User Get all the user object (with app in their name). Note the Expand cmdlet won't do much here except for returning the input objects. #> [cmdletbinding()] Param( # List of ids, names or user objects [Parameter( Mandatory=$true, ValueFromPipeline=$true, Position=0 )] [object[]] $InputObject ) Process { [array] $AllUsers = foreach ($iUser in $InputObject) { if (($iUser -is [string])) { if ($iUser -match "\*") { # Remove any wildcard characters, as they are not supported by c8y $iUserNormalized = $iUser -replace "\*", "" PSc8y\Get-UserCollection -Username $iUserNormalized -WhatIf:$false -PageSize 100 | Where-Object { $_.id -like $iUser -or $_.userName -like $iUser } } else { $iUser } } else { $iUser } } $AllUsers } } # Code generated from specification version 1.0.0: DO NOT EDIT Function Find-ManagedObjectCollection { <# .SYNOPSIS Get a collection of managedObjects based on Cumulocity query language .DESCRIPTION Get a collection of managedObjects based on Cumulocity query language .EXAMPLE PS> Find-ManagedObjectCollection -Query "name eq 'roomUpperFloor_*'" Find all devices with their names starting with 'roomUpperFloor_' #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # ManagedObject query. (required) [Parameter(Mandatory = $true)] [string] $Query, # ManagedObject sort results by. [Parameter(Mandatory = $false)] [string] $OrderBy, # include a flat list of all parents and grandparents of the given object [Parameter()] [switch] $WithParents, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Include raw response including pagination information [Parameter()] [switch] $Raw, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session, # TimeoutSec timeout in seconds before a request will be aborted [Parameter()] [double] $TimeoutSec ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Query")) { $Parameters["query"] = $Query } if ($PSBoundParameters.ContainsKey("OrderBy")) { $Parameters["orderBy"] = $OrderBy } if ($PSBoundParameters.ContainsKey("WithParents")) { $Parameters["withParents"] = $WithParents } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } if ($PSBoundParameters.ContainsKey("TimeoutSec")) { $Parameters["timeout"] = $TimeoutSec * 1000 } } Process { foreach ($item in @("")) { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "inventory" ` -Verb "find" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObjectCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ResultProperty "managedObjects" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } } End {} } Function Format-Date { <# .SYNOPSIS Gets a Cumulocity (ISO-8601) formatted DateTime string in the specified timezone .DESCRIPTION All Cumulocity REST API calls that require a date, must be in the ISO-8601 format. This function allows the user to easily generate the correct format including the correct timezone information. .NOTES The standard powershell Get-Date does not have any timezone information. .EXAMPLE Format-Date Get current datetime (now) as an ISO8601 formatted string .EXAMPLE [TimeZoneInfo]::GetSystemTimeZones() | Foreach-Object { Format-Date -Timezone $_ } Get current datetime (now) as an ISO8601 formatted string in each of the timezones .OUTPUTS String #> [CmdletBinding()] Param( # DateTime to be converted to ISO-8601 format. Accepts piped input [Parameter(Mandatory=$false, Position = 0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [datetime[]] $InputObject = @(), # Timezone to use when converting the DateTime object. Defaults to Local System Timezone [TimeZoneInfo] $TimeZone = $null ) Begin { if ($null -eq $TimeZone) { $TimeZone = [TimeZoneInfo]::Local } $InputDates = New-Object System.Collections.ArrayList } Process { if ($null -ne $InputObject -and $InputObject.Count -ne 0) { $null = $InputDates.AddRange($InputObject) } else { $null = $InputDates.Add((Get-Date)) } } End { foreach ($iDate in $InputDates) { # Get DateTime as ISO 8601 formatted string # It does not contain the timezone, this will have to be added manually $DateWithoutTimezone = Get-Date $iDate -Format "yyyy-MM-ddTHH:mm:ss.fff" # Get the time zone offset at a specific time $TimeZoneOffset = $TimeZone.GetUtcOffset($iDate) if (!($TimeZoneOffset.Hours -eq 0 -and $TimeZoneOffset.Minutes -eq 0)) { if ($TimeZoneOffset.TotalSeconds -ge 0) { $OffsetStr = "+" + "$($TimeZoneOffset.Hours)".PadLeft(2, '0') } else { # The minus sign is automatically in the hours. $OffsetStr = "" + "$($TimeZoneOffset.Hours)".PadLeft(2, '0') } if ($TimeZoneOffset.Minutes -ne 0) { # Math Absolute is required because when a timezone is before GMT, then the Minutes are negative $OffsetStr += ":" + "$([math]::Abs($TimeZoneOffset.Minutes))".PadLeft(2, '0') } $DateWithTimezone = "${DateWithoutTimezone}${OffsetStr}" } else { # GMT 0 / UTC $DateWithTimezone = "${DateWithoutTimezone}Z" } $DateWithTimezone } } } Function Get-AgentCollection { <# .SYNOPSIS Get a collection of agents .DESCRIPTION Get a collection of agent in the current tenant .EXAMPLE Get-AgentCollection -Name *sensor* Get all agents with "sensor" in their name .EXAMPLE Get-AgentCollection -Name *sensor* -Type *c8y_* -PageSize 100 Get the first 100 agents with "sensor" in their name and has a type matching "c8y_" .EXAMPLE Get-AgentCollection -Query "lastUpdated.date gt '2020-01-01T00:00:00Z'" Get a list of agents which have been updated more recently than 2020-01-01 #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Agent name. Wildcards accepted [Parameter(Mandatory = $false)] [string] $Name, # Agent type. [Parameter(Mandatory = $false)] [string] $Type, # Agent fragment type. [Parameter(Mandatory = $false)] [string] $FragmentType, # Agent owner. [Parameter(Mandatory = $false)] [string] $Owner, # Query. [Parameter(Mandatory = $false)] [string] $Query, # include a flat list of all parents and grandparents of the given object [Parameter()] [switch] $WithParents, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Include all results [Parameter()] [switch] $IncludeAll, # Include raw response including pagination information [Parameter()] [switch] $Raw, # Session path [Parameter()] [string] $Session ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("owner")) { $Parameters["owner"] = $Owner } if ($PSBoundParameters.ContainsKey("Query")) { $Parameters["query"] = $Query } if ($PSBoundParameters.ContainsKey("WithParents")) { $Parameters["withParents"] = $WithParents } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject "") )) { continue } Invoke-ClientCommand ` -Noun "agents" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customAgentCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.customAgent+json" ` -ResultProperty "managedObjects" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } } Function Get-AssetParent { <# .SYNOPSIS Get asset parent references for a asset .DESCRIPTION Get the parent of an existing assert by using the references. The cmdlet supports returning various forms of the parent references, i.e. immediate parent, parent or the parent, or the full parental references. .EXAMPLE Get-AssetParent asset0* Get the direct (immediate) parent of the given asset .EXAMPLE Get-AssetParent -All Return an array of parent assets where the first element in the array is the root asset, and the last is the direct parent of the given asset. .EXAMPLE Get-AssetParent -RootParent Returns the root parent. In most cases this will be the agent #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, DefaultParameterSetName = "ByLevel", HelpUri='', ConfirmImpact = 'None')] Param( # Asset id, name or object. Wildcards accepted [Parameter( ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [object[]] $Asset, # Level to navigate backward from the given asset to its parent/s # 1 = direct parent # 2 = parent of its parent # If the Level is too large, then the root parent will be returned [Parameter( ParameterSetName = "ByLevel", Position = 1)] [ValidateRange(1,100)] [int] $Level = 1, # Return the top level / root parent [Parameter( ParameterSetName = "Root")] [switch] $RootParent, # Return a list of all parent assets [Parameter( ParameterSetName = "All")] [switch] $All ) Process { # Get list of ids $Ids = Expand-Id $Asset $Results = foreach ($iasset in @(Get-ManagedObjectCollection -Device $Ids -WithParents)) { $Parents = @($iasset.assetParents.references.managedObject | Foreach-Object { if ($null -ne $_.id) { New-Object psobject -Property @{ id = $_.id; name = $_.name; } } }) # Reverse the order because Cumulocity returns the references in order from number of steps from the given asset. # So the asset closest to the given asset is first. [array]::Reverse($Parents) switch ($PSCmdlet.ParameterSetName) { "ByLevel" { # Convert to array index (don't need minus 1 because Level is also a 1 based index (same as Count)) $Index = $Parents.Count - $Level if ($Index -lt 0) { $Index = 0 } if ($Index -ge $Parents.Count) { $Index = $Parents.Count - 1 } if ($null -ne $Parents[$Index].id) { $Parents[$Index] } } "Root" { if ($null -ne $Parents[0].id) { $Parents[0] } } "All" { $Parents } } } $Results ` | Select-Object ` | Add-PowershellType -Type "c8y.parentReferences" } } Function Get-C8ySessionProperty { <# .SYNOPSIS Get a property from the current c8y session .DESCRIPTION An interface to read properties from the current c8y session, i.e. tenant or host. This is mostly used internally my other cmdlets in the module to abstract the accessing of such variables in case the environment variables change in the future (i.e. $env:C8Y_TENANT or $env:C8Y_HOST). .EXAMPLE Get-C8ySessionProperty tenant Get the tenant name of the current c8y cli session .OUTPUTS string #> [cmdletbinding()] Param( # Property name [Parameter( Mandatory = $true, Position = 0 )] [ValidateSet("tenant", "host")] [string] $Name ) switch ($Name) { "tenant" { $env:C8Y_TENANT } "host" { $env:C8Y_HOST } } } Function Get-ClientBinary { <# .SYNOPSIS Get the path to the Cumulocity Binary .DESCRIPTION Get the full path to the Cumulocity Binary which is compatible with the current Operating system .EXAMPLE Get-ClientBinary Returns the fullname of the path to the Cumulocity binary #> [cmdletbinding()] [OutputType([String])] Param() if ($IsLinux) { Resolve-Path "$script:Dependencies/c8y.linux" } elseif ($IsMacOS) { Resolve-Path "$script:Dependencies/c8y.macos" } else { Resolve-Path "$script:Dependencies/c8y.windows.exe" } } Function Get-ClientBinaryVersion { <# .SYNOPSIS Get the c8y client binary version .DESCRIPTION The c8y client binary version is the only dependency of the PSc8y module, and hence the version number is helpful to determine what functions are available .EXAMPLE Get-ClientBinaryVersion Show the client binary version on the console #> [cmdletbinding()] Param() $c8y = Get-ClientBinary & $c8y version } Function Get-CurrentTenantApplications { <# .SYNOPSIS Get the list of applications that are subscribed on the current tenant .DESCRIPTION Get the list of applications that are subscribed on the current tenant .EXAMPLE Get-CurrentTenantApplications Get a list of applications in the current tenant .LINK Get-CurrentApplication #> [cmdletbinding()] Param() $data = Get-CurrentTenant $data.applications.references.application ` | Select-Object ` | Add-PowershellType "application/vnd.com.nsn.cumulocity.application+json" } Function Get-DeviceBootstrapCredential { <# .SYNOPSIS Get the device bootstrap credential as a PowerShell credential object (for use in Rest requests) .DESCRIPTION The PSCredentials object also has two additional methods to make the usage of the credentials easier in The device bootstrap credentials should be already set in the following environment variables ```powershell $env:C8Y_DEVICEBOOTSTRAP_TENANT $env:C8Y_DEVICEBOOTSTRAP_USERNAME $env:C8Y_DEVICEBOOTSTRAP_PASSWORD ``` Then the credentials can be retrieved using ```powershell $Credential = Get-DeviceBootstrapCredential $Credential.GetPlainText() # => returns credentials in format "{username}/{password}" $Credential.GetBasicAuth() # => returns credentials in format "Basic {base64 encoded username/password}" ``` The credentials can be obtained by contacting support. For security reasons, do not use your tenant credentials. .OUTPUTS System.Management.Automation.PSCredential .EXAMPLE New-DeviceBootstrapCredential Get a credential object containing the devicebootstrap credentials .EXAMPLE $Cred = New-DeviceBootstrapCredential; $Cred.GetBasicAuth() Get device bootstrap credentials in the format of basic auth (for use in the 'Authorization' header) #> [cmdletbinding()] Param() $ErrorMessages = New-Object System.Collections.ArrayList if (!$env:C8Y_DEVICEBOOTSTRAP_TENANT) { $null = $ErrorMessages.Add("Missing env variable: C8Y_DEVICEBOOTSTRAP_TENANT") } if (!$env:C8Y_DEVICEBOOTSTRAP_USERNAME) { $null = $ErrorMessages.Add("Missing env variable: C8Y_DEVICEBOOTSTRAP_USERNAME") } if (!$env:C8Y_DEVICEBOOTSTRAP_PASSWORD) { $null = $ErrorMessages.Add("Missing env variable: C8Y_DEVICEBOOTSTRAP_PASSWORD") } if ($ErrorMessages.Count -ne 0) { Write-Warning ("The following environment variables are missing:`n {0}" -f ($ErrorMessages -join "`n ")) return } # Get credentials from environment variables $Tenant = $env:C8Y_DEVICEBOOTSTRAP_TENANT $Username = $env:C8Y_DEVICEBOOTSTRAP_USERNAME $Password = $env:C8Y_DEVICEBOOTSTRAP_PASSWORD | ConvertTo-SecureString -asPlainText -Force $Credential = New-Object System.Management.Automation.PSCredential("$Tenant/$Username", $password) # Add helper to return clear text username/password $Credential | Add-Member -MemberType ScriptMethod -Name "GetPlainText" -Value { "{0}:{1}" -f $this.GetNetworkCredential().UserName, $this.GetNetworkCredential().Password } # Add helper to return basic auth header info $Credential | Add-Member -MemberType ScriptMethod -Name "GetBasicAuth" -Value { "Basic " + [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(("{0}:{1}" -f @( $this.GetNetworkCredential().UserName, $this.GetNetworkCredential().Password )))) } $Credential } Function Get-DeviceCollection { <# .SYNOPSIS Get a collection of devices .DESCRIPTION Get a collection of devices in Cumulocity by using the inventory API. .EXAMPLE Get-DeviceCollection -Name *sensor* Get all devices with "sensor" in their name .EXAMPLE Get-DeviceCollection -Name *sensor* -Type *c8y_* -PageSize 100 Get the first 100 devices with "sensor" in their name and has a type matching "c8y_" .EXAMPLE Get-DeviceCollection -Query "lastUpdated.date gt '2020-01-01T00:00:00Z'" Get a list of devices which have been updated more recently than 2020-01-01 #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device name. Wildcards accepted [Parameter(Mandatory = $false)] [string] $Name, # Device type. [Parameter(Mandatory = $false)] [string] $Type, # Device fragment type. [Parameter(Mandatory = $false)] [string] $FragmentType, # Device owner. [Parameter(Mandatory = $false)] [string] $Owner, # Query. [Parameter(Mandatory = $false)] [string] $Query, # Only include agents. [Parameter()] [switch] $Agents, # include a flat list of all parents and grandparents of the given object [Parameter()] [switch] $WithParents, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Include all results [Parameter()] [switch] $IncludeAll, # Include raw response including pagination information [Parameter()] [switch] $Raw, # Session path [Parameter()] [string] $Session ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("owner")) { $Parameters["owner"] = $Owner } if ($PSBoundParameters.ContainsKey("Query")) { $Parameters["query"] = $Query } if ($PSBoundParameters.ContainsKey("Agents")) { $Parameters["agents"] = $Agents } if ($PSBoundParameters.ContainsKey("WithParents")) { $Parameters["withParents"] = $WithParents } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject "") )) { continue } Invoke-ClientCommand ` -Noun "devices" ` -Verb "list" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customDeviceCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.customDevice+json" ` -ResultProperty "managedObjects" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } } Function Get-DeviceGroupCollection { <# .SYNOPSIS Get a collection of device groups .DESCRIPTION Get a collection of device groups. Device groups are used to arrange devices together. .EXAMPLE Get-DeviceGroupCollection -Name *Room* Get all device groups with "Room" in their name .EXAMPLE Get-DeviceGroupCollection -Query "creationTime.date gt '2020-01-01T00:00:00Z'" Get a list of devices groups which have been created more recently than 2020-01-01 #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device group name. Wildcards accepted [Parameter(Mandatory = $false)] [string] $Name, # Device group type. [Parameter(Mandatory = $false)] [string] $Type, # Device group fragment type. [Parameter(Mandatory = $false)] [string] $FragmentType, # Device group owner. [Parameter(Mandatory = $false)] [string] $Owner, # Query. [Parameter(Mandatory = $false)] [string] $Query, # Exclude root groups from the list [Parameter(Mandatory = $false)] [switch] $ExcludeRootGroup, # Include a flat list of all parents and grandparents of the given object [Parameter()] [switch] $WithParents, # Maximum number of results [Parameter()] [AllowNull()] [AllowEmptyString()] [ValidateRange(1,2000)] [int] $PageSize, # Include total pages statistic [Parameter()] [switch] $WithTotalPages, # Include all results [Parameter()] [switch] $IncludeAll, # Include raw response including pagination information [Parameter()] [switch] $Raw, # Session path [Parameter()] [string] $Session ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Type")) { $Parameters["type"] = $Type } if ($PSBoundParameters.ContainsKey("FragmentType")) { $Parameters["fragmentType"] = $FragmentType } if ($PSBoundParameters.ContainsKey("owner")) { $Parameters["owner"] = $Owner } if ($PSBoundParameters.ContainsKey("Query")) { $Parameters["query"] = $Query } if ($PSBoundParameters.ContainsKey("ExcludeRootGroup")) { $Parameters["excludeRootGroup"] = $ExcludeRootGroup } if ($PSBoundParameters.ContainsKey("WithParents")) { $Parameters["withParents"] = $WithParents } if ($PSBoundParameters.ContainsKey("PageSize")) { $Parameters["pageSize"] = $PageSize } if ($PSBoundParameters.ContainsKey("WithTotalPages") -and $WithTotalPages) { $Parameters["withTotalPages"] = $WithTotalPages } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject "") )) { continue } Invoke-ClientCommand ` -Noun "devices" ` -Verb "listDeviceGroups" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.customDeviceGroupCollection+json" ` -ItemType "application/vnd.com.nsn.cumulocity.customDeviceGroup+json" ` -ResultProperty "managedObjects" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } } Function Get-DeviceParent { <# .SYNOPSIS Get device parent references for a device .DESCRIPTION Get the parent of a device by using the references stored in the device managed object. .EXAMPLE Get-DeviceParent device0* Get the direct (immediate) parent of the given device .EXAMPLE Get-DeviceParent -All Return an array of parent devices where the first element in the array is the root device, and the last is the direct parent of the given device. .EXAMPLE Get-DeviceParent -RootParent Returns the root parent. In most cases this will be the agent #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, DefaultParameterSetName = "ByLevel", HelpUri='', ConfirmImpact = 'None')] Param( # Device id, name or object. Wildcards accepted [Parameter( ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [object[]] $Device, # Level to navigate backward from the given device to its parent/s # 1 = direct parent # 2 = parent of its parent # If the Level is too large, then the root parent will be returned [Parameter( ParameterSetName = "ByLevel", Position = 1)] [ValidateRange(1,100)] [int] $Level = 1, # Return the top level / root parent [Parameter( ParameterSetName = "Root")] [switch] $RootParent, # Return a list of all parent devices [Parameter( ParameterSetName = "All")] [switch] $All ) Process { # Get list of ids $Ids = (Expand-Device $Device) | Select-Object -ExpandProperty id $Results = foreach ($iDevice in @(Get-ManagedObjectCollection -Device $Ids -WithParents)) { $Parents = @($iDevice.deviceParents.references.managedObject | Foreach-Object { if ($null -ne $_.id) { New-Object psobject -Property @{ id = $_.id; name = $_.name; } } }) # Reverse the order because Cumulocity returns the references in order from number of steps from the given device. # So the device closest to the given device is first. [array]::Reverse($Parents) switch ($PSCmdlet.ParameterSetName) { "ByLevel" { # Convert to array index (don't need minus 1 because Level is also a 1 based index (same as Count)) $Index = $Parents.Count - $Level if ($Index -lt 0) { $Index = 0 } if ($Index -ge $Parents.Count) { $Index = $Parents.Count - 1 } if ($null -ne $Parents[$Index].id) { $Parents[$Index] } } "Root" { if ($null -ne $Parents[0].id) { $Parents[0] } } "All" { $Parents } } } $Results ` | Expand-Device ` | Select-Object ` | Add-PowershellType -Type "c8y.parentReferences" } } Function Get-Session { <# .SYNOPSIS Get the active Cumulocity Session .DESCRIPTION Get the details about the active Cumulocity session which is used by all cmdlets .EXAMPLE Get-Session Get the current Cumulocity session .OUTPUTS None #> [CmdletBinding()] Param() $Path = $env:C8Y_SESSION if (!$Path) { Write-Warning "No active session is set" return } if (!(Test-Path $Path)) { Write-Error "Session file does not exist" return } $data = Get-Content -LiteralPath $Path | ConvertFrom-Json $data | Add-Member -MemberType NoteProperty -Name "path" -Value $Path -ErrorAction SilentlyContinue $data.path = (Resolve-Path $Path).ProviderPath if ($env:C8Y_LOGGER_HIDE_SENSITIVE -eq "true") { $data | Add-PowershellType "cumulocity/session-hide-sensitive" } else { $data | Add-PowershellType "cumulocity/session" } } Function Get-SessionCollection { <# .SYNOPSIS Get a collection of Cumulocity Sessions .DESCRIPTION Get a collection of Cumulocity Sessions found in the home folder under .cumulocity .EXAMPLE Get-SessionCollection List all of the Cumulocity sessions in the default home folder .OUTPUTS object[] #> [CmdletBinding()] Param() $HomePath = Get-SessionHomePath $Sessions = Get-ChildItem -LiteralPath $HomePath -Filter "*.json" -Recurse | ForEach-Object { $Path = $PSItem.FullName $data = Get-Content -LiteralPath $Path | ConvertFrom-Json $data | Add-Member -MemberType NoteProperty -Name "path" -Value $Path -ErrorAction SilentlyContinue $data.path = $Path $data } $Sessions ` | Select-Object ` | Add-PowershellType "cumulocity/sessionCollection" } Function Install-ClientBinary { <# .SYNOPSIS Install the Cumulocity cli binary (c8y) .DESCRIPTION Install the Cumulocity cli binary (c8y) so it is accessible from everywhere in consoles (assuming /usr/local/bin is in the $PATH variable) .EXAMPLE Install-ClientBinary On Linux/MacOS, this installs the cumulocity binary to /usr/local/bin On Windows this will throw a warning .EXAMPLE Install-ClientBinary -InstallPath /usr/bin Install the Cumulocity binary to /usr/bin #> [cmdletbinding()] Param( # Cumulocity installation path where the c8y binaries will be installed. Defaults to $env:C8Y_INSTALL_PATH [Parameter( Position = 0 )] [string] $InstallPath = $env:C8Y_INSTALL_PATH ) $binary = Get-ClientBinary if (!$binary -or !(Test-Path $binary)) { Write-Error "Could not find c8y binary" return } if ($IsMacOS -or $IsLinux) { if (!$InstallPath) { $InstallPath = "/usr/local/bin" } $TargetBinary = "c8y" Write-Verbose "Changing execution rights for the binary [$binary]" & chmod +x $binary if ($LASTEXITCODE -ne 0) { Write-Warning "Failed to change binary to executable mode. Try running 'chmod +x $InstallPath/$TargetBinary' manually" } } else { if (!$InstallPath) { if ($env:HOME) { $InstallPath = $env:HOME } } $TargetBinary = "c8y.exe" } if (!$InstallPath) { Write-Warning "InstallPath is empty. Please specify a target install path by using the -InstallPath parameter" return } Write-Verbose "Copying binary to [$InstallPath/$TargetBinary]" try { $AlreadyInstalled = $false if (Test-Path "$InstallPath/$TargetBinary") { (Get-FileHash -Path $binary -Algorithm SHA256).Hash -eq (Get-FileHash -Path "$InstallPath/$TargetBinary" -Algorithm SHA256).Hash } if (!$AlreadyInstalled) { Copy-Item -Path $binary -Destination "$InstallPath/$TargetBinary" -ErrorAction Stop } } catch { Write-Warning "Failed to copy file. $_" Write-Warning "`nPlease run the following command manually `n`n`tsudo cp `"$binary`" `"$InstallPath/$TargetBinary`"" } if ($env:PATH -notlike "*${InstallPath}*") { Write-Warning "The Cumulocity binary has been installed in [$InstallPath] however it is not in your `$PATH variable. This means it will not be accessible from any where in the console. Please add [$InstallPath] to your `$PATH variable" } } Function Invoke-ClientRequest { <# .SYNOPSIS Send a rest request using the c8y .DESCRIPTION Send a custom rest request to Cumulocity using all of the options found on other command lets. This is useful if you are extending PSc8y and want to send custom microservice requests, or send requests which are not yet provided in the PSc8y module. Example: The following function sends a POST request to predefined microservice endpoint. It accepts an input Body argument which will be used in the request. The response is also converted from raw json (string) to Powershell objects so that advanced filtering can be done on the response (i.e. using `Where-Object`) ```powershell Function Invoke-MyMicroserviceEndpoint { [cmdletbinding( SupportsShouldProcess = $true )] Param( [hashtable] $Body ) $options = @{ Method = "POST" Uri = "/service/mymicroservice" Data = $Body # Add these to support -WhatIf and -Verbose parameters WhatIfPreference = $WhatIfPreference ` VerbosePreference = $VerbosePreference } # Send request $response = Invoke-ClientRequest @options # Convert response from json to Powershell objects ConvertFrom-Json $response -Depth 100 } ``` .EXAMPLE Invoke-ClientRequest -Uri "/inventory/managedObjects" -Method "post" -Data "name=test" Create a new managed object with the name "test" .EXAMPLE Invoke-ClientRequest -Uri "/alarm/alarms" -QueryParameters @{ pageSize = "100" } Get a list of alarms with page size of 100 .EXAMPLE Invoke-ClientRequest -Uri "/alarm/alarms?pageSize=100" Get a list of alarms with page size of 100 .EXAMPLE Invoke-ClientRequest -Uri "/inventory/managedObjects" -Method "post" -Data "name=test" -Headers @{ Custom-Value = "myValue"} Create a new managed object but add a custom accept header value #> [cmdletbinding( SupportsShouldProcess = $true, ConfirmImpact = "None")] Param( # Uri (or partial uri). i.e. /application/applications [Parameter( Mandatory = $true, Position = 0)] [string] $Uri, # Rest Method. Defaults to GET [ValidateSet("GET", "POST", "DELETE", "PUT", "HEAD")] [Microsoft.PowerShell.Commands.WebRequestMethod] $Method = 'GET', # Request body [object] $Data, # Add custom headers to the rest request [hashtable] $Headers, # Input file to be uploaded as FormData [string] $InFile, # Uri query parameters [hashtable] $QueryParameters, # (Body) Content Type [string] $ContentType, # Accept header [string] $Accept, # Ignore the accept header [switch] $IgnoreAcceptHeader, # Timeout in seconds [Parameter()] [double] $TimeoutSec, # Pretty print json response [Parameter()] [switch] $Pretty, # Include raw response including pagination information [Parameter()] [switch] $Raw, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session, # HostName to use which overrides the given host [string] $HostName, # Allow loading Cumulocity session setting from environment variables [Parameter()] [switch] $UseEnvironment ) $c8y = Get-ClientBinary $c8yargs = New-Object System.Collections.ArrayList $null = $c8yargs.Add("rest") if ($Method) { $null = $c8yargs.Add($Method) } if ($null -ne $QueryParameters) { $queryparams = New-Object System.Collections.ArrayList foreach ($key in $QueryParameters.Keys) { $value = $QueryParameters[$key] if ($value) { $null = $queryparams.Add("${key}=${value}") } } if ($queryparams.Count -gt 0) { $str = $queryparams -join "&" if ($Uri.Contains("?")) { # uri already has some query parameters, so just append the new one to it $Uri = $Uri + "&" + $str } else { $Uri = $Uri + "?" + $str } } } $null = $c8yargs.Add($Uri) if ($null -ne $Data) { if ($Data -is [string]) { if (Test-Json -InputObject $Data -WarningAction SilentlyContinue) { $null = $c8yargs.AddRange(@("--data", (ConvertTo-JsonArgument $Data))) } else { # allow shortform strings (intepreted by c8y cli tool) $null = $c8yargs.AddRange(@("--data", $Data)) } } else { # Convert hashtables, psobject etc. $null = $c8yargs.AddRange(@("--data", (ConvertTo-JsonArgument $Data))) } } if ($null -ne $Headers) { foreach ($key in $Headers.Keys) { $null = $c8yargs.AddRange(@("-H=`"{0}: {1}`"" -f $key, $Headers[$key])) } } if (-not [string]::IsNullOrEmpty($ContentType)) { $null = $c8yargs.AddRange(@("--contentType", $ContentType)) } if (-not [string]::IsNullOrEmpty($Accept)) { $null = $c8yargs.AddRange(@("--accept", $Accept)) } if ($IgnoreAcceptHeader) { $null = $c8yargs.Add("--ignoreAcceptHeader") } if ($HostName) { $null = $c8yargs.AddRange(@("--host", $HostName)) } if ($TimeoutSec) { # Convert to milliseconds (cast to an integer) [int] $TimeoutInMS = $TimeoutSec * 1000 $null = $c8yargs.AddRange(@("--timeout", $TimeoutInMS)) } if ($InFile) { $null = $c8yargs.AddRange(@("--file", $InFile)) } if ($OutputFile) { $null = $c8yargs.AddRange(@("--outputFile", $OutputFile)) } if ($Raw) { $null = $c8yargs.Add("--raw") } if ($Session) { $null = $c8yargs.AddRange(@("--session", $Session)) } if ($UseEnvironment) { $null = $c8yargs.Add("--useEnv") } if ($NoProxy) { $null = $c8yargs.Add("--noProxy") } $null = $c8yargs.Add("--pretty={0}" -f $Pretty.ToString().ToLower()) if ($VerbosePreference) { $null = $c8yargs.Add("--verbose") } if ($WhatIfPreference) { $null = $c8yargs.Add("--dry") } Write-Verbose ("{0} {1}" -f $c8y, ($c8yargs -join " ")) & $c8y $c8yargs } Function New-HostedApplication { <# .SYNOPSIS New hosted (web) application .DESCRIPTION Create a new hosted web application by uploading a zip file which contains a web application .EXAMPLE New-HostedApplication -Name $App.id -File "myapp.zip" Upload application zip file containing the web application #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # File or Folder of the web application. It should contains a index.html file in the root folder/ or zip file (required) [Parameter(Mandatory = $false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [Alias("FullName")] [Alias("Path")] [string] $File, # File to be uploaded as a binary [Parameter(Mandatory = $false)] [string] $Name, # Shared secret of application. Defaults to the application name with a "-application-key" suffix if not provided. [Parameter(Mandatory = $false)] [string] $Key, # contextPath of the hosted application. Defaults to the application name if not provided. [Parameter(Mandatory = $false)] [string] $ContextPath, # URL to application base directory hosted on an external server. Required when application type is HOSTED [Parameter()] [string] $ResourcesUrl, # Access level for other tenants. Possible values are : MARKET, PRIVATE (default) [Parameter()] [ValidateSet('MARKET','PRIVATE')] [string] $Availability, # Don't uploaded the web app binary. Only the application placeholder will be created [Parameter()] [switch] $SkipUpload, # Don't subscribe to the application after it has been created and uploaded [Parameter()] [switch] $SkipActivation, # 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 { # # Set defaults if (!$Key) { $Key = $Name } if (!$ContextPath) { $ContextPath = $Name } $Parameters = @{} if ($PSBoundParameters.ContainsKey("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Availability")) { $Parameters["availability"] = $Availability } if ($PSBoundParameters.ContainsKey("ContextPath")) { $Parameters["contextPath"] = $ContextPath } if ($PSBoundParameters.ContainsKey("ResourcesUrl")) { $Parameters["resourcesUrl"] = $ResourcesUrl } if ($PSBoundParameters.ContainsKey("SkipActivation")) { $Parameters["skipActivation"] = $SkipActivation.ToString().ToLower() } if ($PSBoundParameters.ContainsKey("SkipUpload")) { $Parameters["skipUpload"] = $SkipUpload.ToString().ToLower() } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { # Set empty array if no file was provided (so it still uses the loop, but ignores the file) if (!$File) { $File = @("") } foreach ($item in $File) { if ($item) { $Parameters["file"] = (Resolve-Path $item).ProviderPath } if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "applications" ` -Verb "createHostedApplication" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } Function New-Microservice { <# .SYNOPSIS New microservice .DESCRIPTION Create a new microservice or upload a new microservice binary to an already running microservice. By default the microservice will also be subscribed to/enabled. The zip file needs to follow the Cumulocity Microservice format. This cmdlet has several operations .EXAMPLE PS> New-Microservice -File "myapp.zip" Upload microservice binary. The name of the microservice will be named after the zip file name (without the extension) If the microservice already exists, then the only the microservice binary will be updated. .EXAMPLE PS> New-Microservice -Name "myapp" -File "myapp.zip" Upload microservice binary with a custom name. Note: If the microservice already exists in the platform .EXAMPLE PS> New-Microservice -Name "myapp" -File "./cumulocity.json" -SkipUpload Create a microservice placeholder named "myapp" for use for local development of a microservice. The `-File` parameter is provided with the microserivce's manifest file `cumulocity.json` to set the correct required roles of the bootstrap user which will be automatically created by Cumulocity. The microservice's bootstrap credentials can be retrieved using `Get-MicroserviceBootstrapUser` cmdlet. This example is usefuly for local development only, when you want to run the microservice locally (not hosted in Cumulocity). #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # File to be uploaded as a binary (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $File, # Name of the microservice. An id is also accepted however the name have been previously uploaded. [Parameter(Mandatory = $false)] [string] $Name, # Access level for other tenants. Possible values are : MARKET, PRIVATE (default) [Parameter()] [ValidateSet('MARKET','PRIVATE')] [string] $Availability, # ContextPath of the hosted application. Required when application type is HOSTED [Parameter()] [string] $ContextPath, # URL to application base directory hosted on an external server. Required when application type is HOSTED [Parameter()] [string] $ResourcesUrl, # Skip the uploading of the microservice binary. This is helpful if you want to run the microservice locally # and you only need the microservice place holder in order to create microservice bootstrap credentials. [Parameter()] [switch] $SkipUpload, # Don't subscribe to the microservice after it has been created and uploaded [Parameter()] [switch] $SkipSubscription, # 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("Name")) { $Parameters["name"] = $Name } if ($PSBoundParameters.ContainsKey("Availability")) { $Parameters["availability"] = $Availability } if ($PSBoundParameters.ContainsKey("ContextPath")) { $Parameters["contextPath"] = $ContextPath } if ($PSBoundParameters.ContainsKey("ResourcesUrl")) { $Parameters["resourcesUrl"] = $ResourcesUrl } if ($PSBoundParameters.ContainsKey("SkipUpload")) { $Parameters["skipUpload"] = $SkipUpload.ToString().ToLower() } if ($PSBoundParameters.ContainsKey("SkipSubscription")) { $Parameters["skipSubscription"] = $SkipSubscription.ToString().ToLower() } 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 $File) { $Parameters["file"] = $item if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "microservices" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } Function New-RandomPassword { <# .SYNOPSIS Create pseudo random password .DESCRIPTION Create a random password which can be used for one-time passwords if the the password reset functionilty in Cumulocity is not available. .EXAMPLE New-RandomPassword C&3SX6Kn Generate one password with a length between 8 and 12 chars. .EXAMPLE New-RandomPassword -MinPasswordLength 8 -MaxPasswordLength 12 -Count 4 7d&5cnaB !Bh776T"Fw 9"C"RxKcY %mtM7#9LQ9h Generate four passwords, each with a length of between 8 and 12 chars. .EXAMPLE New-RandomPassword -InputStrings abc, ABC, 123 -PasswordLength 4 3ABa Generate a password with a length of 4 containing atleast one char from each InputString .EXAMPLE New-RandomPassword -InputStrings abc, ABC, 123 -PasswordLength 4 -FirstChar abcdefghijkmnpqrstuvwxyzABCEFGHJKLMNPQRSTUVWXYZ 3ABa Generates a password with a length of 4 containing atleast one char from each InputString that will start with a letter from the string specified with the parameter FirstChar .OUTPUTS [String] .FUNCTIONALITY Generates random passwords .LINK http://blog.simonw.se/powershell-generating-random-password-for-active-directory/ #> [CmdletBinding( DefaultParameterSetName = 'FixedLength', ConfirmImpact = 'None')] [OutputType([String])] Param ( # Specifies minimum password length [Parameter(Mandatory = $false, ParameterSetName = 'RandomLength')] [ValidateScript( { $_ -gt 0 })] [Alias('Min')] [int]$MinPasswordLength = 12, # Specifies maximum password length [Parameter(Mandatory = $false, ParameterSetName = 'RandomLength')] [ValidateScript( { if ($_ -ge $MinPasswordLength) { $true } else { Throw 'Max value cannot be lesser than min value.' } })] [Alias('Max')] [int]$MaxPasswordLength = 20, # Specifies a fixed password length [Parameter(Mandatory = $false, ParameterSetName = 'FixedLength')] [ValidateRange(1, 2147483647)] [int]$PasswordLength = 12, # Specifies an array of strings containing charactergroups from which the password will be generated. # At least one char from each group (string) will be used. [String[]]$InputStrings = @('abcdefghijkmnpqrstuvwxyz', 'ABCEFGHJKLMNPQRSTUVWXYZ', '123456789', '!#%()[]*+-_;,.'), # Specifies a string containing a character group from which the first character in the password will be generated. # Useful for systems which requires first char in password to be alphabetic. [String] $FirstChar, # Specifies number of passwords to generate. [ValidateRange(1, 2147483647)] [int]$Count = 1 ) Begin { Function Get-Seed { # Generate a seed for randomization $RandomBytes = New-Object -TypeName 'System.Byte[]' 4 $Random = New-Object -TypeName 'System.Security.Cryptography.RNGCryptoServiceProvider' $Random.GetBytes($RandomBytes) [BitConverter]::ToUInt32($RandomBytes, 0) } } Process { For ($iteration = 1; $iteration -le $Count; $iteration++) { $Password = @{ } # Create char arrays containing groups of possible chars [char[][]]$CharGroups = $InputStrings # Create char array containing all chars $AllChars = $CharGroups | ForEach-Object { [Char[]]$_ } # Set password length if ($PSCmdlet.ParameterSetName -eq 'RandomLength') { if ($MinPasswordLength -eq $MaxPasswordLength) { # If password length is set, use set length $PasswordLength = $MinPasswordLength } else { # Otherwise randomize password length $PasswordLength = ((Get-Seed) % ($MaxPasswordLength + 1 - $MinPasswordLength)) + $MinPasswordLength } } # If FirstChar is defined, randomize first char in password from that string. if ($PSBoundParameters.ContainsKey('FirstChar')) { $Password.Add(0, $FirstChar[((Get-Seed) % $FirstChar.Length)]) } # Randomize one char from each group Foreach ($Group in $CharGroups) { if ($Password.Count -lt $PasswordLength) { $Index = Get-Seed While ($Password.ContainsKey($Index)) { $Index = Get-Seed } $Password.Add($Index, $Group[((Get-Seed) % $Group.Count)]) } } # Fill out with chars from $AllChars for ($i = $Password.Count; $i -lt $PasswordLength; $i++) { $Index = Get-Seed While ($Password.ContainsKey($Index)) { $Index = Get-Seed } $Password.Add($Index, $AllChars[((Get-Seed) % $AllChars.Count)]) } Write-Output -InputObject $( -join ($Password.GetEnumerator() | Sort-Object -Property Name | Select-Object -ExpandProperty Value)) } } } Function New-RandomString { <# .SYNOPSIS Create a random string .DESCRIPTION Helper utility to quickly create a randomized string which can be used when adding unique names to devices or another other properties Note: It should not be used for encryption! .EXAMPLE New-RandomString -Prefix "hello_" Create a random string with the "hello" prefix. i.e `hello_jta6fzwvo7` .EXAMPLE New-RandomString -Postfix "_device" Create a random string which ends with "_device", i.e. `1qs7mc2o3t_device` #> [cmdletbinding()] Param( # Prefix to be added before the random string [string] $Prefix, # Postfix to be added after the random string [string] $Postfix ) $RandomPart = -join ((48..57) + (97..122) | Get-Random -Count 10 | ForEach-Object { [char]$_ }) Write-Output "${Prefix}${RandomPart}${Postfix}" } Function New-Session { <# .SYNOPSIS Create a new Cumulocity Session .DESCRIPTION Create a new Cumulocity session which can be used by the cmdlets. The new session will be automatically activated. .EXAMPLE New-Session -Name "develop" -Host "https://my-tenant-name.eu-latest.cumulocity.com" -Tenant "t12345" Create a new Cumulocity session .OUTPUTS None #> [CmdletBinding()] Param( # Name of the Cumulocity session [Parameter(Mandatory = $true)] [string] $Name, # Host url, i.e. https://my-tenant-name.eu-latest.cumulocity.com [Parameter(Mandatory = $true)] [string] $Host, # Tenant id, i.e. t12345 [Parameter(Mandatory = $true)] [string] $Tenant, # Credential [Parameter(Mandatory = $false, ParameterSetName = 'manual')] [ValidateNotNull()] [System.Management.Automation.PSCredential] [System.Management.Automation.Credential()] $Credential = [System.Management.Automation.PSCredential]::Empty, # Description [Parameter(Mandatory = $false)] [string] $Description, # Don't use tenant name as a prefix to the user name when using Basic Authentication [Parameter(Mandatory = $false)] [switch] $NoTenantPrefix ) $Binary = Get-ClientBinary if (!$Credential -or ($Credential -eq [System.Management.Automation.PSCredential]::Empty)) { $Credential = Get-Credential -Message "Enter the API credentials for the $Tenant C8Y Tenant (leave-out the the tenant prefix)" -ErrorAction SilentlyContinue } if (!$Credential.UserName -or !$Credential.GetNetworkCredential().Password) { Write-Warning "Credentials are required to create a Cumulocity session" return } $c8yargs = New-object System.Collections.ArrayList $null = $c8yargs.AddRange(@("sessions", "create")) if ($Name) { $null = $c8yargs.AddRange(@("--name", $Name)) } if ($Host) { $null = $c8yargs.AddRange(@("--host", $Host)) } if ($Tenant) { $null = $c8yargs.AddRange(@("--tenant", $Tenant)) } if ($Credential.GetNetworkCredential().Username) { $null = $c8yargs.AddRange(@("--username", $Credential.GetNetworkCredential().Username)) } if ($Credential.GetNetworkCredential().Password) { $null = $c8yargs.AddRange(@("--password", $Credential.GetNetworkCredential().Password)) } if ($Description) { $null = $c8yargs.AddRange(@("--description", $Description)) } if ($NoTenantPrefix.IsPresent) { $null = $c8yargs.AddRange("--noTenantPrefix={0}" -f $NoTenantPrefix.ToString().ToLower()) } $Path = & $Binary $c8yargs Set-Session -File $Path } Function New-TestAgent { <# .SYNOPSIS Create a new test agent representation in Cumulocity .DESCRIPTION Create a new test agent with a randomized name. Useful when performing mockups or prototyping. The agent will have both the `c8y_IsDevice` and `com_cumulocity_model_Agent` fragments set. .EXAMPLE New-TestAgent Create a test agent .EXAMPLE 1..10 | Foreach-Object { New-TestAgent -Force } Create 10 test agents all with unique names #> [cmdletbinding()] Param( # Agent name prefix which is added before the randomized string [Parameter( Mandatory = $false, Position = 0 )] [string] $Name = "testagent", # Don't prompt for confirmation [switch] $Force ) $Data = @{ c8y_IsDevice = @{} com_cumulocity_model_Agent = @{} } $AgentName = New-RandomString -Prefix "${Name}_" $TestAgent = PSc8y\New-ManagedObject ` -Name $AgentName ` -Data $Data ` -Force:$Force $TestAgent } Function New-TestAlarm { <# .SYNOPSIS Create a new test alarm .DESCRIPTION Create a test alarm for a device. If the device is not provided then a test device will be created automatically .EXAMPLE New-TestAlarm Create a new test device and then create an alarm on it .EXAMPLE New-TestAlarm -Device "myExistingDevice" Create an alarm on the existing device "myExistingDevice" #> [cmdletbinding()] Param( # Device id, name or object. If left blank then a randomized device will be created [Parameter( Mandatory = $false, Position = 0 )] [object] $Device, # Don't prompt for confirmation [switch] $Force ) if ($null -ne $Device) { $iDevice = Expand-Device $Device } else { $iDevice = PSc8y\New-TestDevice -Force:$Force } PSc8y\New-Alarm ` -Device $iDevice.id ` -Time "1970-01-01" ` -Type "c8y_ci_TestAlarm" ` -Severity MAJOR ` -Text "Test CI Alarm" ` -Force:$Force } Function New-TestDevice { <# .SYNOPSIS Create a new test device representation in Cumulocity .DESCRIPTION Create a new test device with a randomized name. Useful when performing mockups or prototyping. The agent will have both the `c8y_IsDevice` fragments set. .EXAMPLE New-TestDevice Create a test device .EXAMPLE 1..10 | Foreach-Object { New-TestDevice -Force } Create 10 test devices all with unique names .EXAMPLE 1..10 | Foreach-Object { New-TestDevice -AsAgent -Force } Create 10 test devices (with agent functionality) all with unique names #> [cmdletbinding( SupportsShouldProcess = $true, ConfirmImpact = "High" )] Param( # Device name prefix which is added before the randomized string [Parameter( Mandatory = $false, Position = 0 )] [string] $Name = "testdevice", # Add agent fragment to the device [switch] $AsAgent, # Don't prompt for confirmation [switch] $Force ) $Data = @{ c8y_IsDevice = @{} } if ($AsAgent) { $Data.com_cumulocity_model_Agent = @{} } $DeviceName = New-RandomString -Prefix "${Name}_" $TestDevice = PSc8y\New-ManagedObject ` -Name $DeviceName ` -Data $Data ` -Force $TestDevice } Function New-TestDeviceGroup { <# .SYNOPSIS Create a new test device group .DESCRIPTION Create a new test device group with a randomized name. Useful when performing mockups or prototyping. .EXAMPLE New-TestDeviceGroup Create a test device group .EXAMPLE 1..10 | Foreach-Object { New-TestDeviceGroup -Force } Create 10 test device groups all with unique names #> [cmdletbinding()] Param( # Device group name prefix which is added before the randomized string [Parameter( Mandatory = $false, Position = 0 )] [string] $Name = "testgroup", # Group type. Only device groups of type `Group` are visible as root folders in the UI [ValidateSet("Group", "SubGroup")] [string] $Type = "Group", # Don't prompt for confirmation [switch] $Force ) $Data = @{ c8y_IsDeviceGroup = @{ } } switch ($Type) { "SubGroup" { $Data.type = "c8y_DeviceSubGroup" break; } default { $Data.type = "c8y_DeviceGroup" break; } } $GroupName = New-RandomString -Prefix "${Name}_" PSc8y\New-ManagedObject ` -Name $GroupName ` -Data $Data ` -Force:$Force } Function New-TestEvent { <# .SYNOPSIS Create a new test event .DESCRIPTION Create a test event for a device. If the device is not provided then a test device will be created automatically .EXAMPLE New-TestEvent Create a new test device and then create an event on it .EXAMPLE New-TestEvent -Device "myExistingDevice" Create an event on the existing device "myExistingDevice" #> [cmdletbinding()] Param( # Device id, name or object. If left blank then a randomized device will be created [Parameter( Mandatory = $false, Position = 0 )] [object] $Device, # Add a dummy file to the event [switch] $WithBinary, # Don't prompt for confirmation [switch] $Force ) if ($null -ne $Device) { $iDevice = Expand-Device $Device } else { $iDevice = PSc8y\New-TestDevice -Force:$Force } $c8yEvent = PSc8y\New-Event ` -Device $iDevice.id ` -Time "1970-01-01" ` -Type "c8y_ci_TestEvent" ` -Text "Test CI Event" ` -Force:$Force if ($WithBinary) { $tempfile = New-TemporaryFile "Cumulocity test content" | Out-File -LiteralPath $tempfile $null = PSc8y\New-EventBinary ` -Id $c8yEvent.id ` -File $tempfile ` -Force:$Force Remove-Item $tempfile } $c8yEvent } Function New-TestFile { <# .SYNOPSIS Create a new temp file with default contents .DESCRIPTION Create a temporary file with some contents which can be used to uploaded it to Cumulocity via the Binary api. .EXAMPLE New-TestFile Create a temp file with pre-defined content .EXAMPLE "My custom text info" | New-TestFile Create a temp file with customized content. .OUTPUTS System.IO.FileInfo #> Param( # Content which should be written to the temporary file [Parameter( ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Position = 0 )] [object] $InputObject = "example message" ) $TempFile = New-TemporaryFile $InputObject | Out-File -LiteralPath $TempFile.FullName -Encoding utf8 $TempFile } Function New-TestGroup { <# .SYNOPSIS Create a test user group .DESCRIPTION Create a new test user group using a random name .EXAMPLE New-TestGroup -Name mygroup Create a new user group with the prefix "mygroup". A random postfix will be added to it #> [cmdletbinding()] Param( # Name of the user group. A random postfix will be added to it to make it unique [Parameter( Mandatory = $false, Position = 0 )] [string] $Name = "testgroup", # Don't prompt for confirmation [switch] $Force ) $GroupName = New-RandomString -Prefix "${Name}_" $TestGroup = PSc8y\New-Group -Name $GroupName -Force:$Force $TestGroup } Function New-TestMeasurement { <# .SYNOPSIS Create a new test measurement .DESCRIPTION Create a test measurement for a device. If the device is not provided then a test device will be created automatically .EXAMPLE New-TestMeasurement Create a new test device and then create a measurement on it .EXAMPLE New-TestMeasurement -Device "myExistingDevice" Create a measurement on the existing device "myExistingDevice" #> [cmdletbinding( SupportsShouldProcess = $true, ConfirmImpact = "None" )] Param( # Device id, name or object. If left blank then a randomized device will be created [object] $Device, # Value fragment type [string] $ValueFragmentType = "c8y_Temperature", # Value fragment series [string] $ValueFragmentSeries = "T", # Type [string] $Type = "C8yTemperatureReading", # Value [Double] $Value = 1.2345, # Unit. i.e. °C, m/s [string] $Unit = "°C", # Don't prompt for confirmation [switch] $Force ) if ($null -eq $Device) { $iDevice = PSc8y\New-TestDevice -WhatIf:$false -Force:$Force } else { $iDevice = PSc8y\Expand-Device $Device } PSc8y\New-Measurement ` -Device $iDevice.id ` -Time "1970-01-01" ` -Type $Type ` -Data @{ $ValueFragmentType = @{ $ValueFragmentSeries = @{ value = $Value unit = $Unit } } } ` -Force:$Force } Function New-TestOperation { <# .SYNOPSIS Create a new test operation .DESCRIPTION Create a test operation for a device. If the device is not provided then a test device will be created automatically .EXAMPLE New-TestOperation Create a new test device and then create an operation on it .EXAMPLE New-TestOperation -Device "myExistingDevice" Create an operation on the existing device "myExistingDevice" #> [cmdletbinding()] Param( # Device id, name or object. If left blank then a randomized device will be created [Parameter( Mandatory = $false, Position = 0 )] [object] $Device, # Don't prompt for confirmation [switch] $Force ) if ($null -ne $Device) { $iAgent = Expand-Device $Device } else { $iAgent = PSc8y\New-TestAgent -Force:$Force } PSc8y\New-Operation ` -Device $iAgent.id ` -Description "Test operation" ` -Data @{ c8y_Restart = @{ parameters = @{ } } } ` -Force:$Force } Function New-TestUser { <# .SYNOPSIS Create a new test user .DESCRIPTION Create a user with a randomized username .EXAMPLE New-TestUser Create a new test user .EXAMPLE New-TestUser -Name "myExistingDevice" Create a new test user with a custom username prefix #> [cmdletbinding()] Param( # Name of the username. A random postfix will be added to it to make it unique [Parameter( Mandatory = $false, Position = 0 )] [string] $Name = "testuser", # Don't prompt for confirmation [switch] $Force ) $Username = New-RandomString -Prefix "${Name}_" PSc8y\New-User -UserName $Username -Password (New-RandomString) -Force:$Force } Function Open-Website { <# .SYNOPSIS Open a browser to the cumulocity website .DESCRIPTION Opens the default web browser to the Cumulocity application or directly to a device page in the Device Management application .EXAMPLE Open-Website -Application "cockpit" Open the cockpit application .EXAMPLE Open-Website -Device myDevice01 Open the devicemanagement to the device (default) control page for myDevice01 .EXAMPLE Open-Website -Device myDevice01 -Page alarms Open the devicemanagement to the device alarm page for myDevice01 #> [cmdletbinding( DefaultParameterSetName="Device" )] Param( # Application to open [ValidateSet("cockpit", "administration", "devicemanagement", "fieldbus4")] [Parameter( ParameterSetName="Application", Position=0 )] [string] $Application = "cockpit", # Name of the device to open in devicemanagement. Only the first matching device will be used to open the c8y website. [Parameter( ParameterSetName="Device", Position=0, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true )] [object[]] $Device, # Device page to open [Parameter( ParameterSetName="Device", Position=1 )] [ValidateSet("device-info", "measurements", "alarms", "control", "events", "service_monitoring", "identity")] [string] $Page = "control", # Browser to use to open the webpage [ValidateSet("chrome", "firefox", "ie", "edge")] [string] $Browser = "chrome" ) Process { switch ($PSCmdlet.ParameterSetName) { "Application" { $Url = "/apps/{0}/index.html" -f $Application break; } "Device" { $DeviceInfo = Expand-Device $Device | Select-Object -First 1 if (!$DeviceInfo) { Write-Error "Could not find a matching devices to [$Device]" return; } $Url = "/apps/devicemanagement/index.html#/device/{0}/{1}" -f @($DeviceInfo.id, $Page) break; } } # todo: add expand uri function to c8y binary $Url = (Get-C8ySessionProperty -Name "host") + $Url # Print a link to the console, so the user can click on it Write-Host "Open page: $Url" -ForegroundColor Gray switch ($Browser) { "ie" { # Open the url in the default browser...for the people who use Internet Explorer # it is most likely still their default browser so it should work. $null = Start-Process $Url -PassThru } "edge" { $null = Start-Process "microsoft-edge:$Url" -PassThru -ErrorAction SilentlyContinue } Default { $null = Start-Process $Browser $Url -PassThru } } } } Function Register-Alias { <# .SYNOPSIS Register aliases for commonly used cmdlets within the PSc8y module .DESCRIPTION Registers the aliases for quicker access to the PSc8y cmdlets. Additional aliases can be created by using the in-built Powershell `New-Alias` cmdlet. .EXAMPLE Register-Alias .LINK Unregister-Alias #> [cmdletbinding()] Param() $Aliases = $script:Aliases foreach ($Alias in $Aliases.Keys) { $Value = $Aliases[$Alias] if ($Value -is [string]) { Set-Alias -Name $Alias -Value $Aliases[$Alias] -Scope "Global" } } } Function Set-ClientConsoleSetting { <# .SYNOPSIS Set console settings to be used by the cli tool .DESCRIPTION Sensitive information: When using -HideSensitive, the following information will be obfuscated when shown on the console (tenant, username, password, base64 credentials) .EXAMPLE Set-ClientConsoleSetting -HideSensitive Hide any sensitive session information on the console. Settings like (tenant, username, password, base64 credentials) #> [cmdletbinding()] Param( # Hide all sensitive session information (tenant, username, password, base64 encoded passwords etc.) [switch] $HideSensitive, # Show sensitive information (excepts clear-text passwords) [switch] $ShowSensitive ) if ($ShowSensitive) { Write-Host "Sensitive session information will be visible (except clear-text passwords)" -ForegroundColor Gray $env:C8Y_LOGGER_HIDE_SENSITIVE = $false } if ($HideSensitive) { Write-Host "Sensitive session information will be hidden" -ForegroundColor Gray $env:C8Y_LOGGER_HIDE_SENSITIVE = $true } } Function Set-Session { <# .SYNOPSIS Set/activate a Cumulocity Session. .DESCRIPTION By default the user will be prompted to select from Cumulocity sessions found in their home folder under .cumulocity Filtering the list is always "customer dev" will be split in to two search terms, "customer" and "dev", and only results which contain these two search terms will be includes in the results. The search is applied to the following fields of the session: * index * filename (basename only) * host * tenant * username .EXAMPLE Set-Session Prompt for a list of Cumulocity sessions to select from .EXAMPLE Set-Session customer Set a session interactively but only include sessions where the details contain "customer" in any of the fields .EXAMPLE Set-Session customer, dev Set a session interactively but only includes session where the details includes "customer" and "dev" in any of the fields .OUTPUTS String #> [CmdletBinding( DefaultParameterSetName = "ByInteraction" )] Param( # File containing the Cumulocity session data [Parameter(Mandatory=$false, Position = 0, ParameterSetName = "ByFile", ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [Alias("FullName")] [string] $File, # Filter list of sessions. Multiple search terms can be provided. A string "Contains" operation # is done to match any of the session fields (except password) [Parameter( ParameterSetName = "ByInteraction", Position = 0 )] [string[]] $Filter, # Allow loading Cumulocity session setting from environment variables [switch] $UseEnvironment ) Process { switch ($PSCmdlet.ParameterSetName) { "ByFile" { $Path = $File } default { $Binary = Get-ClientBinary $c8yargs = New-Object System.Collections.ArrayList $null = $c8yargs.AddRange(@("sessions", "list")) if ($Filter -gt 0) { $SearchTerms = $Filter -join " " $null = $c8yargs.AddRange(@("--sessionFilter", "$SearchTerms")) } if ($UseEnvironment) { $null = $c8yargs.Add("--useEnv") } $Path = & $Binary $c8yargs } } # Format path $Path = Resolve-Path $Path -ErrorAction SilentlyContinue if (!$Path -or !(Test-Path $Path)) { Write-Warning "Invalid path" return } Write-Verbose "Setting new session: $Path" $env:C8Y_SESSION = Resolve-Path $Path # Update environment variables Set-EnvironmentVariablesFromSession Get-Session } } Function Test-Json { <# .SYNOPSIS Test if the input object is a valid json string .DESCRIPTION Test the given input to check if it is most likely valid json. The cmdlet uses a quick json sanity check rather than trying to parse the json to save time. .EXAMPLE Test-Json '{ "name": "tester" }' Returns true if the input data is valid json #> [cmdletbinding()] [OutputType([bool])] Param( # Input data [Parameter( Mandatory = $true, Position = 0, ValueFromPipeline = $true )] [object] $InputObject ) Process { if ($inputObject -isnot [string]) { return $false } if (!(($InputObject -match "^\s*[\[\{]") -and ($InputObject -match "[\]\}]\s*$"))) { Write-Information "Only json array or objects are supported" return $false } $IsValid = $false try { $null = ConvertFrom-Json -InputObject $InputObject -ErrorAction Stop $IsValid = $true } catch { Write-Information "Invalid json: $_" } $IsValid } } Function Unregister-Alias { <# .SYNOPSIS Unregister aliases .DESCRIPTION Unregister any aliases which were registered by the Register-Alias cmdlet .EXAMPLE Unregister-Alias .LINK Register-Alias #> [cmdletbinding()] Param() $Aliases = $script:Aliases foreach ($Alias in $Aliases.Keys) { $Value = $Aliases[$Alias] if ($Value -is [string]) { if (!(Get-Alias -Name $Value -ErrorAction SilentlyContinue)) { Remove-Item -Path Alias:$Alias } } } } Function Wait-Operation { <# .SYNOPSIS Wait for an operation to be completed (i.e. either in the SUCCESS or FAILED status) .DESCRIPTION Wait for an operation to be completed with support for a timeout. Useful when writing scripts which should only proceed once the operation has finished executing. .PARAMETER Id Operation id or object to wait for .PARAMETER TimeoutSec Timeout in seconds. Defaults to 30 seconds. i.e. how long should it wait for the operation to be processed .EXAMPLE Wait-Operation 1234567 Wait for the operation id .EXAMPLE Wait-Operation 1234567 -TimeoutSec 30 Wait for the operation id, and timeout after 30 seconds #> Param( [Parameter( Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Position = 0 )] [string] $Id, [int] $TimeoutSec = 30 ) Process { $ExpirationDate = (Get-Date).AddSeconds($TimeoutSec) do { $op = Get-Operation -Id $id if ($null -eq $op) { # Cancel early if the operation does not exist Write-Warning "Could not find operation" return; } Start-Sleep -Milliseconds 200 $HasExpired = (Get-Date) -ge $ExpirationDate } while (!$HasExpired -and $op.status -notmatch "(FAILED|SUCCESSFUL)" -and $op.id) if ($HasExpired) { Write-Warning "Timeout: Operation is still being processed after $TimeoutSec seconds. Operation: $id" $op return } switch ($op.status) { "FAILED" { Write-Warning ("Operation failed [id={1}]. Reason: {0}" -f $op.id, $op.failureReason) break; } "SUCCESSFUL" { Write-Verbose "Operation was successful" break; } default { throw "Unknown operation status. $($op.status)" } } $op } } Function Watch-Alarm { <# .SYNOPSIS Watch realtime alarms .DESCRIPTION Watch realtime alarms .EXAMPLE PS> Watch-Alarm -Device 12345 Watch all alarms for a device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Start date or date and time of alarm occurrence. (required) [Parameter()] [int] $DurationSec, # End date or date and time of alarm occurrence. [Parameter()] [string] $Count, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DurationSec")) { $Parameters["duration"] = $DurationSec } if ($PSBoundParameters.ContainsKey("Count")) { $Parameters["count"] = $Count } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { $id = PSc8y\Expand-Id $Device if ($id) { $Parameters["device"] = PSc8y\Expand-Id $Device } if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "alarms" ` -Verb "subscribe" ` -Parameters $Parameters ` -Type "application/json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } Function Watch-Event { <# .SYNOPSIS Watch realtime events .DESCRIPTION Watch realtime events .EXAMPLE PS> Watch-Event -Device 12345 Watch all events for a device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Start date or date and time of event occurrence. (required) [Parameter()] [int] $DurationSec, # End date or date and time of event occurrence. [Parameter()] [string] $Count, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DurationSec")) { $Parameters["duration"] = $DurationSec } if ($PSBoundParameters.ContainsKey("Count")) { $Parameters["count"] = $Count } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { $id = PSc8y\Expand-Id $Device if ($id) { $Parameters["device"] = PSc8y\Expand-Id $Device } if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "events" ` -Verb "subscribe" ` -Parameters $Parameters ` -Type "application/json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } Function Watch-ManagedObject { <# .SYNOPSIS Watch realtime managedObjects .DESCRIPTION Watch realtime managedObjects .EXAMPLE PS> Watch-ManagedObject -Device 12345 Watch all managedObjects for a device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Start date or date and time of managedObject occurrence. (required) [Parameter()] [int] $DurationSec, # End date or date and time of managedObject occurrence. [Parameter()] [string] $Count, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DurationSec")) { $Parameters["duration"] = $DurationSec } if ($PSBoundParameters.ContainsKey("Count")) { $Parameters["count"] = $Count } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { $id = PSc8y\Expand-Id $Device if ($id) { $Parameters["device"] = PSc8y\Expand-Id $Device } if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "inventory" ` -Verb "subscribe" ` -Parameters $Parameters ` -Type "application/json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } Function Watch-Measurement { <# .SYNOPSIS Watch realtime measurements .DESCRIPTION Watch realtime measurements .EXAMPLE PS> Watch-Measurement -Device 12345 Watch all measurements for a device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Start date or date and time of measurement occurrence. (required) [Parameter()] [int] $DurationSec, # End date or date and time of measurement occurrence. [Parameter()] [string] $Count, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DurationSec")) { $Parameters["duration"] = $DurationSec } if ($PSBoundParameters.ContainsKey("Count")) { $Parameters["count"] = $Count } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { $id = PSc8y\Expand-Id $Device if ($id) { $Parameters["device"] = PSc8y\Expand-Id $Device } if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "measurements" ` -Verb "subscribe" ` -Parameters $Parameters ` -Type "application/json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } Function Watch-Notification { <# .SYNOPSIS Watch realtime notifications .DESCRIPTION Watch realtime notifications .EXAMPLE PS> Watch-Notification -Channel "/measurements/*" -DurationSec 90 Watch all measurements for 90 seconds #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter( Mandatory = $true)] [string] $Channel, # Start date or date and time of notification occurrence. (required) [Parameter()] [int] $DurationSec, # End date or date and time of notification occurrence. [Parameter()] [string] $Count, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Channel")) { $Parameters["channel"] = $Channel } if ($PSBoundParameters.ContainsKey("DurationSec")) { $Parameters["duration"] = $DurationSec } if ($PSBoundParameters.ContainsKey("Count")) { $Parameters["count"] = $Count } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "realtime" ` -Verb "subscribe" ` -Parameters $Parameters ` -Type "application/json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } Function Watch-NotificationChannels { <# .SYNOPSIS Watch realtime device notifications .DESCRIPTION Watch realtime device notifications .EXAMPLE PS> Function Watch-NotificationChannels -Device 12345 -DurationSec 90 Watch all types of notifications for a device for 90 seconds #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Start date or date and time of notification occurrence. (required) [Parameter()] [int] $DurationSec, # End date or date and time of notification occurrence. [Parameter()] [string] $Count, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Channel")) { $Parameters["channel"] = $Channel } if ($PSBoundParameters.ContainsKey("DurationSec")) { $Parameters["duration"] = $DurationSec } if ($PSBoundParameters.ContainsKey("Count")) { $Parameters["count"] = $Count } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { $id = PSc8y\Expand-Id $Device if ($id) { $Parameters["device"] = PSc8y\Expand-Id $Device } if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "realtime" ` -Verb "subscribeAll" ` -Parameters $Parameters ` -Type "application/json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } Function Watch-Operation { <# .SYNOPSIS Watch realtime operations .DESCRIPTION Watch realtime operations .EXAMPLE PS> Watch-Operation -Device 12345 Watch all operations for a device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Device ID [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Device, # Start date or date and time of operation occurrence. (required) [Parameter()] [int] $DurationSec, # End date or date and time of operation occurrence. [Parameter()] [string] $Count, # Outputfile [Parameter()] [string] $OutputFile, # NoProxy [Parameter()] [switch] $NoProxy, # Session path [Parameter()] [string] $Session ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("DurationSec")) { $Parameters["duration"] = $DurationSec } if ($PSBoundParameters.ContainsKey("Count")) { $Parameters["count"] = $Count } if ($PSBoundParameters.ContainsKey("OutputFile")) { $Parameters["outputFile"] = $OutputFile } if ($PSBoundParameters.ContainsKey("NoProxy")) { $Parameters["noProxy"] = $NoProxy } if ($PSBoundParameters.ContainsKey("Session")) { $Parameters["session"] = $Session } } Process { $id = PSc8y\Expand-Id $Device if ($id) { $Parameters["device"] = PSc8y\Expand-Id $Device } if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-ClientCommand ` -Noun "operations" ` -Verb "subscribe" ` -Parameters $Parameters ` -Type "application/json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } #endregion Export-ModuleMember -Function Add-AssetToGroup,Add-ChildDeviceToDevice,Add-ChildGroupToGroup,Add-DeviceToGroup,Add-RoleToGroup,Add-RoleToUser,Add-UserToGroup,Approve-DeviceRequest,Copy-Application,Disable-Application,Disable-Microservice,Enable-Application,Enable-Microservice,Get-Agent,Get-Alarm,Get-AlarmCollection,Get-AllTenantUsageSummaryStatistics,Get-Application,Get-ApplicationBinaryCollection,Get-ApplicationCollection,Get-ApplicationReferenceCollection,Get-AuditRecord,Get-AuditRecordCollection,Get-Binary,Get-BinaryCollection,Get-ChildAssetCollection,Get-ChildAssetReference,Get-ChildDeviceCollection,Get-ChildDeviceReference,Get-CurrentApplication,Get-CurrentApplicationSubscription,Get-CurrentTenant,Get-CurrentUser,Get-CurrentUserInventoryRole,Get-CurrentUserInventoryRoleCollection,Get-DataBrokerConnector,Get-DataBrokerConnectorCollection,Get-Device,Get-DeviceGroup,Get-DeviceRequest,Get-DeviceRequestCollection,Get-Event,Get-EventBinary,Get-EventCollection,Get-ExternalId,Get-ExternalIdCollection,Get-Group,Get-GroupByName,Get-GroupCollection,Get-GroupMembershipCollection,Get-ManagedObject,Get-ManagedObjectCollection,Get-Measurement,Get-MeasurementCollection,Get-MeasurementSeries,Get-Microservice,Get-MicroserviceBootstrapUser,Get-MicroserviceCollection,Get-Operation,Get-OperationCollection,Get-RetentionRule,Get-RetentionRuleCollection,Get-RoleCollection,Get-RoleReferenceCollectionFromGroup,Get-RoleReferenceCollectionFromUser,Get-SupportedMeasurements,Get-SupportedOperations,Get-SupportedSeries,Get-SystemOption,Get-SystemOptionCollection,Get-Tenant,Get-TenantCollection,Get-TenantOption,Get-TenantOptionCollection,Get-TenantOptionForCategory,Get-TenantStatisticsCollection,Get-TenantUsageSummaryStatistics,Get-TenantVersion,Get-User,Get-UserByName,Get-UserCollection,Get-UserMembershipCollection,New-Agent,New-Alarm,New-Application,New-ApplicationBinary,New-AuditRecord,New-Binary,New-Device,New-DeviceGroup,New-Event,New-EventBinary,New-ExternalId,New-Group,New-ManagedObject,New-Measurement,New-MicroserviceBinary,New-Operation,New-RetentionRule,New-Tenant,New-TenantOption,New-User,Register-Device,Remove-Agent,Remove-AlarmCollection,Remove-Application,Remove-AssetFromGroup,Remove-Binary,Remove-ChildDeviceFromDevice,Remove-Device,Remove-DeviceFromGroup,Remove-DeviceGroup,Remove-DeviceRequest,Remove-Event,Remove-EventBinary,Remove-EventCollection,Remove-ExternalId,Remove-Group,Remove-ManagedObject,Remove-Measurement,Remove-MeasurementCollection,Remove-Microservice,Remove-OperationCollection,Remove-RetentionRule,Remove-RoleFromGroup,Remove-RoleFromUser,Remove-Tenant,Remove-TenantOption,Remove-User,Remove-UserFromGroup,Request-DeviceCredentials,Reset-UserPassword,Set-DeviceRequiredAvailability,Update-Agent,Update-Alarm,Update-AlarmCollection,Update-Application,Update-Binary,Update-CurrentApplication,Update-CurrentUser,Update-DataBrokerConnector,Update-Device,Update-DeviceGroup,Update-Event,Update-EventBinary,Update-Group,Update-ManagedObject,Update-Microservice,Update-Operation,Update-RetentionRule,Update-Tenant,Update-TenantOption,Update-TenantOptionBulk,Update-TenantOptionEditable,Update-User,Add-PowershellType,Clear-Session,ConvertFrom-Base64ToUtf8,ConvertTo-JsonArgument,Expand-Application,Expand-Device,Expand-Id,Expand-Microservice,Expand-PaginationObject,Expand-Source,Expand-Tenant,Expand-User,Find-ManagedObjectCollection,Format-Date,Get-AgentCollection,Get-AssetParent,Get-C8ySessionProperty,Get-ClientBinary,Get-ClientBinaryVersion,Get-CurrentTenantApplications,Get-DeviceBootstrapCredential,Get-DeviceCollection,Get-DeviceGroupCollection,Get-DeviceParent,Get-Session,Get-SessionCollection,Install-ClientBinary,Invoke-ClientRequest,New-HostedApplication,New-Microservice,New-RandomPassword,New-RandomString,New-Session,New-TestAgent,New-TestAlarm,New-TestDevice,New-TestDeviceGroup,New-TestEvent,New-TestFile,New-TestGroup,New-TestMeasurement,New-TestOperation,New-TestUser,Open-Website,Register-Alias,Set-ClientConsoleSetting,Set-Session,Test-Json,Unregister-Alias,Wait-Operation,Watch-Alarm,Watch-Event,Watch-ManagedObject,Watch-Measurement,Watch-Notification,Watch-NotificationChannels,Watch-Operation #region imports # # Create session folder # $HomePath = Get-SessionHomePath if (!(Test-Path $HomePath)) { Write-Host "Creating home directory [$HomePath]" $null = New-Item -Path $HomePath -ItemType Directory } # Install binary (and make it executable) if ($script:IsLinux -or $script:IsMacOS) { # silence errors if ($env:PSC8Y_INSTALL_ON_IMPORT -match "true|1|on") { Install-ClientBinary -ErrorAction SilentlyContinue } else { # Make c8y executable $binary = Get-ClientBinary & chmod +x $binary } } # Set environment variables if a session is set via the C8Y_SESSION env variable $ExistingSession = Get-Session -WarningAction SilentlyContinue -ErrorAction SilentlyContinue if ($ExistingSession) { Set-EnvironmentVariablesFromSession # Display current session $ConsoleMessage = $ExistingSession | Out-String $ConsoleMessage = $ConsoleMessage.TrimEnd() Write-Host "Current Cumulocity session" Write-Host "${ConsoleMessage}`n" } $script:Aliases = @{ # collections alarms = "Get-AlarmCollection" apps = "Get-ApplicationCollection" devices = "Get-DeviceCollection" events = "Get-EventCollection" fmo = "Find-ManagedObjectCollection" measurements = "Get-MeasurementCollection" ops = "Get-OperationCollection" series = "Get-MeasurementSeries" # single items alarm = "Get-Alarm" app = "Get-Application" event = "Get-Event" m = "Get-Measurement" mo = "Get-ManagedObject" op = "Get-Operation" # References childdevices = "Get-ChildDeviceCollection" childassets = "Get-ChildAssetCollection" # utilities json = "ConvertTo-Json" tojson = "ConvertTo-Json" fromjson = "ConvertFrom-Json" rest = "Invoke-ClientRequest" base64ToUtf8 = "ConvertFrom-Base64ToUtf8" # session session = "Get-Session" } Register-Alias #endregion imports #region tab completion # allow -Session params to be tab-completed $Manifest = Test-ModuleManifest -Path $PSScriptRoot\PSc8y.psd1 $ModulePrefix = $Manifest.Prefix $commandsWithSessionParameter = @( $Manifest.ExportedFunctions.Keys ) ` | ForEach-Object { # Note: Different PowerShell version handle internal function names # slightly differenty (some with prefix sometimes without), so we always # look for both of them. # $Name = "$_" $NameWithoutPrefix = $Name.Replace("-${ModulePrefix}", "-") if (Test-Path "Function:\$Name") { Get-Item "Function:\$Name" } elseif (Test-Path "Function:\$NameWithoutPrefix") { Get-Item "Function:\$NameWithoutPrefix" } else { throw "Could not find function '$Name'" } } ` | Where-Object { $null -ne $_.Parameters -and $_.Parameters.ContainsKey("Session") } try { if (Get-Command -Name Register-ArgumentCompleter -ErrorAction SilentlyContinue) { Register-ArgumentCompleter -CommandName $commandsWithSessionParameter -ParameterName Session -ScriptBlock { param ($commandName, $parameterName, $wordToComplete) $C8ySessionHome = Get-SessionHomePath Get-ChildItem -Path $C8ySessionHome -Filter "$wordToComplete*.json" -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_.BaseName, $_.BaseName, 'ParameterValue', $_.BaseName) } } } } catch { # All this functionality is optional, so suppress errors Write-Debug -Message "Error registering argument completer: $_" } #endregion tab completion |