Created
November 20, 2022 14:55
-
-
Save AaronSadlerUK/521ae1718d52ad0ee13f50c5695541c5 to your computer and use it in GitHub Desktop.
Auto update WMSVC Certificate after Win-Acme runs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.\wacs.exe --installation script --script "Scripts\ImportWMSVC.ps1" --scriptparameters "'{CertThumbprint}'" --certificatestore My |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param | |
( | |
[Parameter(Position=0,Mandatory=$true)] | |
[string] | |
$certThumbprint | |
) | |
#Use the new certificate | |
Stop-Service wmsvc | |
$strGuid = New-Guid | |
netsh http delete sslcert ipport=0.0.0.0:8172 | |
netsh http add sslcert ipport=0.0.0.0:8172 certhash=$certThumbprint appid=`{$strGuid`} certstorename="MY" | |
#convert thumbprint to bytes and update registry | |
$bytes = for($i = 0; $i -lt $certThumbprint.Length; $i += 2) { [convert]::ToByte($certThumbprint.SubString($i, 2), 16) } | |
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\WebManagement\Server' -Name IPAddress -Value "*"; | |
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\WebManagement\Server' -Name SslCertificateHash -Value $bytes | |
Start-Service wmsvc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment