Deep Dive Into Office 365 PowerShell Cmdlets (Part 2)

by [Published on 7 April 2016 / Last Updated on 7 April 2016]

This article will focus on useful Office 365 PowerShell cmdlets that can help you reduce the time it takes to perform certain Office 365 WAAD tasks.

If you would like to read the other parts in this article series please go to:

In the first part of this article series, we gave an overview of Office 365 PowerShell cmdlets and how to install ‘Windows Azure Active Directory Module for Windows PowerShell” module for managing the Office 365 WAAD instance. As we explained, it is easy as pie to install and verify installation of Office 365 WAAD module by following the steps highlighted in the part 1 of this article series. You can get a list of PowerShell cmdlets available in “Windows Azure Active Directory Module for Windows PowerShell” by executing the “Get-Command –Noun Msol* | FL” command. The command returns a list of all the PowerShell modules that are available with the Office 366 WAAD PowerShell module and the DLL name that contains the execution instructions. If you wish to export a list of cmdlets to a text or a CSV file, you can use below commands:

  • Get-Command -Noun MSol* | Select-Object Name, DLL | Export-CSV AllMSOnLineCmdlets.CSV –NoTypeInformation
  • Get-Command -Noun MSol* | Select-Object Name, DLL > AllMSOnLineCmdlets.Txt

There are several PowerShell cmdlets that get installed when you install Azure Active Directory for Windows PowerShell. These PowerShell cmdlets allow you to manage users, groups, group role membership, domains, service principals, domains, single-sign-on, Office 365 subscription, user licenses, company information and administrative units. There are about 161 PowerShell cmdlets available to interact with Office 365 WAAD. For example, to work with Office 365 users, you will use cmdlets that have “user” noun in it. Similarly, to manage Office 365 groups, you will use cmdlets that have “group” noun in the cmdlet as shown in the two screenshots below:

Running “Get-Command –Noun MSolGroup* | FT –AutoSize” displays you a list of cmdlets that are applicable to the Office 365 Groups.

Image
Figure 1.0:
Getting the list of MSOL cmdlets that belong to Office 365 Groups

Running “Get-Command –Noun MSolUser* | FT –AutoSize” shows you a list of cmdlets that are applicable to the Office 365 user as shown in the screenshot below:

Image
Figure 1.1:
Getting the list of MSOL cmdlets that belong to Office 365 Users

“Get-Command –Noun” is very useful. It helps you get the list of available cmdlets for particular role/features/services. I have compiled a table that you can use to list the commands to manage a particular aspect of Office 365 WAAD.

Command to run

Office 365 Component

Get-Command –Noun MSolUser* | FT –AutoSize

To get a list of cmdlets available to manage Office 365 users.

Get-Command –Noun MSolGroup* | FT –AutoSize

Lists cmdlets that can be used to manage Office 365 groups.

Get-Command –Noun MSolDomain* | FT –AutoSize

This command shows the list of cmdlets available to work with Office 365 domains.

Get-Command –Noun MSolCompany* | FT –AutoSize

Lists cmdlets that belong to Company Information page in Office 365 Admin Center.

Get-Command –Noun MSolAdministrative* | FT –AutoSize

Cmdlets that can be used to manage administrative units in Office 365.

Get-Command –Noun MSolService* | FT –AutoSize

Returns the list of cmdlets that you can use to manage Service Principals in Office 365.

There are other cmdlets available, but we will only talk about the PowerShell cmdlets that are useful in the daily operational tasks. In other words, you may not find it useful to use all of the Office 365 PowerShell cmdlets to manage a WAAD instance. You need to pay attention as to what you will use these cmdlets for. For example, as an Office 365 user administrator, you might want to manage WAAD users. Similarly, a global Office 365 administrator might want to verify domain status, checking services status and checking DNS registration of domains registered with Office 365 subscription.

Before you can use any of these cmdlets to interact with Office 365 WAAD, you will need to connect to your Office 365 subscription. Microsoft provides a 30 day trial of Office 365. I would encourage you to start with a trial version of Office 365 to use these cmdlets. In the next and subsequent parts of this article series, I will offer advice on using Office 365 cmdlets to manage WAAD instance.

Connecting to an Office 365 Subscription

Once you have installed Azure Active Directory Module for Windows PowerShell, click start > search and then type “Windows Azure Active Directory”, right click on the shortcut and then open the PowerShell window using “Run As Administrator” action. You need to sign in to your Office 365 account before you can use any PowerShell cmdlets. To start using PowerShell cmdlets to manage Office 365 WAAD, run the “Connect-MsolService” PowerShell cmdlet. When you run “Connect-MsolService” a credential window will pop up as shown in the screenshot below.

Image
Figure 1.2

Type your Office 365 account name in “username@domainname” format and password to allow you to connect to Office 365 tenant as shown in the screenshot above.

Note:
It is important to note that Connect-MsolService PowerShell cmdlet does not return anything if the logon is successful. However, in case of a failed attempt, you will be shown an error message. In case you need to check whether your logon was successful or not, run any other cmdlets that might show you some information from the Office 365 subscription. For example, you can run Get-MsolSubscription cmdlet which should return the information about Office 365 you have connected to as shown in the screenshot below:

Image
Figure 1.3

Summary

In the first part of this article series, we gave an overview of Office 365 PowerShell cmdlets, and how to install ‘Windows Azure Active Directory Module for Windows PowerShell” module for managing the Office 365 WAAD instance.

As explained above, Get-Command PowerShell cmdlet can be used to get a list of cmdlets that you can use to manage a specific aspect of Office 365, for example users. To connect to an Office 365 subscription, you need to use Connect-MSolService cmdlet. In the next part of this article series, we will explain some useful examples on using WAAD cmdlets.

If you would like to read the other parts in this article series please go to:

See Also


The Author — Nirmal Sharma

Nirmal Sharma avatar

Nirmal Sharma is a MCSEx3, MCITP and was awarded the Microsoft MVP award in Directory Services and Windows Networking. He specializes in Microsoft Azure, Office 365, Directory Services, Failover Clusters, Hyper-V, PowerShell Scripting and System Center products. Nirmal has been involved with Microsoft Technologies since 1994. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles on various sites and contributing to PowerShell-based Dynamic Packs for www.ITDynamicPacks.Net solutions.