Manual assignment of a Remote Desktop certificate fails with error message "Invalid parameter"
Assume the following scenario:
- A manually requested Remote Desktop certificate is to be assigned to the Remote Desktop session host on a computer.
- The operation fails with the following error message:
Set-WMIInstance : Invalid parameter
At line:1 char:1
Set-WMIInstance -path $TerminalServicesConfig.__path -argument @{SSLC …
~~~~~~~~~~~~~~~~~ CategoryInfo : InvalidOperation: (:) [Set-WmiInstance], ManagementException
FullyQualifiedErrorId : SetWMIManagementException,Microsoft.PowerShell.Commands.SetWmiInstance Cause/Solution
Do you know TameMyCerts? TameMyCerts is an add-on for the Microsoft certification authority (Active Directory Certificate Services). It extends the function of the certification authority and enables the application of rule sets to realize the secure automation of certificate issuance. TameMyCerts is unique in the Microsoft ecosystem, has already proven itself in countless companies around the world and is available under a free license. It can be downloaded via GitHub and used free of charge. Professional maintenance is also offered.
The target system is a certification authority.
The following logic was used to determine the SHA1 fingerprint for the Remote Desktop certificate:
$RdcCertHash = (Get-ChildItem -path Cert:\LocalMachine\My | Where-Object { $_.Extensions.EnhancedKeyUsages.Value -eq "1.3.6.1.4.1.311.54.1.2" } | Sort-Object -Property NotAfter -Descending | Select-Object -First 1).ThumbprintThe certification authority certificate on the target system contains a constraint on the issuance of Remote Desktop certificates.
Therefore, the previous command incorrectly selected the certification authority certificate that also exists in the machine certificate store on this system, which cannot be assigned to the Remote Desktop session host.
