Remove-IpsCredentials.ps1
<# .SYNOPSIS Remove a credential from a customer's credential wallet. .DESCRIPTION Removes a credential from a customer's credential wallet. .PARAMETER CustomerId Specifies the customer id of the Citrix customer running this command. .PARAMETER SecureClientId Specifies the client id of the Citrix customer's API client. .PARAMETER SecureSecret Specifies the client secret of the Citrix customer's API client. .PARAMETER CredentialId Specifies the id of the credential to remove. .PARAMETER Deployment Specifies the service address to send the job request to. It defaults to api.layering.cloud.com. This can be used if necessary to send the request to a geo specific deployment such as api.eu.layering.cloud.com. .PARAMETER LogFileDir Specifies the path to the file to log to. The local directory is the default. .PARAMETER LogFileName Specifies the name of the file to log to. .PARAMETER OverwriteLog If specified the log file is overwritten otherwise it is appended to. .INPUTS None. .OUTPUTS None. .EXAMPLE PS> $CredParams = @{ CustomerId = 'a7f4wb1example' SecureClientId = '7fed2a1e-1495-46b7-8fd3-5644764af395' SecureSecret = '9T.3Q~MGlnB6NNgpNUUWrcquVzODrdGK~eXampLe' CredentialId = 'example-credential' } PS> Remove-IpsCredentials @CredParams #> 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]$Deployment, [Parameter(Mandatory = $false)] [string]$LogFileDir, [Parameter(Mandatory = $false)] [string]$LogFileName = 'Credentials.log', [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 $MyInvocation $LogFileDir $LogFileName $OverwriteLog $Verbose VersionCheck $Deployment $CustomerId 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 { LogFatal "Failed to authenticate to Citrix Cloud" } # Send the DELETE try { LogIt "Deleting credential $CredentialId" $response = Invoke-CCRestMethod 'Delete' $Deployment "credentials/$CredentialId" $CustomerId $SecureClientId $SecureSecret @{} $null LogIt "Deleted credential id $CredentialId" } catch { LogFatal "Failed to delete credentials: $_" } } } |