Private/Set-ADCCertificateKey.ps1
function Set-ADCCertificateKey { <# .SYNOPSIS Sets (Binds) a Certificate and Key File. .DESCRIPTION Sets (Binds) a Certificate and Key File. .PARAMETER Session The Citrix ADC Session to execute the function against. .PARAMETER CertificateFile The certificate file name. .PARAMETER KeyFile The key file name. .PARAMETER CertificateKeyName The certificate and key description on the Citrix ADC. .NOTES Creation Date: 04/07/2018 .CHANGE CONTROL Name Version Date Change Detail David Brett 1.0 29/03/2018 Function Creation .EXAMPLE Set-ADCCertificateKey -CertificateFile "external_wildcard.cer" -KeyFile "external_wildcard.key" -CertificateKeyName "external_wildcard" -Verbose #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] Param ( $Session = $script:session, [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)] [string[]]$CertificateFile = (Read-Host -Prompt 'Enter Certificate Name'), [string[]]$KeyFile = (Read-Host -Prompt 'Enter Keyfile Name'), [string[]]$CertificateKeyName = (Read-Host -Prompt 'Enter Certificate and Key Name') ) begin { $PayLoad = @{ certkey = "$CertificateKeyName" cert = "$CertificateFile" key = "$KeyFile" } } process { try { if ($Force -or $PSCmdlet.ShouldProcess("ShouldProcess?")) { Invoke-ADCRestAPI -Session $Session -Method POST -Type "sslcertkey" -Payload $PayLoad -Action Add write-verbose "Certificate and Key Pair added to the Citrix ADC as ($CertificateKeyName)" } } catch { write-verbose "Certificate and Key Pair could not be added to the Citrix ADC as ($CertificateKeyName)" } } end { } } |