TransWikia.com

Can't write to ROOTCIMV2TerminalServices via powershell

Server Fault Asked by Phalse Impressions on December 13, 2021

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:LocalMachineMy
    $RDPInstance = Get-CimInstance -ClassName Win32_TSGeneralSetting -Namespace ROOTCIMV2TerminalServices
    $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.

One Answer

Ah! I found the issue. It turns out that some of the attributes are read-only so I would be able to put the entire instance back again and that is where it was failing. I have changed it so it is now just updating the attribute SSLCertificateSHA1Hash.

Set-CimInstance -CimInstance $RDPInstance -Property @{SSLCertificateSHA1Hash=$Thumbprint} -PassThru

Answered by Phalse Impressions on December 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP