- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the local user account settings using PowerShell?
To set the local user account settings related to the account or the password expiration, we can use the Set-LocalUser command.
The below command will change the local user Testuser account and password set to never expire.
Set-LocalUser -Name Testuser -AccountNeverExpires -PasswordNeverExpires $true -Verbose
The below command will set the account expiry,
Set-LocalUser -Name Testuser -AccountExpires 05/11/2022 -Verbose
To run the above commands on the remote computers, use the Invoke-Command.
Invoke-Command -ComputerName Computer1, computer2 -ScriptBlock{ Set-LocalUser -Name Testuser -AccountNeverExpires -PasswordNeverExpires $true -Verbose } Invoke-Command -ComputerName Computer1, computer2 -ScriptBlock{ Set-LocalUser -Name Testuser -AccountExpires 05/11/2022 -Verbose }
Advertisements