PowerShell

How to Generate Random Password using PowerShell

Posted on

Try the below powershell script to generate random password as per required characters and length. With the help of below scrip you can configure complex passwords to services or any account user. function Generate-Password { $alphabets= “abcdefghijklmnopqstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()” $char = for ($i = 0; $i -lt $alphabets.length; $i++) { $alphabets[$i] } for ($i = 1; $i […]

PowerShell

How to List Local Administrators Using PowerShell

Posted on

Try the below script, in order to audit or list local administrators. Here is the VBScript Set objGroup = GetObject(“WinNT://./Administrators,group”) For Each objUser In objGroup.Members WScript.Echo “Member found: ” & objUser.Name Next set objGroup = Nothing Here is the Powershell syntax function LogToFile ([string]$strFileName, [string]$strComputer) { Add-Content $strFileName $strComputer } $strComputer = “.” $computer = […]