was successfully added to your cart.

8 Useful PowerShell Commands

By February 1, 2016 Tech

Useful Powershell Commands
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

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.

 
2. Force the Global Address Book to Update

Get-GlobalAddressList | update-GlobalAddressList
Get-AddressList | update-AddressList
Get-OfflineAddressBook | Update-OfflineAddressBook

 
3. Export users from a specific Security Group to a .csv file.

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.

 
4. Export a list of users that have access to a specific Public Folder and their Permissions to a .csv file

Get-PublicFolderClientPermission "\Finance" | select user, AccessRights | export-csv C:\finance.csv

Replace Finance with the folder you want.

 
5. Find a user’s Username using Email

get-recipient <"email address">

 
6. List all files in a folder & export them to a .csv file

Get-ChildItem -Path C:\Finance | Export-CSV C:\FinanceFiles.csv

 
7. Set an Email Auto-Reply

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).

 
8. Search All Mailboxes in Exchange and Place Found Emails in Your Mailbox

Get-Mailbox | Search-Mailbox -SearchQuery 'admin@hotmail.com' -TargetMailbox "PeterStavrou" -TargetFold
er "AdminHotmailEmails" -LogLevel Full

The above example will find all emails that contain admin@hotmail.com and will copy them to PeterStavrou‘s Mailbox under the folder AdminHotmailEmails.

Replace admin@hotmail.com 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?

Share Your Thoughts

 

Do NOT follow this link or you will be banned from the site!