Below you will find 8 PowerShell commands that will be useful to any Business Owner who has a Server and wants to do some technical work, or for any System Administrator that deals with user and email accounts on a daily basis.
Keep in mind that email related commands need to be entered in Exchange Management Shell and Windows related commands in Windows PowerShell.
Useful PowerShell Commands
- 1. Hide all Disabled Users from the GAL in Exchange
- 2. Force the Global Address Book to Update
- 3. Export users from a specific Security Group to a .csv file.
- 4. Export a list of users that have access to a specific Public Folder and their Permissions to a .csv file
- 5. Find a user’s Username using Email
- 6. List all files in a folder & export them to a .csv file
- 7. Set an Email Auto-Reply
- 8. Search All Mailboxes in Exchange and Place Found Emails in Your Mailbox
Get-Mailbox -OrganizationalUnit "Disabled Users" | Set-Mailbox -HiddenFromAddressListsEnabled $true
Replace Disabled Users with the name of the Organizational Unit that contains the users you would like to Hide from the Exchange address lists.
Get-GlobalAddressList | update-GlobalAddressList
Get-AddressList | update-AddressList
Get-OfflineAddressBook | Update-OfflineAddressBook
Get-ADGroupMember SG-Finance | select name | Export-Csv c:\finance.csv
Replace SG-Finance with the Security Group you would like to export users from.
Get-PublicFolderClientPermission "\Finance" | select user, AccessRights | export-csv C:\finance.csv
Replace Finance with the folder you want.
get-recipient <"email address">
Get-ChildItem -Path C:\Finance | Export-CSV C:\FinanceFiles.csv
Set-MailboxAutoReplyConfiguration PeterStavrou -AutoReplyState enabled -ExternalAudience all -InternalMessage “Please note, Peter Stavrou is on leave. Please contact our office on 03 9898 0100. Thank You” -ExternalMessage “Please note, Peter Stavrou Please contact our office on 03 9898 0100. Thank You”
Replace PeterStavrou with the User ID you want to set the auto-reply for.
Replace Please note, Peter Stavrou is on leave. Please contact our office on 03 9898 0100. Thank You with the auto-reply message you would like to use.
Please note that </br> is simply used to insert a line break (place text on the next line).
Get-Mailbox | Search-Mailbox -SearchQuery '[email protected]' -TargetMailbox "PeterStavrou" -TargetFold er "AdminHotmailEmails" -LogLevel Full
The above example will find all emails that contain [email protected] and will copy them to PeterStavrou‘s Mailbox under the folder AdminHotmailEmails.
Replace [email protected] with the word you would like to search for.
Replace PeterStavrou with the Mailbox ID that you want the emails copied to.
Replace AdminHotmailEmails with the folder name you would like to create in PeterStavrou’s mailbox to copy the emails into.
If you receive an error in Exchange PowerShell when using the search command then type in the below and try again.:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
What are your favorite PowerShell commands and what do they do?