I'm trying to automate installing new SSL certificates onto a Windows Server using powershell. I have most of it done but I have a small issue. When I try to update the Terminal Services SSL cert I keep getting an error and for the life of me I can't figure out why.
$NewCert = Import-Certificate -FilePath $FileName -CertStoreLocation cert:\LocalMachine\My $RDPInstance = Get-CimInstance -ClassName Win32_TSGeneralSetting -Namespace ROOT\CIMV2\TerminalServices $RDPInstance.SSLCertificateSHA1Hash = $NewCert.Thumbprint Set-CimInstance -CimInstance $RDPInstance -Passthru
I took most of this code from Microsoft's site to be able to do this update but it throws the error:
Set-CimInstance : Invalid parameter At line:1 char:1 + Set-CimInstance -CimInstance $RDPInstance -Passthru + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (Win32_TSGeneral...me = "RDP-Tcp"):CimInstance) [Set-CimInstance], CimException + FullyQualifiedErrorId : HRESULT 0x80041008,Microsoft.Management.Infrastructure.CimCmdlets.SetCimInstanceCommand
I have tried a few versions of the Set-CimInstance but all of them seem to throw the same Invalid parameter.