Public/MobileServer/Remove-MobileServerCertificate.ps1

function Remove-MobileServerCertificate {
    <#
    .SYNOPSIS
        Removes the current sslcert binding for Milestone XProtect Mobile Server
 
    .DESCRIPTION
        Removes the current sslcert binding for Milestone XProtect Mobile Server. The current
        binding is found by calling Get-MobileServerInfo, and if the CertHash value is -ne $null
        we call netsh http delete sslcert ipport=$HttpsIp:$HttpsPort.
    #>

    [CmdletBinding(SupportsShouldProcess, ConfirmImpact='Medium')]
    param ()

    begin {
        $Elevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
        if (!$Elevated) {
            throw "Elevation is required for Remove-MobileServerCertificate to work properly. Consider re-launching PowerShell by right-clicking and running as Administrator."
        }
    }

    process {
        try {
            $mosInfo = Get-MobileServerInfo -Verbose:$VerbosePreference
            $ipPort = "$($mosInfo.HttpsIp):$($mosInfo.HttpsPort)"
            if ($mosInfo.CertHash) {
                if ($PSCmdlet.ShouldProcess($ipPort, "Remove SSL certificate binding and restart Milestone XProtect Mobile Server")) {
                    $result = netsh http delete sslcert ipport=$ipPort
                    if ($result -notcontains 'SSL Certificate successfully deleted') {
                        Write-Warning "Unexpected result from netsh http delete sslcert: $result"
                    }
                    Restart-Service -Name 'Milestone XProtect Mobile Server' -Verbose:$VerbosePreference
                }
            } else {
                Write-Warning "No sslcert binding present for $ipPort"
            }
        } catch {
            Write-Error $_
        }
    }
}