« Previous 1 2 3 4 Next »
Use PowerShell to manage Exchange Online
Its Master's Voice
Managing Office 365
In addition to managing Windows and Microsoft servers and Exchange Online with PowerShell, you can manage the other cloud services in Office 365 or Microsoft Azure. All commands can be executed in a single PowerShell session, and you do not have to use separate windows to manage local servers, Microsoft server applications, and cloud services. To manage Office 365 and Microsoft Azure, you do need to download and install additional modules on the server:
Install-Module -Name AzureAD
Next, install the Microsoft Online Services Sign-In Assistant [5] and the Office 365 management module:
Install-Module MSOnline
After you have installed the extensions, connect to your Office 365 account in PowerShell. To do this, use the Connect-MsolService
cmdlet. If PowerShell cannot find the module, use Import-Module MSOnline
to load it. In the window, use an administrator account to authenticate to Office 365, and then use
Get-Command *msol*
to view each cmdlet. In most cases of a failed logon to Office 365, you are experiencing problems with the logon wizard. If this happens, either install the latest version of the wizard or download the latest official version from the Office 365 site. Also, make sure you install the correct language and note that you cannot run multiple versions in parallel on one computer. You must always uninstall the previous version (with appwiz.cpl
) before you install the successor.
Office 365 Subscriptions
The Get-MsolDomain
cmdlet displays the domains used in your Office 365 subscription and their domain status. Get-MsolDomainVerificationDNS
queries domain data. You can use PowerShell to remove domains and define the default domain:
Set-MsolDomain -Name contoso.onmicrosoft.com -IsDefault
Once you have modified the default domain, you can delete any domains you no longer need:
Remove-MsolDomain -DomainName contoso.com
To view all the roles available for access in your Office 365 subscription, use Get-MsolRole
. Make sure the User Management Administrator role has additional rights for user management, such as password resets. Get-MsolUser
displays information about your users. For example, to display licensed users, type:
get-msoluser |ft UserPrincipalname, Displayname, *lic*
The -Autosize
option fits the table to the window. To manage a specific user's licenses use:
get-msoluser -userprincipalname "<UPN>" |select licenses, islicensed | fl
Licenses can also be assigned directly:
set-msoluserlicense -userprincipalname "<UPN>" -addlicenses "<license name>"
An exhaustive list of cmdlet capabilities is available online [6].
Managing Office 365 Users
In addition to the cmdlets already mentioned, other commands let you create, manage, or delete users in Office 365:
New-MsolUser
creates a new user and password (e.g.,New-MsolUser -UserPrincipalName "<email-address>" -DisplayName "<displayname>"
).Remove-MsolUser
deletes the user and releases the assigned licenses. In this way, the mailbox can be registered for another 30 days.Restore-MsolUser
restores the user's original status. This action works up to 30 days after the deletion.Set-MsolUser
customizes a user, changing their settings.Set-MsolUserPassword
changes a user's password.
To see all the cmdlets that manage users, use get-command *msoluser*
. You can also manage groups in Office 365 with PowerShell. To see those commands, type get-command *msolgroup*
.
« Previous 1 2 3 4 Next »
Buy this article as PDF
(incl. VAT)