Created
March 29, 2017 23:42
-
-
Save jauderho/e3160777c3f470e77ac076252e4b3061 to your computer and use it in GitHub Desktop.
PowerShell fragments for automated Let's Encrypt cert request/renew/install for RDP
This file contains hidden or 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
################################################################################### | |
# File Name: RDSHCert.ps1 # | |
# Description: Script to Configure RDSH Certificate in WMI RDP-TCP # | |
# Version: 1.0 # | |
# Creator: Ryan Mangan # | |
# Emails: [email protected] # | |
# Blog: Ryanmangansitblog.com # | |
# # | |
# Date: March 2014 # | |
# Notes: RDSH Certificate Deployment # | |
# # | |
################################################################################### | |
# https://gallery.technet.microsoft.com/RDS-2012-Session-Host-fbb54ff9 | |
# https://ryanmangansitblog.com/2013/03/10/configuring-rds-2012-certificates-and-sso/ | |
# https://ryanmangansitblog.com/2014/05/20/rds-2012-rdsh-certificate-deployment-script/ | |
# https://technet.microsoft.com/en-us/itpro/powershell/windows/remote-desktop/set-rdcertificate | |
# https://nubisnovem.com/how-to-protect-windows-server-remote-desktop-service-with-valid-ssl-certificate/ | |
param ( | |
[Parameter(Mandatory=$TRUE, HelpMessage="PFX Certificate file path eg c:\certs\test.pfx")] | |
[String] | |
$Filepath, | |
[Parameter(Mandatory=$TRUE, HelpMessage="Certificate Password")] | |
[String] | |
$Password | |
) | |
$pass = ConvertTo-SecureString $Password -AsPlainText -Force | |
Import-PfxCertificate -FilePath $Filepath -Password $pass -CertStoreLocation cert:\localMachine\my | |
$path = (Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices -Filter "TerminalName='RDP-tcp'").__path` | |
Get-ChildItem cert:\localmachine\my | |
write-host " ---------------------Copy The ThumbPrint and Paste Below----------------" -ForegroundColor Green | |
$Thumbprint = Read-Host "Enter Thumbprint here" | |
Set-WmiInstance -Path $path -argument @{SSLCertificateSHA1Hash=$Thumbprint} | |
# https://blogs.technet.microsoft.com/tune_in_to_windows_intune/2013/12/10/get-certificate-thumbprint-using-powershell/ | |
# Get-ChildItem -path cert:\LocalMachine\My | |
# extract thumbprint | |
# http://stackoverflow.com/questions/22408150/get-thumprint-of-a-certificate/22408208 | |
# get remote SSL thumbprint | |
# https://gist.github.com/jauderho/f97adf4ad2c812dd70da57288dd68d8d | |
# Use ACMESharp to get LE cert programmatically? | |
# https://github.com/ebekker/ACMESharp/wiki/Quick-Start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment