How can I do the same think as the following WMIC commands in powershell?
wmic UserAccount where Name='LocalUser' set PasswordExpires=False
wmic useraccount where name='LocalUser' set passwordchangeable=false
With the WMI cmdlets available since version 2.0 of PowerShell, that would be something like:
Get-WmiObject Win32_UserAccount -Filter 'Name = "LocalUser"' |Set-WmiInstance -Arguments @{PasswordExpires=$false}
Get-WmiObject Win32_UserAccount -Filter 'Name = "LocalUser"' |Set-WmiInstance -Arguments @{PasswordChangeable=$false}
If you have PowerShell 5.1, you can use:
Set-LocalUser -Name 'LocalUser' -PasswordNeverExpires:$false -UserMayChangePassword:$false