Get-IpsCredentials.ps1
<# .Synopsis List all credentials in customer's credential wallet. .Description List all credentials in customer's credential wallet. This function supports listing all credentials in customer's credential wallet. #> Function Get-IpsCredentials { [CmdletBinding()] Param( # Citrix Cloud customer id. [Parameter(Mandatory = $true)] [string]$CustomerId, # Credential type of target platform. [Parameter(Mandatory = $false)] [ValidateSet("Azure", "Gcp", "UsernamePassword", "Aws")] [string]$CredentialType, # Citrix Cloud credentials. [Parameter(Mandatory = $false)] [string]$SecureClientId = "", [Parameter(Mandatory = $false)] [string]$SecureSecret = "", [Parameter(Mandatory = $false)] [string]$LogFileDir = "", [Parameter(Mandatory = $false)] [string]$LogFileName = 'Credentials.log', [Parameter(Mandatory = $false)] [string]$Deployment, [Parameter(Mandatory = $false)] [switch]$OverwriteLog ) Begin { Add-PSSnapin Citrix.* } Process { # Initialize Logger # Set parameter 'Verbose' by internal parameter 'VerbosePreference', since the option -Verbose is occupied by powershell cmdlet if($VerbosePreference -eq 'Continue') { $Verbose = $True } else { $Verbose = $False } LogInit $LogFileDir $LogFileName $OverwriteLog $Verbose try { # Authenticate to Citrix Cloud $parameters = AuthToCitrixCloud $CustomerId $SecureClientId $SecureSecret if ([string]::IsNullOrWhiteSpace($SecureClientId) -Or [string]::IsNullOrWhiteSpace($SecureSecret)) { $SecureClientId = $parameters.ApiKey $SecureSecret = $parameters.SecretKey } } catch { return } try { LogIt "Getting all credentials from credential wallet" $credentialsList = Invoke-CCRestMethod 'Get' $Deployment 'credentials' $CustomerId $SecureClientId $SecureSecret @{} $null if ($CredentialType) { LogIt "Listing credentials of $CredentialType" foreach ($credential in $credentialsList.items) { if ($credential.type -eq $CredentialType) { LogIt $credential } } } else { LogIt "Listing all credentials" foreach ($credential in $credentialsList.items) { LogIt $credential } } } catch { LogFatal "Failed to get the credential list: $_" } } } |