-
Notifications
You must be signed in to change notification settings - Fork 968
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
Conversation
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
Issue that prompted this PR: |
There was a problem hiding this 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?
$UserNoPasswd = Get-CimInstance Win32_UserAccount -Filter "Name='$Env:UserName'" | ||
$UserNoPasswd | Set-CimInstance -Property @{ PasswordExpires = $false } | ||
|
There was a problem hiding this comment.
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
?
$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 } | |
There was a problem hiding this comment.
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.
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 In the script I commented out line #335 and added above, the fix above, posted by @NerfBlasters, then ran the script without issue:
wmic useraccount here "name='${Env:UserName}'" set PasswordExpires=False |
@drumtechphoto not sure I understand your comment. Does the change in this pull request fix your issue or does it introduce a new issue for you? I think it fixes the issue for you too, but just to be sure before merging it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can go ahead and merge this PR. Thanks @NerfBlasters for the fix and everyone else for testing it out.
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