Powershell Needful Things put that in your pipeline

Exchange 2007 Audit Script

The Exchange 2007 Audit script is a free script, which Exchange administrators can use to collect various parameters from a collection of Exchange 2007 servers. The results are then reported in a clean HTML report format, which can be uploaded to a web server.

This script can also be scheduled to run automatically and used as a daily check, to ensure that your Exchange 2007 environment is in good health.

Collections can be piped to the script from Exchange 2007 cmdlets such as Get-MailboxServer. The script will perform different check and tests, based on which roles are detected on the server.

The script will report on the health of the following items:

Basic OS / computer information
Exchange 2007 Rollups
Logical Disk configuration
OWA connectivity tests
ActiveSync connectivity tests
Outlook Web Services connectivity tests
Queue information
Mailbox database and whitespace
MAPI connectivity tests
Exchange Server services and event logs

I am always adding new features and bug fixes, so to stay up to date with the latest releases, follow me on Twitter or check back regularly.

CHANGE LOG
------------
V3.0
New multi-browser HTML format
Reduced the number of lines of code by half
The script now support pipeline input from other cmdlets
Added an additional test (Test-OutlookWebServices) to the CAS servers

V2.0
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.

V1.1
I now use [System.Diagnostics.EventLog]::GetEventLogs() to collect the remote event logs and entries instead of WMI
The output to the host displays exactly which event log it is busy reading.
The date range seems more accurate now when the event log contains a large amount of data.
The physical memory on the basic server information is now displayed as GB and is neatly rounded.
The Mailbox stores are sorted in alphabetical order by Store Name.
Added more verbose output to the console while the script runs, to give a better indication of what the script is busy with.

V1.0
Added Basic Information
Exchange Hotfixes
Disk Reports
Exchange queues for Hub Transport Servers
Mailbox Store Reports
Exchange Server Services and Event log reports.

An updated version of this script is available for Exchange 2010 here.

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 script can be downloaded from here:

Comments (27) Trackbacks (3)
  1. So, how would I add mailbox database size to the Mailbox stores section of the report. I have a seperate weekly report that gives me this info, it’s helpful in determining when I need to move users around as the quota approaches. I think it would be very helpfult match up the size in gb to teh users and white space.

  2. thank you so much for this… it really works well..

    For Exchange 2007:
    Do you know how i could get this to send an email?
    the scheduled task within windows 2003 donot work as well as the windows 2008.

    For Exchange 2010:
    It still populates the ifnromation into more than one file??

    Thank you again for the script.

    any help would be appreciated

    Shaun

    • Shaun,

      To get the script to make a single file, you have to run it with -output s on the command line.

      This forces all the results into a single file.

      As far as the email is concerned, I have suggested the following code to someone else:

      $messageParameters = @{
      Subject = “Exchange 2007 Audit Report – $((Get-Date).ToShortDateString())”
      Body = $fullReport
      Attachments = $Filename
      From = “report@domain.com”
      To = “rcpt@domain.com”
      SmtpServer = “1.1.1.1”
      }
      Send-MailMessage @messageParameters -BodyAsHtml

      You can then have the full report in the body, or you can have the report file (if it is a single file) as an attachment.

      I hope this helps.

      Jean

  3. Your script is awesome and it has helped me with my divesture project.
    When i run this script it tries to connect to all exchange servers in my organization and i just want it to run on 1 or couple of servers. I tried creating server.txt file in the same location from where the script is executing but it still collects data for all servers.
    I am just a beginer in PS scripting. Any help would be appreciated.

    Thanks
    Shahid

  4. Thanks Guys, I already managed to get the script running as i wanted.

  5. I need small help , i like your script , when when i tried with -output s , i did not get the single file , below is the example whihc i ran

    C:\>.\test-exchange2k7_V3.ps1 -output s

    2nd – now i want to send the output to email and i tried as mentioned above but where i need to add that syntax. pls help

  6. Can anyone please update as requested above ?

    • Hi Jugal,

      Sorry for the late reply, I have been out of town. I see the script on the site doesn’t contain the code for the single output file. I am not sure if it got lost during the site migration, or when I last updated the code. I will have to either re-code it, or see if I can get one of the previous versions somewhere.

      Emailing the script, you really have two options here, you can use this code at the bottom of the script, which others have used, you just need to customize it for your environment.

      $messageParameters = @{
      Subject = “Exchange 2007 Audit Report – $((Get-Date).ToShortDateString())”
      Body = $fullReport
      Attachments = $Filename
      From = “report@domain.com”
      To = “rcpt@domain.com”
      SmtpServer = “1.1.1.1″
      }
      Send-MailMessage @messageParameters -BodyAsHtml

      OR

      I have a version of the script, which writes to a web server to give you a page which you can visit daily to check the results. This code however I sell to my clients, so it is not available free on the site.

      I will keep you posted on the code to write out to a single file.

      Jean

  7. Thanks Jean for your reply now , i am able to get the report on email BUT As i have a CCR and CAS HUB server deployment but seems to be the report i am getting for NODE1 only, report is getting generated but through mail is coming for one ( NODE1) only. Or this is by design like if the report will run on one of the NODE then it will show that NODE only irrespective to the entire cluster.

  8. One more doubt , i hope this is not changing any configuration mean to say while running the script it is only collect the data ( GET Command) not writing anything to the server configuration . Correct ? as i liked but bit afraid off running the same in production environment. pls help

  9. Hi Jean, Did you get a time to look for one report exsist all the servers, as i mentioned above as i am able to get the report on email BUT As i have a CCR and CAS HUB server deployment but seems to be the report i am getting for NODE1 only, report is getting generated but through mail is coming for one ( NODE1) only. Or this is by design like if the report will run on one of the NODE then it will show that NODE only irrespective to the entire cluster.

    Thanks

    • Jugal,

      When you run the script against a CCR cluster, you should point the virtual name, not the nodes.

      The “Exchange Server” is the virtual instance.

      Jean

  10. Hi,

    This script is very useful but it’s not reporting the whitespace, the filed is blank?

    • Stephen, this value is obtained from the event log in Exchange 2007, so I have found that when people clear the log often, they have a blank value in the report.

  11. Jean, Pls share the updated script to make single file for exchange 2007

  12. Jean – I am getting ” You cannot call a method on a null-valued expression. At line: 266 char: 37 ” when trying to use you script. I am attempting to execute it in PowerGUI, on a external box, not my exchange server directly. Is that the cause? Does you script assume direct access to the exchange server?

    • The script can be executed from another server, but you have to be in the Exchange Management Shell, or in the case of 2007 have the snapin loaded prior to executing the script, as the script relies on the Exchange 2007 cmdlets.

  13. Hi, I run the script and next point should be changed
    Change from Get-WmiObject -ComputerName $Target Win32_LogicalDisk to -Class Win32_Volume as LogicalDisk doesn’t show all disks form system.

  14. I’m trying to figure out a way to put in:

    .\Get-StorageGroupCopyStatus
    and
    .\Get-StorageGroupCopyStatus -StandbyMachine

    …I’m in a bit of a loop here.
    Maybe you could shed some light here.

  15. Guys, I’ve done it before but completely forget anyone remember how to set the mailbox results to show more than 1000 user’s i know it’s -resultsize -unlimited but for the life of me can’t remember where to put it.

  16. It just hangs on
    “..getting queue details” for me
    Tried on both mbx and cas/hub server
    Environment is 2xcas/hub and 2xmbx in a ccr cluster. active/passive.

    • Hi there,

      It normally seems to “hang” if the event logs on the server are large. Please try saving and emptying the event logs, and try to run the script again.

      I hope this helps.

      Jean

  17. I have a list of users with the current primary smtp address and secondary address. I need to make the secondary address as primary in bulk using a csv file. The secondary address already exists on the users exchange mail account and just need to make it primary.

    Could not see anything online to make existing secondary smtp address as primary using a csv. Also is there particular fields I need in the csv file e.g. displayname or login name?, these values are not changing.

    Thanks


Leave a comment