Writing a basic script
We will write a simple script to report various Mailbox and Client Access settings such as Database Name, ActiveSyncMailboxPolicy
, DisplayName
, EmailAddress
, LastSuccessSync
time, and more for users with Exchange mailboxes.
The first step is to create a variable called $Usermailboxes
that will store a list of all the user mailboxes in the organization. Then, we have declared $Report
as an empty array to store objects for later purposes in the script. We then use another ForEach
to loop through each of the mailboxes and define a few additional variables to store various Mailbox and CAS settings for the mailboxes. $MailboxObject
is a new PSObject
created with our required properties using the Add-Member
cmdlet. Finally, the report will be exported to a CSV file in the C:\Scripts
folder with today's date.csv
format.
You can also add HTML formatting and send an e-mail to the administrators using a scheduled task:
$UserMailboxes = Get-Mailbox -ResultSize Unlimited $Report...