
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Generate a Strong Password Using PowerShell
To generate a strong password with the PowerShell, we can use 8 or more characters password. In the below example, we are going to use the 8 character password, you can change the number of characters as per your convenience.
This script you can bind into windows forms and provide it to the IT helpdesk to set the password for new users.
In this example, we will use the Random integers between 33 and 126 and convert it to the Character, considering them they are the ASCII values for characters.
You can find more about ASCII values in the table provided in the link.
https://www.rapidtables.com/code/text/ascii-table.html
Now we will see the explanation of the script and then finally write the script.
To get the random numbers between 33 and 126, Get-Random command is used.
Get-Random -Minimum 33 -Maximum 126
Once, you get the number, translate it into character by type conversion.
[char](Get-Random -Minimum 33 -Maximum 126)
We have not a single character, but we need 8 characters long password so you need to loop above commands 8 times and append each character to the previous character.
Example
[int]$passlength = 8 [string]$pass for($i=0; $i -lt $passlength; $i++){ $pass += [char](Get-Random -Minimum 33 -Maximum 126) } $pass
Output
EGS)^&hf