How to create basic PowerShell scripts

Pre-requisites for this Tutorial
- Connect to On-Premises Exchange using Exchange Management Shell
or
- Connect to Online Exchange using PowerShell - Link
Note - the same cmdlets will work in either environment

-------------------------------------------------------------------------------------------

In this tutorial you will discover how easy it is to create your own basic scripts with just a few steps.
I am connecting to local On-Premises Exchange via the Exchange Management Shell

First we are going to run the simple cmd - Get-mailbox to see the local mailboxes

Get-Mailbox


















Now if you want to see some details about the mailboxes, you can use the same get-mailbox cmdlet but add the pipe symbol ( | ) and then fl. The fl is short for Format-List

Get-Mailbox | fl





































Once you run that, you will see that if you have multiple mailboxes, you receive too much information to be of any use.

So let's query just a single mailbox, VIP01 and pipe out the details of that mailbox only.

Get-Mailbox VIP01 | fl






































OK... so now that we only get the results of a single mailbox, it is much easier to read.
Now we can scroll through the results to find some mailbox attributes that we can add to our script to refine the results.


Get-Mailbox  VIP01 | fl  Name, DisplayName, PrimarySMTPAddress, UserPrincipalName






Congratulations - You have now the knowledge to create basic PowerShell scripts.

----------------------------------------------------------------------------------------

Check out a list of ALL of my tutorials here - Link


----------------------------------------------------------------------------------------

No comments:

Post a comment