Private/Add-ADCCertificateFile.ps1
function Add-ADCCertificateFile { <# .SYNOPSIS Adds a Certificate File to the Citrix ADC. .DESCRIPTION Adds a Certificate File to the Citrix ADC. .PARAMETER Session The Citrix ADC Session to execute the function against. .PARAMETER CertificateFile The Local Source for the Certificate File. .PARAMETER CertificateFileName The Certificate File Name On the Citrix ADC. .NOTES Creation Date: 20/06/2018 .CHANGE CONTROL Name Version Date Change Detail David Brett 1.0 04/07/2018 Function Creation .EXAMPLE Add-ADCCertificateFile -CertificateFile "D:\certificates\external\wildcard\wildcard.cer" -CertificateFileName "external_wildcard.cer" -Verbose #> [CmdletBinding()] Param ( $Session = $script:session, [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)] [string[]]$CertificateFile = (Read-Host -Prompt 'Enter Local Patch and Filename to Certificate File'), [string[]]$CertificateFileName = (Read-Host -Prompt 'Enter Cert File Name for the Citrix ADC') ) begin { $certContent = Get-Content -Path $CertificateFile -Encoding "Byte" $certContentBase64 = [System.Convert]::ToBase64String($certContent) $PayLoad = @{ filename = "$CertificateFileName" filecontent = "$certContentBase64" filelocation = "/nsconfig/ssl/" fileencoding = "BASE64" } } process { try { Invoke-ADCRestAPI -Session $Session -Method POST -Type "systemfile" -Payload $PayLoad write-verbose "Certificate File ($CertificateFileName) has been uploaded to the Citrix ADC" } catch { write-verbose "Certificate File ($CertificateFileName) could not be uploaded to the Citrix ADC" } } end { } } |