Public/Access/Unlock-SIAAssetSecret.ps1
|
function Unlock-SIAAssetSecret { <# .SYNOPSIS Retrieves the secret for an accessible asset. .DESCRIPTION Calls the Get Secret operation for a specific asset. This reveals credential material, so it is never written to verbose or debug output - only returned on the pipeline. .PARAMETER AssetId The asset's ID, as returned by Get-SIAAsset. .EXAMPLE Get-SIAAsset | Where-Object name -eq 'db01-admin' | Unlock-SIAAssetSecret Retrieves the secret for a specific named asset. .INPUTS psSIA.Asset .OUTPUTS psSIA.AssetSecret .LINK https://api-docs.cyberark.com/secure-access/docs/secure-access-api #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] [OutputType('psSIA.AssetSecret')] param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [string]$AssetId ) process { if ($PSCmdlet.ShouldProcess($AssetId, 'Retrieve asset secret')) { Invoke-SIARequest -Method POST -Path "/api/assets/$AssetId/secret" -Service UserPortal | ConvertFrom-SIAResponse -TypeName 'psSIA.AssetSecret' } } } |