Search Domain for list of users inside a CSV file to Move them to a specific OU

The requirement was to collect list of users distributed over the domain to a specific OU, so we have to take the source of the data from a CSV file then search the domain for the content of this file to move the results to a specific OU.

Open  windows Power Shell:

Import-module activedirectory
$users= import-csv c:\SBCU.csv foreach ($user in $users) { Get-Aduser -filter "Samaccountname -eq ‘$($user.name)’" | Move-ADObject -TargetPath "ou=HRusers ,dc=Contoso,dc=Com" }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: