As powerful as Office 365 is, it can be made even more powerful with simple PowerShell cmdlets that can streamline your work and make your life easier. In today’s “Deep Dive,” we look at how to use PowerShell to manage Office 365 Exchange Online Services.
Previously in this series, we have explained the PowerShell cmdlets that you can use to manage Windows Azure Active Directory instance of an Office 365 tenant. We explained the use of Get-MsolUser, Get-MsolGroup, Add-MsolGroupMember and Remove-MsolGroupMember PowerShell cmdlets. We also explained how important Get-MsolUser PowerShell cmdlet is when it comes to collecting user information from Office 365 WAAD. Get-MsolUser PowerShell cmdlet plays an important role when collecting information such as Office 365 users licensing information, collecting membership of Office 365 users, and much more. We have provided examples of using Get-MsolUser and other cmdlets in Part 1 through Part 10. You may want to read Part 1 through Part 10 of this article series in case you need to know what Get-MsolUser cmdlet is capable of. (Links to these parts are at the end of this article.)
From this part forward, we are going to explain how you can manage other aspects of an Office 365 tenant using PowerShell. Microsoft provides the necessary PowerShell cmdlets to manage Exchange Online, SharePoint Online, Skype Online, and other services. The key here is that you need to know the PowerShell cmdlets that you can use to interact with Office 365 services. While you might have already worked with some of the Exchange Online PowerShell cmdlets, there are a few hidden PowerShell cmdlets that many Office 365 Admins are not aware of. We will start exploring PowerShell cmdlets available to manage Exchange Online Services and then move on to managing SharePoint and Skype services. In this part, we will provide the necessary steps to get you ready to work with Office 365 Exchange Online Services using PowerShell.
Before you can interact with Office 365 Exchange Online Services, it is important to note that there are a few requirements that you must meet:
Once you have met the above requirements, it is easy as pie to connect to Office 365 Exchange Online. All you need to do is follow the steps outlined below:
$O365Creds = Get-Credential
You will be prompted to enter your Office 365 credential. Enter the Office 365 Exchange Online credential that has Organization Management rights to manage Office 365 Exchange Online Services. Note that by default, only Global Administrator has the necessary permissions to connect to Office 365 Exchange Online Services. In case you are planning to use a different user, make sure to configure the Office 365 user and give him or her appropriate rights to interact with Office 365 Exchange Online Services. To ensure the credential object was created successfully, what you can do is just type the $O365Creds in the PowerShell window. The PowerShell window should list the credential object with the username that you had used.
$Office365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $O365Creds -Authentication Basic -AllowRedirection
Note that in the above command, we are storing connection information in a variable. We are using the credentials stored in the $O365Creds variable to successfully authenticate against Office 365 Exchange Online.
Import-PSSession $Office365Session -DisableNameChecking
Note that the above command connects to Office 365 Exchange Online Services using the credentials stored in the $O365Creds and also imports the necessary Exchange Online PowerShell modules. As you noticed, we used “-DisableNameChecking” parameter in the above command. When you import a module or cmdlets that have unapproved verbs in their names, the PowerShell window will display a warning. The warning indicates that the some PowerShell commands have unapproved verbs that might make them less predictable. You can safely ignore the warning. All required PowerShell modules to manage Exchange Online will still be imported.
In the next part of this article series, we will continue to focus on Office 365 Exchange Online Services and explain some useful PowerShell cmdlets that will help you interact with Office 365 Exchange Online Services.
If you would like to read the other parts in this article series, here are the links:
In what may be a landmark case, Google faces a hefty fine if it is found guilty of violating GDPR…
Sometimes, old wisdom is the best wisdom. Protect your data with these IT security best practices that have proven effective…
Today’s Xtreme Podcast: Shining a light on dark data, legacy security tools, and hacking stats that will leave you more…
In most cyberattacks, hackers want you to know you’ve been compromised. But in cryptojacking, hackers want you to live in…
Businesses want to improve uptime, and optimizing every part of their technology stack for high availability is a significant step…
Cybercrime is bad and getting worse. Yes, these 10 hacking stats will scare you, but knowing about them can help…