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

Replaced deprecated wmic cmd in install.ps1 #664

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NerfBlasters
Copy link

Replaces the deprecated and no longer included "wmic" command with Get-CimInstance. Verified functionality in a new 24H2 VM installation.

Verification:
Get-CimInstance Win32_UserAccount -Filter "Name='$Env:UserName'" -property PasswordExpires | select-object PasswordExpires

PasswordExpires

      False

Replaces the deprecated and no longer included "wmic" command with Get-CimInstance.  Verified functionality in a new 24H2 VM installation.

Verification:
PS C:\Users\Sus\Desktop> Get-CimInstance Win32_UserAccount -Filter "Name='$Env:UserName'" -property PasswordExpires | select-object PasswordExpires

PasswordExpires
---------------
          False
Replace deprecated wmic cmd in install.ps1
@NerfBlasters
Copy link
Author

Issue that prompted this PR:
#663

Copy link
Member

@Ana06 Ana06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was introduced in #658 to support Powershell x86. I have tested the change and seem to work fine. @PrajeetGuha can you please test if this change works for you too?

Comment on lines +335 to +337
$UserNoPasswd = Get-CimInstance Win32_UserAccount -Filter "Name='$Env:UserName'"
$UserNoPasswd | Set-CimInstance -Property @{ PasswordExpires = $false }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the variable name confusion, as it is just returning the user account, isn't it? What about $userAccount?

Suggested change
$UserNoPasswd = Get-CimInstance Win32_UserAccount -Filter "Name='$Env:UserName'"
$UserNoPasswd | Set-CimInstance -Property @{ PasswordExpires = $false }
$userAccount = Get-CimInstance Win32_UserAccount -Filter "Name='$Env:UserName'"
$userAccount | Set-CimInstance -Property @{ PasswordExpires = $false }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objections to that, I think that I was just trying to avoid $userAccount in case it was used somewhere else in the script. That was a long day and the variable name is confusing to me as well now that I've slept since then.

@PrajeetGuha
Copy link
Contributor

This code was introduced in #658 to support Powershell x86. I have tested the change and seem to work fine. @PrajeetGuha can you please test if this change works for you too?

tested it. works fine. good to go with merging.

@drumtechphoto
Copy link

This code was introduced in #658 to support Powershell x86. I have tested the change and seem to work fine. @PrajeetGuha can you please test if this change works for you too?

tested it. works fine. good to go with merging.

Hey Team,

Just wanted to let you know that this change to the .ps1 script does work in Win11 Pro 24H2:

Edition Windows 11 Pro
Version 24H2
Installed on ‎2/‎22/‎2025
OS build 26100.3194
Experience Windows Feature Experience Pack 1000.26100.48.0

In the script I commented out line #335 and added above, the fix above, posted by @NerfBlasters, then ran the script without issue:

Write-Host "[+] Setting password to never expire to avoid that a password expiration blocks the installation..."
Get-CimInstance Win32_UserAccount -Filter "Name='$Env:UserName'" -property PasswordExpires | select-object PasswordExpires

wmic useraccount here "name='${Env:UserName}'" set PasswordExpires=False

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

Successfully merging this pull request may close these issues.

4 participants