Remove-IpsCredentials.ps1
<# .Synopsis Remove credential in customer's credential wallet. .Description Remove credential in customer's credential wallet. This function supports deleting different types of credential in customer's credential wallet. #> Function Remove-IpsCredentials { [CmdletBinding()] Param( # Citrix Cloud customer id. [Parameter(Mandatory = $true)] [string]$CustomerId, [Parameter(Mandatory = $false)] [string]$SecureClientId = "", [Parameter(Mandatory = $false)] [string]$SecureSecret = "", [Parameter(Mandatory = $true)] [string]$CredentialId, [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 $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 } # Send the DELETE try { LogIt "Deleting credential $CredentialId" $response = Invoke-CCRestMethod 'Delete' $Deployment "credentials/$CredentialId" $CustomerId $SecureClientId $SecureSecret $false $null LogIt "Deleted credential id $CredentialId" } catch { LogFatal "Failed to delete credentials: $_" } } } |