Hi,
In my windows 2019 server, there are 20 users.
The users password is the same for everyone.
I need to change the password for all users on a daily basis.
can someone help me with a script?
Thank you
GH
Hi,
In my windows 2019 server, there are 20 users.
The users password is the same for everyone.
I need to change the password for all users on a daily basis.
can someone help me with a script?
Thank you
GH
You can do via PowerShell.
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/set-localuser?view=powershell-5.1#example-2--change-the-password-on-an-account
--please don't forget to Accept as answer if the reply is helpful--
Windows erver 2019
PS C:\Users\Administrator> $PSVersionTable.PSVersion
Major Minor Build Revision
5 1 17763 1852
What OS are you running the PowerShell on? You'll need WMF version 5.1 to have the LocalAccounts module so I'd check $PSVersionTable.PSVersion
Hi,
I run the program:
$ Password = Read-Host -AsSecureString
$ UserAccount = Get-LocalUser -Name "user030"
$ UserAccount | Set-LocalUser -Password $ Password
which asks me for the password
I type the password: 123Test)
and I get this error:
Get-LocalUser : The term 'Get-LocalUser' 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.
At line:2 char:16
+ $UserAccount = Get-LocalUser -Name "user030"
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-LocalUser:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Set-LocalUser : The term 'Set-LocalUser' 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.
At line:3 char:16
+ $UserAccount | Set-LocalUser -Password $Password
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-LocalUser:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
where I'm wrong?
Thanks for your help
That doesn't look right
PS C:\> $Password = Read-Host -AsSecureString ---this line prompts for a new password, then the password is stored as a secure string in the $Password variable
PS C:\> $UserAccount = Get-LocalUser -Name "User030" ---this line gets a user account named User030
PS C:\> $UserAccount | Set-LocalUser -Password $Password ---this line sets the new password on the user account
Thank you for your answer.
I don't know powershell.
I tried to change the password.
To user "user030" I have to put this password: 123 (Test):
$Password = Read-Host -AsSecureString
$UserAccount = Get-LocalUser -Name "user030"
$UserAccount | Set-LocalUser -123(Test) $Password
but the script gives me this error:
Get-LocalUser : The term 'Get-LocalUser' 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.
At line:2 char:16
+ $UserAccount = Get-LocalUser -Name "user030"
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-LocalUser:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Set-LocalUser : The term 'Set-LocalUser' 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.
At line:3 char:16
+ $UserAccount | Set-LocalUser -Password $Password
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-LocalUser:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
8 people are following this question.