Powershell has alot of potential in it’s ability to allow .net functionality. This is also the reason why Microsoft has been using powershell alot in the backend of their services such as Windows 10 OS.
.Net has a powershell namespace called system.web.security https://docs.microsoft.com/en-us/dotnet/api/system.web.security.membership.generatepassword?view=netframework-4.8 In the namespace is a method called generatepassword that we can use to generate random passwords in powershell.
By default the namespace isn’t in powershell we have to add it first. This is very simple to do by running the cmd Add-Type -AssemblyName ‘System.Web’ Once added you can run this command to generate a random password in powershell. The 12 specifies length of password, and 1 is a value from 0-passwordlength that specifies how many alphanumerics to add. There isn’t an option to add no alphanumerics or only 1. As using 1 is just the minimum by default you will get more alphanumerics in the password as shown below.[System.Web.Security.Membership]::GeneratePassword(12,1)