Public/Resources/Get-SIAWindowsStrongAccount.ps1
|
function Get-SIAWindowsStrongAccount { <# .SYNOPSIS Retrieves Windows strong accounts managed by SIA. .DESCRIPTION Lists or retrieves strong accounts used for provisioning and Privilege Cloud handoff on Windows targets. -Type, -Name, -Details, and -MatchAnyDetail map directly to the documented server-side query parameters (secret_type, secret_name, secret_details, any_details). By default this calls the v1 list endpoint, whose response schema CyberArk documents only as an untyped body. -All instead pages through the v2 endpoint using its documented continuation key; see docs/LIMITATIONS.md for what that endpoint does and does not document. .PARAMETER Id Retrieves a single strong account by its secret ID. .PARAMETER Type Server-side filter: one or more strong account types. 'ProvisionerUser' accounts are stored directly in the SIA service; 'PCloudAccount' accounts are vaulted in Privilege Cloud. .PARAMETER Name Server-side filter: strong account name, wildcard format. .PARAMETER Details Server-side filter: a key/value match against the account's details. .PARAMETER MatchAnyDetail Changes -Details matching from AND to OR semantics. .PARAMETER Offset Starting offset for the v1 listing. .PARAMETER Count Maximum accounts to return from the v1 listing. .PARAMETER All Retrieves every account by paging through the v2 endpoint. .PARAMETER NoAutoPaging With -All, return only the first page instead of every page. .EXAMPLE Get-SIAWindowsStrongAccount -Type 'PCloudAccount' Lists Windows strong accounts vaulted in Privilege Cloud. .EXAMPLE Get-SIAWindowsStrongAccount -All Retrieves every Windows strong account, following pagination. .INPUTS None. .OUTPUTS psSIA.WindowsStrongAccount .LINK https://docs.cyberark.com/setup/latest/en/content/privileged-access/apis/dpa-strong-accounts-api.htm #> [CmdletBinding(DefaultParameterSetName = 'List')] [OutputType('psSIA.WindowsStrongAccount')] param( [Parameter(Mandatory, ParameterSetName = 'ById', ValueFromPipelineByPropertyName)] [Alias('secret_id')] [string]$Id, [Parameter(ParameterSetName = 'List')] [ValidateSet('ProvisionerUser', 'PCloudAccount')] [string[]]$Type, [Parameter(ParameterSetName = 'List')] [string]$Name, [Parameter(ParameterSetName = 'List')] [string]$Details, [Parameter(ParameterSetName = 'List')] [switch]$MatchAnyDetail, [Parameter(ParameterSetName = 'List')] [int]$Offset, [Parameter(ParameterSetName = 'List')] [int]$Count, [Parameter(Mandatory, ParameterSetName = 'All')] [switch]$All, [Parameter(ParameterSetName = 'All')] [switch]$NoAutoPaging ) process { switch ($PSCmdlet.ParameterSetName) { 'ById' { Invoke-SIARequest -Method GET -Path "/api/secrets/public/v1/$Id" | ConvertFrom-SIAResponse -TypeName 'psSIA.WindowsStrongAccount' } 'List' { $query = @{} if ($Type) { $query.secret_type = $Type -join ',' } if ($Name) { $query.secret_name = $Name } if ($Details) { $query.secret_details = $Details } if ($MatchAnyDetail) { $query.any_details = 'true' } if ($PSBoundParameters.ContainsKey('Offset')) { $query.offset = $Offset } if ($PSBoundParameters.ContainsKey('Count')) { $query.count = $Count } Invoke-SIARequest -Method GET -Path '/api/secrets/public/v1' -QueryParameter $query | ConvertFrom-SIAResponse -TypeName 'psSIA.WindowsStrongAccount' } 'All' { $stopAfterFirstPage = $NoAutoPaging -or -not $script:SIAModuleConfig.AutoPagination $firstPage = Invoke-SIARequest -Method GET -Path '/api/secrets/public/v2' $pages = Get-SIAPagination -FirstPage $firstPage -ContinuationProperty 'b64_last_evaluated_key' ` -NoAutoPaging:$stopAfterFirstPage -NextPageRequest { param($token) Invoke-SIARequest -Method GET -Path '/api/secrets/public/v2' -QueryParameter @{ b64StartKey = $token } } foreach ($page in $pages) { $items = @($page.PSObject.Properties | Where-Object { $_.Name -ne 'b64_last_evaluated_key' -and $_.Value -is [array] } | ForEach-Object Value) if (-not $items) { Write-Warning 'SIA does not document which response field holds strong accounts on this page; returning the raw page object. See docs/LIMITATIONS.md.' $page | ConvertFrom-SIAResponse -TypeName 'psSIA.WindowsStrongAccount' } else { $items | ConvertFrom-SIAResponse -TypeName 'psSIA.WindowsStrongAccount' } } } } } } |