public/http/sslcert/Remove-SslCert.ps1
#Requires -RunAsAdministrator function Remove-SslCert { <# .SYNOPSIS Removes an sslcert binding using netsh http delete sslcert .DESCRIPTION Removes an sslcert binding using netsh http delete sslcert .EXAMPLE PS C:\> Remove-SslCert -IpPort 0.0.0.0:443 Removes the sslcert binding for ipport 0.0.0.0:443 #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact="High", DefaultParameterSetName='IpPortFilter')] param ( # Specifies the IP address and port for the binding. Example: [fe80::1]:443, 1.1.1.1:443, 0.0.0.0:443, [::]:443 [Parameter(ParameterSetName='IpPortFilter', ValueFromPipelineByPropertyName)] [string] $IpPort, # Specifies the hostname and port for the binding. Example: www.contoso.com:443 [Parameter(ParameterSetName='HostnamePortFilter', ValueFromPipelineByPropertyName)] [string] $HostnamePort, # Specifies the ccs port for the binding. Example: 443 [Parameter(ParameterSetName='CcsFilter', ValueFromPipelineByPropertyName)] [string] $Ccs ) process { $command = "netsh.exe http delete sslcert" switch ($PSCmdlet.ParameterSetName) { 'IpPortFilter' { $command += " ipport=$IpPort" } 'HostnamePortFilter' { $command += " hostnameport=$HostnamePort" } 'CcsFilter' { $command += " ccs=$Ccs" } Default {} } Write-Verbose "Executing the command '$command'" if ($PSCmdlet.ShouldProcess((hostname), $command)) { $output = Invoke-Expression -Command $command $success = $LASTEXITCODE -eq 0 if ($success) { Write-Information $output } else { $output = [string]::Join("`r`n", $output).Trim() Write-Error "Error: $output" } } } } |