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.

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

Basic PowerShell Tutorials
01. How to configure your desktop PC for Office 365 Administration - Link
02. How to connect to Office 365 via PowerShell - Link
03. How to create basic PowerShell scripts - Link
04. How to create basic PowerShell scripts with Export-CSV - Link
05. How to create basic PowerShell scripts with Import-CSV - Link

Series Tutorials -
How to manage Enterprise environments - Part 1 - Filtering queries - Link
How to manage Enterprise environments - Part 2 - Creating scripts with a filtered query - Link
How to manage Enterprise environments - Part 3 - Bulk management using multiple filters - Link

Tips and Tricks
General Tips and Tricks for better Office 365 Administration - Link
How to extend your Office 365 Trial - Link
How to get a 180 day trial tenant in Office 365 for testing - Link

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

No comments:

Post a Comment