Powershell Needful Things put that in your pipeline


Exchange 2013 Audit Script

Posted by Jean Louw

I finally had time to finish the last little issues with this script.

As with the Exchange 2010 script, this script can be used to audit various aspects of Exchange servers in the organization. Some administrators may deploy it as a morning check script, to check the health of the environment, while others may use it at client sites, as a quick overview of the server health.


- Audit Exchange 2013 servers including all features of the Exchange 2010 script.
- Added DAG health (get-mailboxdatabasecopystatus).
- Added certificates check to alert about expiring certificates.
- Colour coded some of the alerts to make them more visual.
- Updated the script output to a more Exchange 2013 look and feel.
- Added a check for the CU version of Exchange.
- Reduced the Event Log checks to 4 hours to increase speed, and reduce output size.

I have decided to make this script a GitHub project, so that anyone with PowerShell / Exchange knowledge can contribute to the project.

This script is a project I maintain in my free time, and which I provide to the community at no cost. If you like this script and use it in production, please help me keep this project free by considering a small donation.

The latest version of the script can be downloaded at https://github.com/technologicza/testexchange2013


Exchange 2013 Audit Script

Posted by Jean Louw

It has been a long time since I have posted anything on this blog, and with good reason. I started my own company a while ago, and it has consumed most of my time for the last couple of years.

I know that Exchange 2013 is something of the past, but I also know that it is very much still deployed in many organisations. Many of the subscribers to the blog have asked for an Exchange 2013 version of the script, and I have finally decided to sit down and complete it.

It will be available for download soon, so for now, please see below a screenshot of the result file.

Exchange 2013 Audit Report


Exchange 2010 Audit Script

Posted by Jean Louw

I have started development on the Exchange 2010 version of my Audit script.

If all goes well I intend to add the following features:

1. Location of database in the DAG
2. Mailbox count per database.
3. Current Mailbox count / server
4. Uncleared move requests and their status.
5. Exchange service pack and roll information
6. A new look and feel - more Exchange 2010-ish.

If time permits, I am aiming to have this ready by the 1st of January 2011.

Watch this space for updates, or join the email feed to stay updated.


Determine the source site of Outlook clients on Exchange server

Posted by Jean Louw

We have been toying with the idea of centralising our Exchange environment for a while now, and as part of this project, we needed to audit our Outlook clients, to determine which source site they were connecting from.

I was tasked with this, and was able to quickly gather this information, from both the Exchange 2003 and the 2007 environment, without too much hassle.

For Exchange 2007 simply use get-logonstatistics and select the information that you need. I added some additional spice, which exports each server to a separate CSV file.

foreach ($server in get-mailboxserver){
write-host "Current server: " $server
$filename = ".\" + $server + ".csv"
Get-LogonStatistics -server $server | select UserName, ClientIPAddress | sort UserName -Unique | Export-Csv $filename

Exchange 2003 is very similar, but as you can probably guess by now, you need to use WMI.

foreach ($server in (Get-ExchangeServer | Where {$_.IsExchange2007OrLater -eq $false})){
write-host "Current server: " $server
$filename = ".\" + $server + ".csv"
Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Logon -Computer $server | select MailboxDisplayName, ClientIP | sort MailboxDisplayName -Unique | Export-Csv $filename

My job done, I sent the CSV files of the project managers, only to find out that they thought it would be nice, to see exactly which site each IP address belonged to.

This proved to be a little more tricky, but after a few minutes of probing the Interwebs, I found a post where Shay uses nltest to get the site information for a computer.

I assimilated this into my script with a little DNS lookup to find the host name and came up with a function which will retrieve the site information for each IP address on the fly and add that to the CSV file.

function Get-ComputerSite ($ip){
Write-Host "Current IP:" $ip
$site = $null
$computer = [System.Net.Dns]::gethostentry($ip)
$site = nltest /server:$($computer.hostname) /dsgetsite
Return $site[0]

$ADSiteWMI = @{Name="ADSite";expression={Get-ComputerSite $($_.ClientIP)}}
$ADSite = @{Name="ADSite";expression={Get-ComputerSite $($_.ClientIPAddress)}}

foreach ($server in get-mailboxserver){
write-host "Current server: " $server
$filename = ".\" + $server + ".csv"
$LogonStats = Get-LogonStatistics -server $server | sort UserName -Unique
$LogonStats | select UserName, ClientIPAddress, $ADSite | Export-Csv $filename

foreach ($server in (Get-ExchangeServer | Where {$_.IsExchange2007OrLater -eq $false})){
write-host "Current server: " $server
$filename = ".\" + $server + ".csv"
$LogonStats = Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Logon -Computer $server | sort MailboxDisplayName -Unique
$LogonStats | select MailboxDisplayName, ClientIP, $ADSiteWMI | Export-Csv $filename

This does take some time to complete on servers with many connections, but it gets the results required. I have already noticed a few issues, and the script can do with a little more refinement.

I will post these updates as soon as I get round to adding them. For now, I hope this script can help someone else with a similar problem.

The complete script can be downloaded from here:


Exchange 2007 Audit Script – Version 3

Posted by Jean Louw

I have updated the Exchange 2007 audit script yet again!

Included in this update are two MAJOR changes, firstly, the script uses and publishes information using the new HTML format, as created by Virtu-Al.

This script, and the functions which create its HTML output are far more efficient and literally cut the number of lines in the script down by half. Not only is the code leaner, but it is also infinitely more legible, and adding new tests to the current script is a breeze. This version of the HTML output is also compatible with multiple browsers, including Mozilla and Chrome.

Secondly, the script will now detect pipeline input. You can still use a server list as a parameter to the script, but now, you can also pipe content to the script. This content can include your server list, or output from Exchange commands such as get-transportserver or get-mailboxserver etc. Be careful though, because commands like get-exchangeserver could include Exchange 2003 servers.
If no server list is specified or piped, the script will still get all Exchange 2007 servers.

As another minor addition, I have added an additional test (Test-OutlookWebServices) to the CAS servers.

As always, your comments and feedback is always welcome.

Complete version and download information can be found here:


Updated: Exchange 2007 audit script (Version 2)

Posted by Jean Louw

I have finally been able to complete the updates to my Exchange 2007 audit script.

The script has some enhancements which includes suggestions and comments from some readers.

The new script includes a few checks against CAS servers, which I feel have been neglected in the past. These checks include test-owaconnectivity and test-activesyncconnectivity. These two commands need some additional work to enable. To test if these command will work, you can run both test-owaconnectivity and test-activesyncconnectivity with the –ClientAccessServer switch.

Additional information will be available in the console if the commands are unable to run.

I have been meaning to update the HTML format, as designed and used by Virtu-Al, but I have been unable to find the time. This is definitely high on the priority list, as the new format is supported by multiple browsers, and cuts down the number of lines of code significantly. I really wanted to include the new HTML in this release, but it would have delayed the release by weeks.

Here is a complete list of changes:

  • You have the option to specify a list of servers to audit, if you don’t, the script will use get-exchangeserver to find servers to audit.
  • Changed disk space to values to gigabyte.
  • Added white space to mailbox store report. ( This is done with dotnet, and has been optimised to be really quick)
  • Added MAPI connectivity test to mailbox server report.
  • Added OWA connectivity report for CAS servers.
  • Added ActiveSync connectivity report for CAS servers.
  • Cleaned up some variable names.

I will release a newer version soon, which will include a few additional checks, and will also use the latest HTML code.

Your comments and suggestions are always welcome.

Complete version and download information can be found here: