Exploring the API

At the time of writing this, there are 650 commands included in the Exchange module. The broad scope of the product makes it difficult to know and review all commands. Because the commands do not adhere to a naming convention, it is recommended that you target the module when searching for a command. Review previous chapters to see how to take advantage of the help features within PowerShell:

$exchangeModule = Get-Module -Name tmp_cozt5qry.a4u
$exchangeModule.ExportedCommands.Count

650

Get-Command -Module $exchangeModule -Name *User*

CommandType Name Version Source
----------- ---- ------- ------
Function Get-CsActiveUserReport 1.0 tmp_cozt5qry.a4u
Function Get-CsUserActivitiesReport 1.0 tmp_cozt5qry.a4u
Function Get-CsUsersBlockedReport 1.0 tmp_cozt5qry.a4u
Function Get-DeviceComplianceUserInventory 1.0 tmp_cozt5qry.a4u
...

Because the module is used for both the online and on-premise versions of Exchange, you can easily run into errors when trying to use a command or parameter that does not apply to your version.

In the following example, we used New-Mailbox without specifying the necessary parameters for online execution. The command defaults to asking you for the on-premise parameter UserPrincipalName and consequently fails with a misleading error message:

New-Mailbox -Name test4 -Password $pass

cmdlet New-Mailbox at command pipeline position 1
Supply values for the following parameters:
UserPrincipalName: [email protected]

The "UserPrincipalName" parameter can't be used on the "New-Mailbox" cmdlet because it isn't present in the role definition for the current user. Check the management roles assigned to you, and try again.

It is recommended that, before running any scripts in production, you first test your scripts in a development tenant. More importantly, review the documentation and parameter descriptions as they will indicate whether they can be used in the online version or not.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.44.182