Skip to main content

List Users in OU using Powershell

List Users in OU using Powershell

An application developer in my company needed to list users in OU with some specific properties. He wanted to get OU members and import in his application to perform some tasks. There are multiple ways to achieve this. The simplest way is to run Get-Aduser in Powershell on a domain controller.


Get-ADUser -SearchBase “OU=OUNAME,dc=Domain,dc=com” -Filter *

Here SearchBase is used to specify the OU name and path while Filter is used to filter out any results if you need, * is used to include everything.

If you have lots of users in the OU, then you may have to add -ResultSetSize  to the above command, “$Null” gives unlimited results.

Get-ADUser -SearchBase “OU=OUName,dc=Domain,dc=com” -Filter * -ResultSetSize $Null

Next, you can specify the properties you want to display

Get-ADUser -SearchBase “OU=OUName,dc=Domain,dc=com” -Filter * -ResultSetSize $Null | select Name, SamAccountName

List Users in OU using Powershell

Finally, if you want to export the result, you can use Export-csv as follows:

Get-ADUser -SearchBase “OU=OUName,dc=Domain,dc=com” -Filter * -ResultSetSize $Null | select Name, SamAccountName | export-csv D:\UserInOUList.csv

List Users in OU using Powershell Export

That’s it.

You can check my related article that i wrote  about listing Users by Mailbox Size in exchange.


Disable Password Reset in OWA

Disable Password Reset in OWA

One of my friend is who works as Exchange Admin in his company. He told me that his manager asked him if they can disable Password reset option in OWA. Because the security department requested to disable this option to meet their security compliance.

By default, user can change their passwords through Exchange 2013 Outlook Web App in their personal settings or directly opening this URL.

We can Disable the password reset option in for OWA in two ways in Exchange 2013.

Disable Change Password through Exchange Admin Center:

Login to the Exchange Admin Center  and go to the Servers on the left side.

Next click the “Virtual Directories” and select your Client Access Server and select OWA in Type as shown in this screenshot

EAC Virtual Directories

Double click the “OWA (Default Web Site)”, in the new windows select features and then uncheck the “Change Password”. Since this settings should be applied to all the client access servers in the domain, you will need to repeat this step for all of you rCAS Servers.

OWA Change Password

As these settings are stored in a Virtual Directory in IIS, hence the IIS should be restarted on all Client Access Servers for the settings to take effect.

Disable Change Password through Powershell:

To disable this option through Powershell, we need to run the following command:

Set-OwaVirtualDirectory -Identity <Identity> -ChangePasswordEnabled $false

In identity you should put “Server name \Virtual Directory name”. This is how i configured the client access servers:

Disable ChangePassword PS

  • First, run the get-OwaVirutalDirectory command to get the Client Access Server names and name of the Virtual Directories.
  • Next, run the command to disable the ChangePasswordEnabled option in both servers.
  • Finally, run the get-OwaVirutalDirectory again to confirm the settings have changed.

Similarly to the Exchange Admin Center method, you need to restart IIS service for the settings to apply.


Exchange 2013 Get Top Mailboxes by Size through Powershell

Get Top Mailboxes By Size in Powershell


One of my friend running exchange 2013 had mailbox database named DB3 size increasing rapidly, so he asked to help him get a list of Top 50 Mailbox users by size, so he can monitor these mailboxes.
As the problem was related to only Database named “DB3” so we only want report for that specific database.


The article describes step by step procedure on how to get Top Mailboxes By Size through Powershell in Exchange 2010 or Exchange 2013. Powershell makes it easy to get such kind of reports. So this is the final command i suggested him to run through Exchange Powershell
Get-mailboxdatabase -identity DB3 | Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,TotalItemSize -First 100 | Export-CSV Top50Mboxes-Db3.csvExplanation:Get-mailboxdatabase -identity DB3 this command gets the data from the Database DB3

Get-Mailbox -ResultSize Unlimited this command brings all of the mailboxes in this database

Get-MailboxStatistics this command brings the statistics about all the mailboxes in DB3

Sort-Object TotalItemSize -Descending this commands sorts the mailboxes by size (Largest first)

Select-Object DisplayName,TotalItemSize -First 50 now we can select the columns that we want to display and -first 50 gives us the top 50 mailboxes in DB3 by size.

Export-CSV D:Top50Mboxes-Db3.csv and finally we export the output to the csv on D: drive