Private/Set-ADCCertificateTovServer.ps1
function Set-ADCCertificateTovServer { <# .SYNOPSIS Sets (Binds) a Certificate to a Virtual Server. .DESCRIPTION Sets (Binds) a Certificate to a Virtual Server. .PARAMETER Session The Citrix ADC Session to execute the function against. .PARAMETER vServerName The Virtual Server 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-ADCCertificateTovServer -vServerName "vsvr_storefront_443" -CertificateKeyName "external_wildcard" -Verbose #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] Param ( $Session = $script:session, [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)] [string[]]$vServerName = (Read-Host -Prompt 'Enter Virtual Server Name'), [string[]]$CertificateKeyName = (Read-Host -Prompt 'Enter Certificate and Key Pair Name') ) begin { $PayLoad = @{ vservername = "$vServerName" certkeyname = "$CertificateKeyName" } } process { try { if ($Force -or $PSCmdlet.ShouldProcess("ShouldProcess?")) { Invoke-ADCRestAPI -Session $Session -Method POST -Type "sslvserver_sslcertkey_binding" -Payload $PayLoad -Action Add write-verbose "Certificate and Key Pair ($CertificateKeyName) bound to Virtual Server ($vServerName)" } } catch { write-verbose "Certificate and Key Pair ($CertificateKeyName) could not be bound to Virtual Server ($vServerName)" } } end { } } |