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 ‘$($’" | Move-ADObject -TargetPath "ou=HRusers ,dc=Contoso,dc=Com" }


Inactive Accounts in AD

There are many ways to find inactive accounts in Active Directory (i.e. computer or user accounts that have not logged to the domain for an extended period of time).”

There are many ways to accomplish the task.TechNet script center has a fair amount of scripts that deal with the problem:

However, in this post I’d like to shed some light  on a different method using the GUI instead of the command line.

You can use “Active Directory administrative center” (available in Windows 2008 R2 and above) to list inactive accounts.

From “global search”, select “add criteria” then “users with enabled accounts who have not logged on for more than this number of days”. You can modify the number of days by clicking on the number. For example, you can use the below filter to find users who have not logged on for 90 days (3 months)




You can see the equivalent LDAP query for the filter using the “convert to LDAP” radio button. Here you can also edit the LDAP query as you see fit. Note that the query makes use of the lastlogontimestamp attribute to find inactive accounts.

For a very good explanation of how lastlogontimestamp works, you can check the following article:

“The LastLogonTimeStamp Attribute” – “What it was designed for and how it works”




You can also edit the LDAP query to include both user and compute accounts by changing the objectClass in the LDAP query as follows:




Afterwards, you can easily select the search results and move them all to a separate OU to delete them later.

Make a New Storage Group and Mailbox Database in SCC Exchange 2007

To make a new Data base in a Exchange 2007 Single Copy Cluster (SCC) you have to take care of configuring the Disk Dependencies.

To Configure the Disk Dependencies in Cluster environment, I’m sharing the following articles:

If the disk you will use to create the SG is not added in the cluster, you need to add it.

Find AD users with most of their Attributes and save the result to a CSV file

Find Users who didn’t Login for specific period and Move them to Specific OU