Sometimes you just want to quickly connect to Exchange Online and Azure Active Directory only to update some user or mailbox configurations. As much as I love my script that connects to ALL of the Office 365 services in one hit, sometimes I just want to connect NOW and I don't need connections to SharePoint and other services.
That is where this new(ish) script comes in. I originally created it on January 2017, and as my very first connection script, it was very basic, and only connected to Exchange Online and Azure AD v1 (MSOL). Not long after that, I updated the script to v2 (Link) and it included connection to ALL Office 365 services. The updated v2 script is extremely popular and it has nearly 3,000 downloads to date.
I ignored the original script as I was happy with the new version, and I even put an update on TechNet advising about version 2, but people found it organically and it has now racked up nearly 1,500 downloads.
Pretty impressive as I have never promoted it via my social media presence!
So here it is, what is old is new again.
*** Download and save my Exchange Online and Azure AD Connection script - Link - ***
I have spruced up the script a little bit and added connection to Azure AD v2, but it is still the nice, tight script I wrote all that time ago.
So if you just want to quickly connect to Exchange Online and Azure AD, this is the script for you !
-------------------------------------------------------------------------------------------------------
To connect to Office 365 and Azure AD via PowerShell, follow the steps below.
Pre-requisites - First you need to ensure your desktop PC is configured to connect to Office 365 via PowerShell.
Follow this tutorial to configure your desktop PC for Office 365 Administration - Link
I still recommend you install all the modules to ensure you can connect to all the Office 365 services when you need.
-------------------------------------------------------------------------------------------------------
Once your PC is configured, you will need to create a connection script.
*** Download and save my Exchange Online and Azure AD Connection script - Link - ***
Next, edit my connection script by opening the file in Notepad or PowerShell ISE.
I personally prefer PowerShell ISE as it provides visual cues when creating and editing scripts.
To edit the script in PowerShell ISE, open PowerShell ISE on the left side of your window, and have Windows Explorer open on the right. Browse to your download directory and drag the file -
Connect-Office365-Basic-v1-x.ps1 into PowerShell ISE.
You will need to edit the variable in the script to match your Office 365 tenant administrator login. Scroll down until you see the following section -
### Edit the variable with your details ###
In the 'Edit the variable section, you will see one variable to update.
Edit the variable -
$Cred = Get-credential "admin@tenant.onmicrosoft.com" - by entering your admin credentials
Original Script
Updated Script
Now that you have edited the variable with your admin credentials, save your connection script - Connect-Office365-Basic.ps1
---------------------------------------------------------------------------------------------
One of the great features of PowerShell ISE, is that you can edit and RUN your scripts from the same program. Once you have saved your script, simply click on the green arrow to run the script -
Once you click the green arrow and run the script, a PowerShell credential box will appear. This is prompting for your password for the Office 365 admin user that you edited in the script.
If you have correctly updated the script and saved it with your tenant admin user logon, the script will automatically populate the User name field with the logon you updated with.
Enter your password and then click OK -
A green progress bar will appear as it connects and verifies what permissions you have.
You will then have text appear similar to below.
If your connection script has run successfully, depending on your tenant configuration, you should not receive any errors.
To test and confirm successful connection to each of the three services, run the following cmdlets.
Test - Exchange Online
Get-Mailbox
Test - Azure AD v1.0
Get-MSOLUser
Test - Azure AD v2.0 Admin
Get-AzureADuser
===============================================================
Congratulations -
You have now confirmed that you can successfully connect via PowerShell to Exchange Online and Azure AD services via the Connect-Office365-Basic script.
----------------------------------------------------------------------------------
Check out a list of ALL of my tutorials here - Link
No comments:
Post a Comment