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 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-RoleToGroup { <# .SYNOPSIS Add role to a group .EXAMPLE PS> Add-RoleToGroup -Group "customGroup1*" -Role "*ALARM_*" Add a role to a group using wildcards .EXAMPLE PS> Get-RoleCollection -PageSize 100 | Where-Object Name -like "*ALARM*" | Add-RoleToGroup -Group "customGroup1*" Add a role to a group using wildcards (using pipeline) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant [Parameter()] [object] $Tenant, # Group ID (required) [Parameter(Mandatory = $true)] [object[]] $Group, # User role id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Role, # 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, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("Group")) { $Parameters["group"] = PSc8y\Expand-Id $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 $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-Command ` -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 .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( # Tenant [Parameter()] [object] $Tenant, # User prefix or full username (required) [Parameter(Mandatory = $true)] [object[]] $User, # User role id [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Role, # 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, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("User")) { $Parameters["user"] = $User } 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-Command ` -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 .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, # Tenant [Parameter()] [object] $Tenant, # User id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $User, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 "my-example-app" 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, # 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, # 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-Command ` -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 .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( # Tenant id. Defaults to current tenant (based on credentials) [Parameter()] [object] $Tenant, # Application id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Application, # 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, # 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-Command ` -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 microservice .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, # 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, # 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-Command ` -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 .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( # Tenant id. Defaults to current tenant (based on credentials) [Parameter()] [object] $Tenant, # Application id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Application, # 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, # 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-Command ` -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 microservice .EXAMPLE PS> Enable-Microservice -Id $App.id Enable (subscribe) to a microservice #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant id [Parameter()] [object] $Tenant, # Microservice id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # 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, # 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-Command ` -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 .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, # 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("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-Command ` -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, # 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("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-Command ` -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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .EXAMPLE PS> Get-Application -Id $App.id Get an application by id .EXAMPLE PS> Get-Application -Id "my-simple-app" 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, # 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("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-Command ` -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, # 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("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-Command ` -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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 Required authentication with bootstrap user .EXAMPLE PS> Get-CurrentApplication Get the current application (requires using application credentials) #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # 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("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-Command ` -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, # 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("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-Command ` -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 .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( # 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("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-Command ` -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 .EXAMPLE PS> Get-CurrentUser Get the current user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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, # 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("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-Command ` -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, # 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("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-Command ` -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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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, # 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("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-Command ` -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 .EXAMPLE PS> Get-Group -Id $Group.id Get a user group #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Tenant [Parameter()] [object] $Tenant, # Group id [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # 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("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-Command ` -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 .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( # Tenant [Parameter()] [object] $Tenant, # Group name [Parameter()] [string] $Name, # 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("Tenant")) { $Parameters["tenant"] = $Tenant } 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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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, # 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("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-Command ` -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, # 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("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-Command ` -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, # 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("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-Command ` -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, # 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("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-Command ` -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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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( # Tenant [Parameter()] [object] $Tenant, # Group id (required) [Parameter(Mandatory = $true)] [object[]] $Group, # 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("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("Group")) { $Parameters["group"] = PSc8y\Expand-Id $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-Command ` -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 .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( # Tenant [Parameter()] [object] $Tenant, # User (required) [Parameter(Mandatory = $true)] [object[]] $User, # 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("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("User")) { $Parameters["user"] = $User } 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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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, # 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("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-Command ` -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 .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 "-10d" -DateTo "-9d" Get tenant 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, # 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("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-Command ` -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, # 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("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-Command ` -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 .EXAMPLE PS> Get-TenantVersion Get the Cumulocity backend version #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # 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("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-Command ` -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 .EXAMPLE PS> Get-User -Id $User.id Get a user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Tenant [Parameter()] [object] $Tenant, # User id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # 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("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 } } Invoke-Command ` -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 .EXAMPLE PS> Get-UserByName -Name $User.userName Get a user by name #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'None')] [Alias()] [OutputType([object])] Param( # Tenant [Parameter()] [object] $Tenant, # Username (required) [Parameter(Mandatory = $true)] [string] $Name, # 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("Tenant")) { $Parameters["tenant"] = $Tenant } 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-Command ` -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( # Tenant [Parameter()] [object] $Tenant, # 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, # 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("Tenant")) { $Parameters["tenant"] = $Tenant } 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("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-Command ` -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 .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, # 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("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-Command ` -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 agent .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 myapp -Type HOSTED -Key "myapp-key" -ContextPath "myapp" Create 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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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-ChildAssetReference { <# .SYNOPSIS Create a child asset (device or devicegroup) reference .DESCRIPTION Create a child asset (device or devicegroup) reference .EXAMPLE PS> New-ChildAssetReference -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 id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Group, # new child device asset [Parameter()] [object[]] $NewChildDevice, # new child device group asset [Parameter()] [object[]] $NewChildGroup, # 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, # 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-Command ` -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 New-ChildDeviceReference { <# .SYNOPSIS Create a child device reference .DESCRIPTION Create a child device reference .EXAMPLE PS> New-ChildDeviceReference -Device $Device.id -NewChild $ChildDevice.id Assign a device as a child device to an existing device .EXAMPLE PS> Get-ManagedObject -Id $ChildDevice.id | New-ChildDeviceReference -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( # ManagedObject id (required) [Parameter(Mandatory = $true)] [object[]] $Device, # new child device (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $NewChild, # 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, # 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-Command ` -Noun "inventoryReferences" ` -Verb "createChildDevice" ` -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 New-Device { <# .SYNOPSIS Create device .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)] [string] $Name, # Device type [Parameter()] [string] $Type, # Custom device properties. [Parameter()] [object] $Data, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 event .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 .EXAMPLE PS> New-Group -Name "$GroupName" Create a user group #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant [Parameter()] [object] $Tenant, # Group name [Parameter()] [string] $Name, # 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, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } 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-Command ` -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 .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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 New application binary .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # The tenant ID. Will be auto-generated if not present. [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # 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] $Contact_phone, # A set of custom properties of the tenant [Parameter()] [object] $Data, # 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, # 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("Id")) { $Parameters["id"] = $Id } if ($PSBoundParameters.ContainsKey("AdminName")) { $Parameters["adminName"] = $AdminName } if ($PSBoundParameters.ContainsKey("AdminPass")) { $Parameters["adminPass"] = $AdminPass } if ($PSBoundParameters.ContainsKey("ContactName")) { $Parameters["contactName"] = $ContactName } if ($PSBoundParameters.ContainsKey("Contact_phone")) { $Parameters["contact_phone"] = $Contact_phone } 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 (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-Command ` -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 .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, # 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, # 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-Command ` -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 .EXAMPLE PS> New-user -Username "$Username" -Password "$NewPassword" Create a user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant [Parameter()] [object] $Tenant, # 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 (required) [Parameter(Mandatory = $true)] [string] $Password, # User activation status (true/false) [Parameter()] [ValidateSet('true','false')] [switch] $SendPasswordResetEmail, # Custom properties to be added to the user [Parameter()] [object] $CustomProperties, # 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, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } 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("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-Command ` -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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 Info: 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 "my-temp-app" 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, # 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, # 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-Command ` -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-AuditRecordCollection { <# .SYNOPSIS Delete a collection of audit records .DESCRIPTION Important: This method has been deprecated and will be removed completely with the July 2020 release (10.6.6). With Cumulocity IoT >= 10.6.6 the deletion of audit logs will no longer be permitted. All DELETE requests to the audit API will return the error 405 Method not allowed. Note that retention rules still apply to audit logs and will delete audit log records older than the specified retention time. .EXAMPLE PS> Remove-AuditRecordCollection -Source $Device.id Delete audit records from a device #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [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()] [string] $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, # 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, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Source")) { $Parameters["source"] = $Source } 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("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-Command ` -Noun "auditRecords" ` -Verb "deleteCollection" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-Binary { <# .SYNOPSIS Delete event binary .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, # 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, # 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-Command ` -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-ChildAssetReference { <# .SYNOPSIS Delete child asset reference .EXAMPLE PS> Remove-ChildAssetReference -Asset $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[]] $Asset, # Child device [Parameter()] [object[]] $ChildDevice, # Child device group [Parameter()] [object[]] $ChildGroup, # 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, # 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 $Asset)) { if ($item) { $Parameters["asset"] = if ($item.id) { $item.id } else { $item } } if (!$Force -and !$WhatIfPreference -and !$PSCmdlet.ShouldProcess( (PSc8y\Get-C8ySessionProperty -Name "tenant"), (Format-ConfirmationMessage -Name $PSCmdlet.MyInvocation.InvocationName -InputObject $item) )) { continue } Invoke-Command ` -Noun "inventoryReferences" ` -Verb "deleteChildAsset" ` -Parameters $Parameters ` -Type "" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } # Code generated from specification version 1.0.0: DO NOT EDIT Function Remove-ChildDeviceReference { <# .SYNOPSIS Delete child device reference .EXAMPLE PS> Remove-ChildDeviceReference -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, # 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, # 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-Command ` -Noun "inventoryReferences" ` -Verb "deleteChildDevice" ` -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 .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, # 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, # 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-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-Command ` -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-DeviceGroup { <# .SYNOPSIS Delete device group .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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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( # Tenant [Parameter()] [object] $Tenant, # Group id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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, # 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, # 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, # Don't prompt for confirmation [Parameter()] [switch] $Force ) 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("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-Command ` -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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .EXAMPLE PS> Remove-User -Id $User.id Delete a user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant [Parameter()] [object] $Tenant, # User id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $Id, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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' 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)] [string] $Id, # Tenant [Parameter()] [object] $Tenant, # New user password. Min: 6, max: 32 characters. Only Latin1 chars allowed [Parameter()] [string] $NewPassword, # 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, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } if ($PSBoundParameters.ContainsKey("NewPassword")) { $Parameters["newPassword"] = $NewPassword } 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-Command ` -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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 "helloworld-app" -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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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( # Tenant [Parameter()] [object] $Tenant, # Group id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Id, # name [Parameter()] [string] $Name, # 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, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } 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 (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-Command ` -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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 operation .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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 (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] $Contact_phone, # A set of custom properties of the tenant [Parameter()] [object] $Data, # 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, # 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("Contact_phone")) { $Parameters["contact_phone"] = $Contact_phone } 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-Command ` -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 .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, # 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, # 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-Command ` -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 .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, # 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, # 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-Command ` -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, # 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, # 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-Command ` -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 .EXAMPLE PS> Update-User -Id $User.id -FirstName "Simon" Update a user #> [cmdletbinding(SupportsShouldProcess = $true, PositionalBinding=$true, HelpUri='', ConfirmImpact = 'High')] [Alias()] [OutputType([object])] Param( # Tenant [Parameter()] [object] $Tenant, # User id (required) [Parameter(Mandatory = $true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string] $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, # 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, # Don't prompt for confirmation [Parameter()] [switch] $Force ) Begin { $Parameters = @{} if ($PSBoundParameters.ContainsKey("Tenant")) { $Parameters["tenant"] = $Tenant } 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("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-Command ` -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" .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 .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 .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 { [cmdletbinding()] Param( [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. .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. .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. .PARAMETER InputObject List of ids .EXAMPLE Expand-Id 12345 Normalize a list of ids .EXAMPLE "12345", "56789" | Expand-Id Normalize a list of ids #> [cmdletbinding()] Param( [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 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 .EXAMPLE Invoke-CumulocityRequest -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-CumulocityRequest -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 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 .PARAMETER InputObject List of ids .EXAMPLE Expand-Source 12345 Normalize a list of ids .EXAMPLE "12345", "56789" | Expand-Source Normalize a list of ids #> [cmdletbinding()] Param( [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 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 .PARAMETER InputObject List of ids, names or tenant objects .EXAMPLE Expand-C8yTenant "mytenant" Retrieve the tenant objects by name or id .EXAMPLE Get-C8yTenant *test* | Expand-C8yTenant 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( [Parameter( Mandatory=$true, ValueFromPipeline=$true, Position=0 )] [object[]] $InputObject ) Process { [array] $AllTenants = foreach ($iTenant in $InputObject) { if (($iTenant -is [string]) -or ($iTenant -match "^\d+$")) { Get-Tenant -Tenant $iTenant -WhatIf:$false } else { $iTenant } } $AllTenants } } Function Expand-User { <# .SYNOPSIS 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 .PARAMETER InputObject List of ids, names or user objects .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( [Parameter( Mandatory=$true, ValueFromPipeline=$true, Position=0 )] [object[]] $InputObject ) Process { [array] $AllUsers = foreach ($iUser in $InputObject) { if (($iUser -is [string])) { # Remove any wildcard characters, as they are not supported by c8y $iUserNormalized = $iUser -replace "\*", "" # Search for users PSc8y\Get-UserCollection -Username $iUserNormalized -WhatIf:$false -PageSize 100 | Where-Object { $_.id -like $iUser -or $_.userName -like $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-Command ` -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 .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-Command ` -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 .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 { [cmdletbinding()] Param( [Parameter( Mandatory = $true, Position = 0 )] [string] $Name ) switch ($Name) { "tenant" { $env:C8Y_TENANT } "host" { $env:C8Y_HOST } } } Function Get-CumulocityBinary { <# .SYNOPSIS Get the full path to the Cumulocity Binary which is compatible with the current Operating system .EXAMPLE Get-CumulocityBinary 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-CumulocityBinaryVersion { [cmdletbinding()] Param() $c8y = Get-CumulocityBinary & $c8y version } Function Get-CurrentTenantApplications { <# .SYNOPSIS 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 $Credential = Get-DeviceBootstrapCredential $Credential.GetPlainText() # => returns credentials in format "{username}/{password}" $Credential.GetBasicAuth() # => returns credentials in format "Basic {base64 encoded username/password}" .DESCRIPTION The bootstrap credentials should be already set in the following environment variables $env:C8Y_DEVICEBOOTSTRAP_TENANT $env:C8Y_DEVICEBOOTSTRAP_USERNAME $env:C8Y_DEVICEBOOTSTRAP_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 .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-Command ` -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 .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-Command ` -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 .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 .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 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-CumulocityBinary { <# .SYNOPSIS 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-CumulocityBinary On Linux/MacOS, this installs the cumulocity binary to /usr/local/bin On Windows this will throw a warning .EXAMPLE Install-CumulocityBinary -InstallPath /usr/bin Install the Cumulocity binary to /usr/bin #> [cmdletbinding()] Param( [Parameter( Position = 0 )] [string] $InstallPath = $env:C8Y_INSTALL_PATH ) $binary = Get-CumulocityBinary 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-Command { [cmdletbinding()] Param( [Parameter( Mandatory = $true )] [string] $Noun, [Parameter( Mandatory = $true )] [string] $Verb, [hashtable] $Parameters, [string] $Type = "c8y.item", [string] $ItemType, [string] $ResultProperty, [switch] $IncludeAll, [switch] $Raw, # Timeout in seconds [Parameter()] [double] $TimeoutSec ) $args = New-Object System.Collections.ArrayList $null = $args.Add($Noun) $null = $args.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 = $args.AddRange(@("--${key}")) } else { if ($key -eq "data") { # due to cli parsing, data needs to be sent using "=" $null = $args.AddRange(@("--${key}", $Value)) } else { if ($Value -match " ") { # $null = $args.AddRange(@("--${key}", "$Value")) $null = $args.Add("--${key}=`"$Value`"") } else { $null = $args.Add("--${key}=$Value") } } } } } } $null = $args.Add("--pretty=false") if ($WhatIfPreference) { $null = $args.Add("--dry") } if ($VerbosePreference) { $null = $args.Add("--verbose") } if ($TimeoutSec) { # Convert to milliseconds (cast to an integer) [int] $TimeoutInMS = $TimeoutSec * 1000 $null = $args.AddRange(@("--timeout", $TimeoutInMS)) } # Include all pagination results if ($IncludeAll) { $null = $args.Add("--all") } $null = $args.Add("--raw") $c8ycli = Get-CumulocityBinary Write-Verbose ("$c8ycli {0}" -f $args -join " ") try { $RawResponse = & $c8ycli $args } 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 Invoke-CumulocityRequest { <# .SYNOPSIS Send a rest request using the c8y .EXAMPLE Invoke-CumulocityRequest -Uri "/inventory/managedObjects" -Method "post" -Data "name=test" Create a new managed object with the name "test" .EXAMPLE Invoke-CumulocityRequest -Uri "/alarm/alarms" -QueryParameters @{ pageSize = "100" } Get a list of alarms with page size of 100 .EXAMPLE Invoke-CumulocityRequest -Uri "/alarm/alarms?pageSize=100" Get a list of alarms with page size of 100 #> [cmdletbinding( SupportsShouldProcess = $true, ConfirmImpact = "None")] Param( # Uri (or partial uri). i.e. /application/applications [Parameter( Mandatory = $true, Position = 0)] [string] $Uri, # HostName to use which overrides the given host [string] $HostName, # Rest Method. Defaults to GET [Microsoft.PowerShell.Commands.WebRequestMethod] $Method, # Request body [object] $Data, # Input file to be uploaded as FormData [string] $InFile, # Uri query parameters [hashtable] $QueryParameters, # 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 ) $c8y = Get-CumulocityBinary $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 ($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 ($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 Invoke-CustomRestMethod { <# .SYNOPSIS Create a new C8Y Rest Request given a specific API string. It uses information from the active c8y session to build the full api request object .EXAMPLE Invoke-CustomRestMethod /alarm/alarms Manually invoke the REST method GET on the alarms rest endpoint, to return all alarms .EXAMPLE rest /alarm/alarms Invoke the rest method using the alias for the Invoke-CustomRestMethod (useful when testing out new c8y commands) .EXAMPLE rest myapp://health Get the health status of the myapp microservice #> [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "None")] Param( # Uri [Parameter( Mandatory = $true, Position = 0)] [string] $Uri, # REST API Method. i.e. GET, POST, PUT etc. [Parameter( Mandatory = $false, Position = 1)] [Microsoft.PowerShell.Commands.WebRequestMethod] $Method = "GET", # Content Type. Defaults to application/json (with utf8 encoding). If no encoding is set, then utf8 will be used [string] $ContentType, # Accept header type [string] $Accept, [Parameter(Mandatory = $false)] [System.Collections.IDictionary] $Headers, [Parameter(Mandatory = $false)] [System.Object] $Body, # Ignore the accept header [switch] $IgnoreAcceptHeader, # Return the result as text [switch] $AsText, # Don't send requests to the proxy [switch] $NoProxy, # Use an explicit proxy setting (instead of environmnet variables) [string] $Proxy, [int] $TimeoutSec, # Include raw response including pagination information [Parameter()] [switch] $Raw, # Compress returns minimized json [Parameter()] [switch] $Compress, # Allow loading Cumulocity session setting from environment variables [Parameter()] [switch] $UseEnvironment, # Session path [Parameter()] [string] $Session ) Begin { # Control default timeout setting by using a environment variable if (!$PSBoundParameters.ContainsKey("TimeoutSec")) { if ($Env:__C8Y_REST_TIMEOUT) { $TimeoutSec = $Env:__C8Y_REST_TIMEOUT } else { $TimeoutSec = 600 } } $c8ycli = Get-CumulocityBinary } Process { $args = New-Object System.Collections.ArrayList $null = $args.Add("rest") if (![string]::IsNullOrEmpty($Method)) { $null = $args.Add($Method) } if (![string]::IsNullOrEmpty($Uri)) { $null = $args.Add($Uri) } if (![string]::IsNullOrEmpty($ContentType)) { $null = $args.AddRange(@("--contentType", $ContentType)) } if (![string]::IsNullOrEmpty($Accept)) { $null = $args.AddRange(@("--accept", $Accept)) } if ($IgnoreAcceptHeader) { $null = $args.Add("--ignoreAcceptHeader") } if ($Raw) { $null = $args.Add("--raw") } if (![string]::IsNullOrEmpty($Session)) { $null = $args.AddRange(@("--session", $Session)) } if ($Compress) { $null = $args.Add("--pretty=false") } if (![string]::IsNullOrEmpty($Proxy)) { $null = $args.AddRange(@("--proxy", $Proxy)) } if ($NoProxy) { $null = $args.Add("--noProxy") } if ($VerbosePreference) { $null = $args.Add("--verbose") } if ($WhatIfPreference) { $null = $args.Add("--dry") } if ($UseEnvironment) { $null = $args.Add("--useEnv") } if ($null -ne $Body) { $null = $args.AddRange(@( "--data", ("{0}" -f ((ConvertTo-Json $Body -Compress) -replace '"', '\"')) )) } $VerboseArgs = for ($i = 0; $i -lt $args.Count; $i++) { if ($args[$i] -eq "--data") { Write-Output $args[$i] $i += 1 Write-Output ("'{0}'" -f $args[$i]) } else { Write-Output $args[$i] } } Write-Verbose ("$c8ycli {0}" -f ($VerboseArgs -join " ")) $RawResponse = & $c8ycli $args $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 } if ($AsText) { Write-Output $RawResponse return } $response = $RawResponse | ConvertFrom-Json $global:_rawdata = $response $global:_data = $response Write-Output $response } } Function Invoke-CustomRestRequest { [cmdletbinding()] Param( [string] $Uri, [string] $Method, [hashtable] $QueryParameters ) $pair = "{0}:{1}" -f $env:C8Y_USER, $env:C8Y_PASSWORD $Headers = @{ Authorization = "Basic {0}" -f [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) } Invoke-WebRequest -Uri:$Uri -Method:$Method -Headers:$Headers -UserAgent "pscumulocity.v2" } Function New-HostedApplication { <# .SYNOPSIS New hosted (web) application .EXAMPLE New-HostedApplication -Name $App.id -File "myapp.zip" Upload application microservice binary #> [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-Command ` -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 application .EXAMPLE PS> New-Microservice -Name $App.id -File "myapp.zip" Upload application microservice binary #> [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, # File to be uploaded as a binary (required) [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 application binary [Parameter()] [switch] $SkipUpload, # Don't subscribe to the application 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-Command ` -Noun "microservices" ` -Verb "create" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.application+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } Function New-RandomPassword { <# .Synopsis Generate pseudo random passwords .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] .NOTES Written by Simon Wåhlin, blog.simonw.se I take no responsibility for any issues caused by this script. .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 { [cmdletbinding()] Param( [string] $Prefix, [string] $Postfix ) $RandomPart = -join ((48..57) + (97..122) | Get-Random -Count 10 | ForEach-Object { [char]$_ }) Write-Output "${Prefix}${RandomPart}${Postfix}" } Function New-Session { <# .SYNOPSIS Get the active Cumulocity Session .EXAMPLE Get-Session Get the current Cumulocity session .OUTPUTS None #> [CmdletBinding()] Param( # Name of the Cumulocity session [Parameter(Mandatory = $true)] [string] $Name, # Host the type of this alarm, e.g. 'com_cumulocity_events_TamperEvent'. (required) [Parameter(Mandatory = $true)] [string] $Host, # Tenant the type of this alarm, e.g. 'com_cumulocity_events_TamperEvent'. (required) [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-CumulocityBinary 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 } $args = New-object System.Collections.ArrayList $null = $args.AddRange(@("sessions", "create")) if ($Name) { $null = $args.AddRange(@("--name", $Name)) } if ($Host) { $null = $args.AddRange(@("--host", $Host)) } if ($Tenant) { $null = $args.AddRange(@("--tenant", $Tenant)) } if ($Credential.GetNetworkCredential().Username) { $null = $args.AddRange(@("--username", $Credential.GetNetworkCredential().Username)) } if ($Credential.GetNetworkCredential().Password) { $null = $args.AddRange(@("--password", $Credential.GetNetworkCredential().Password)) } if ($Description) { $null = $args.AddRange(@("--description", $Description)) } if ($NoTenantPrefix.IsPresent) { $null = $args.AddRange("--noTenantPrefix={0}" -f $NoTenantPrefix.ToString().ToLower()) } $Path = & $Binary $args Set-Session -File $Path } Function New-TestAgent { [cmdletbinding()] Param( [Parameter( Mandatory = $false, Position = 0 )] [string] $Name = "testagent", [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 #> [cmdletbinding()] Param( [Parameter( Mandatory = $false, Position = 0 )] [object] $Device, [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 { [cmdletbinding( SupportsShouldProcess = $true, ConfirmImpact = "None" )] Param( [Parameter( Mandatory = $false, Position = 0 )] [string] $Name = "testdevice", [switch] $AsAgent, [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 { [cmdletbinding()] Param( [Parameter( Mandatory = $false, Position = 0 )] [string] $Name = "testgroup", [ValidateSet("Group", "SubGroup")] [string] $Type = "Group", [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 #> [cmdletbinding()] Param( [Parameter( Mandatory = $false, Position = 0 )] [object] $Device, [switch] $WithBinary, [switch] $Force ) if ($null -ne $Device) { $iDevice = Expand-Device $Device } else { $iDevice = PSc8y\New-TestDevice -Force:$Force } $Event = 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 $Event.id ` -File $tempfile ` -Force:$Force Remove-Item $tempfile } $Event } Function New-TestFile { <# .SYNOPSIS Create a new temp file with default contents #> Param( [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 #> [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", [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 #> [cmdletbinding( SupportsShouldProcess = $true, ConfirmImpact = "None" )] Param( [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", [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 #> [cmdletbinding()] Param( [Parameter( Mandatory = $false, Position = 0 )] [object] $Device, [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 #> [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", [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 .PARAMETER Application Application to open .PARAMETER Device Name of the device to open in devicemanagement. Only the first matching device will be used to open the c8y website. .PARAMETER Page Device page to open .PARAMETER Browser Browser to use to open the webpage .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( [ValidateSet("cockpit", "administration", "devicemanagement", "fieldbus4")] [Parameter( ParameterSetName="Application", Position=0 )] [string] $Application = "cockpit", [Parameter( ParameterSetName="Device", Position=0, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true )] [object[]] $Device, [Parameter( ParameterSetName="Device", Position=1 )] [ValidateSet("device-info", "measurements", "alarms", "control", "events", "service_monitoring", "identity")] [string] $Page = "control", [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 .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-CumulocityConsoleSetting { <# .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-CumulocityConsoleSetting -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 .EXAMPLE Set-Session .OUTPUTS String #> [CmdletBinding( DefaultParameterSetName = "None" )] Param( # File containing the Cumulocity session data [Parameter(Mandatory=$false, Position = 0, ParameterSetName = "ByFile", ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [Alias("FullName")] [string] $File, # Allow loading Cumulocity session setting from environment variables [switch] $UseEnvironment ) Process { switch ($PSCmdlet.ParameterSetName) { "ByFile" { $Path = $File } default { $Binary = Get-CumulocityBinary $args = New-Object System.Collections.ArrayList $null = $args.AddRange(@("sessions", "list")) if ($UseEnvironment) { $null = $args.Add("--useEnv") } $Path = & $Binary $args } } # 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 .EXAMPLE Test-Json '{ "name": "tester" }' Returns true if the input data is valid json #> [cmdletbinding()] [OutputType([bool])] Param( [Parameter( Mandatory = $true, Position = 0, ValueFromPipeline = $true )] [object] # Input data $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 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 Update-Microservice { <# .SYNOPSIS Update microservice application .EXAMPLE PS> Update-Microservice -Id $App.id -File "myapp.zip" Upload application microservice binary #> [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, # Application id (required) [Parameter(Mandatory = $false, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [object[]] $Application, # 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("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 } } Process { # TODO: create Expand-Microservice # TODO: create Get-MicroserviceCollection # TODO: create Get-Microservice 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-Command ` -Noun "microservices" ` -Verb "update" ` -Parameters $Parameters ` -Type "application/vnd.com.nsn.cumulocity.managedObject+json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw } } End {} } Function Wait-Operation { <# .SYNOPSIS Wait for an operation to be completed (i.e. either in the SUCCESS or FAILED status) .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-Command ` -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-Command ` -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-Command ` -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-Command ` -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-Command ` -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-Command ` -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-Command ` -Noun "operations" ` -Verb "subscribe" ` -Parameters $Parameters ` -Type "application/json" ` -ItemType "" ` -ResultProperty "" ` -Raw:$Raw ` -IncludeAll:$IncludeAll } End {} } #endregion Export-ModuleMember -Function 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-ChildAssetReference,New-ChildDeviceReference,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-AuditRecordCollection,Remove-Binary,Remove-ChildAssetReference,Remove-ChildDeviceReference,Remove-Device,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-CumulocityBinary,Get-CumulocityBinaryVersion,Get-CurrentTenantApplications,Get-DeviceBootstrapCredential,Get-DeviceCollection,Get-DeviceGroupCollection,Get-DeviceParent,Get-Session,Get-SessionCollection,Install-CumulocityBinary,Invoke-Command,Invoke-CumulocityRequest,Invoke-CustomRestMethod,Invoke-CustomRestRequest,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-CumulocityConsoleSetting,Set-Session,Test-Json,Unregister-Alias,Update-Microservice,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-CumulocityBinary -ErrorAction SilentlyContinue } else { # Make c8y executable $binary = Get-CumulocityBinary & 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-Measurements" 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-CumulocityRequest" 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 $commandsWithSessionParameter = @( $Manifest.ExportedFunctions.Keys ) ` | ForEach-Object { Get-Item "function:\$_" } ` | Where-Object { $_.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 |