PowerShell: List everything on a OU in a one line


To list all users in a OU, we can get it using Get-ADUser cmdlet. See the example below. (replace OU path in LDAP format to your own stuff and "Import-Module ActiveDirectory" before you run it). Get-ADUser -Filter * -SearchBase "cn=Users,dc=company,,dc=com" -properties title, department| Select-Object name,title,department Now what if you want everything (Users, Groups, Contacts, etc.,) … Continue reading PowerShell: List everything on a OU in a one line

PowerShell: Search User Accounts in Active Directory


Active Directory Module has many cmdlets to process many AD related tasks. BUT we don’t have simple search cmdlet. I had a requirement to check a list of users in AD to see if they exist or not. Get-ADUser doesn’t cut it for my requirement. If a user doesn’t exist, Get-ADUser errors out. So I … Continue reading PowerShell: Search User Accounts in Active Directory

Active Directory: Bulk User Password Reset by PowerShell


If you need to reset password for bulk number of user accounts, the following PowerShell scripts is for you. This first script requires an file with usernames listed one per line. Check the UserList.txt file location in this file. Change your favorite password in ConvertTo-SecureString cmdlet in this script. Then you are good go. ## … Continue reading Active Directory: Bulk User Password Reset by PowerShell

PowerShell 4.0: “Get-ADUser : One or more properties are invalid”


This applies to Get-ADComputer cmdlet too. When I try to get all properties of an AD account like Get-ADUser JohnDoe –Properties * it gives following error. Get-ADUser : One or more properties are invalid. Parameter name: msDS-AssignedAuthNPolicy It used to work in older PowerShell versions (Windows 8 or Windows 7). Now my scripts are all … Continue reading PowerShell 4.0: “Get-ADUser : One or more properties are invalid”

PowerShell: List Active Computers from Active Directory


I had a requirement to get list of active computers from Active Directory with some stored properties in computer account like OS, OS version and OU name where the computer account exists. I have defined the active computer as if LastLogonDate is less than 60 days. Here is the script. P.S. Your computer should be … Continue reading PowerShell: List Active Computers from Active Directory

(Updated) Active Directory: Account Lockout issues


Update: See the bottom of this blog on how to search SCOM event on account lockout. When yours or user’s account locked out frequently how do you find out which computer is sending bad passwords? I got few unconventional methods apart from Microsoft’s recommendations. First method is throw up your hands & say “I don’t … Continue reading (Updated) Active Directory: Account Lockout issues

When your service account is being locked out constantly….


This might be a bad idea. But this script helps at times when an service account is being locked out constantly, you need time to figure out how it is happening. I wrote this script and schedule to run every 5 minutes to scan my service account lockouts, unlock the account and send me an … Continue reading When your service account is being locked out constantly….

Active Directory: Copy a Group Members to a new Group


How would you copy the members (including users and groups) of GROUP-A to another group (GROUP-B)? I figured that out today. Open Active Directory Module for Windows PowerShell in Administrative Tools and type the following command. Get-ADGroupMember -Identity GROUP-A | Add-ADPrincipalGroupMembership -MemberOf GROUP-B Get-ADGroupMember gets all the members of GROUP-A and pipes into Add-ADPrincipalGroupMembership cmdlet … Continue reading Active Directory: Copy a Group Members to a new Group

Active Directory Group with more then 500 members: Icon changes for group members


Weird..huh! When I was asked why a AD group that contains Computer Objects and it shows computer names as User Icons. Well, its true that group had more then 500 computer objects. We supposed to see computer icons in members tab. It doesn't seem to affect it's functionality. Mystery! Love it. But it was an … Continue reading Active Directory Group with more then 500 members: Icon changes for group members

Power shell: How to list group members?


Every system admin gets request to send list of group members from all kinds of users.  It’s very easy if you know how to search Internet (Bing! anyone). Long back I posted VBScript to list the group members. Check here: https://anandthearchitect.wordpress.com/2008/10/18/get-members-list-from-a-domain-group-by-vbscript/ While back I posted an blog to list the AD group members using DSQuery … Continue reading Power shell: How to list group members?