We help IT Professionals succeed at work.

How run this script just for one OU?

Todd Mostowy
Todd Mostowy asked
I use this script for my AD user reviews and would like to run it on users in just one OU and the OU's listed under that.  So how do I do this and list that OU in the output?  Here is the script.

using Activeroles AD management shell (x64)

Get-QADUser -IncludedProperties userAccountControl, WhoCreatedBy -SizeLimit 0 | Select-Object SamAccountName, LastName, FirstName, HomeDrive, HomeDirectory, PasswordLastChanged, PasswordNeverExpires, PasswordLastSet, PasswordExpires, AccountExpires, AccountIsLockedOut, LastLogon, WhenCreated, WhoCreatedBy, @{n='UserAccountStatus';e={ $_.UserAccountControl }}, @{n='Groups';e={ $_ | Get-QADMemberOf | Select-Object -ExpandProperty Name }} | Export-Csv "20120125a.csv" -NoTypeInformation
Watch Question

Change your Get-QADUser to add this


Explore More ContentExplore courses, solutions, and other research materials related to this topic.