Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wmic.exe is deprecated - scripts don't run unter Server 2025 and W11 #2748

Open
TBobsin opened this issue Feb 14, 2025 · 1 comment
Open

Comments

@TBobsin
Copy link

TBobsin commented Feb 14, 2025

Before you post
Make sure to search through the issue list to check if others have reported the same bug already. If you find an existing issue, make your voice heard there. Your case may provide valueable extra clues towards a solution and will increase its priority.
Yes i searched for wmic

Describe the bug
A clear and concise description of what the bug is.

wmic.exe is deprecated

The windows cmdlet "wmic.exe" is not supported under Server 2025 and Windows 11, because wmic is deprecated. Look at:
https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242

To Reproduce
The included PowerShell scripts, are using the cmdlet.

ImportRDListener.ps1
ImportRDS.ps1
ImportRDSFull.ps1

Expected behavior
Replace the cmdlets with Get-CimInstance to avoid errors.

Log
Please add any available log output. You may copy it from the console window, get it from the Windows Event Viewer, or the log files on disk, which can typically be found in a sub folder of %programdata%\win-acme.

wmic : The term 'wmic' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.

Platform:

  • OS: [Windows 11, Server 2025 - All Languages]

Additional context
Add any other context about the problem here, for example possible network issues (firewalls, proxies, NAT) that might play a role.

Example in ImportRDListener.ps1

Replace Line

wmic /namespace:\\root\cimv2\TerminalServices PATH Win32_TSGeneralSetting Set-SSLCertificateSHA1Hash = "$($CertInStore.Thumbprint)"

with

# Win32_TSGeneralSetting Get-CimInstanz 
$tsGeneralSetting = Get-CimInstance -Namespace "root/CIMV2/TerminalServices" -ClassName Win32_TSGeneralSetting
# SSLCertificateSHA1Hash set
$tsGeneralSetting | Set-CimInstance -Property @{ SSLCertificateSHA1Hash = $certThumbprint }

Tested :)

@adrianvanderwal
Copy link

Thanks for the fix @TBobsin - got me out of a pickle today.

Can confirm that this fix works on Server 2025 and wacs 2.2.9.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants