Active Directory

How to Get AD User’s Group Membership

Posted on

To Get User’s security group membership Run below command: Get-ADPrincipalGroupMembership -Identity user  | where {$_.groupCategory -eq ‘Security’} |  add-adgroupmember -members USER To get all groups that a user is a member of Run below command: Get-ADPrincipalGroupMembership username | select name Name —- Domain Users Domain Computers Workstation Admins Company Users Company Developers AutomatedProcessingTeam Another command […]

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 = […]