Connect-Maester
Overview
Connect-Maester is a helper command that simplifies the process of authenticating to the services required to run Maester tests including Microsoft Graph PowerShell, Azure PowerShell and Exchange Online PowerShell.
While Connect-Maester will handle the most common interactive authentication scenarios, it does not replicate all of the authentication options available in the respective modules.
The Connect-Maester command is completely optional if your current PowerShell session is already connected to Microsoft Graph using Connect-MgGraph.
Examining the code for Connect-Maester will reveal that it simply calls Connect-MgGraph.
What this means is that you can use Connect-MgGraph directly if you prefer to have more control over the authentication process. See the Connect-MgGraph: Microsoft Graph authentication documentation for more information on all the options available including the use of certificates, secrets, managed identities, different clouds and more.
Using Connect-Maester
Connect to Microsoft Graph
To connect to Microsoft Graph, use the following command:
Connect-Maester
Running Connect-Maester is the same as running the following:
Connect-MgGraph -Scopes (Get-MtGraphScope)
Send Mail and Teams message
Connects to Microsoft Graph with the Mail.Send scope in addition to the default Maester scopes. This allows you to use the required permission to send email when using the Send-MtMail command or when using Invoke-Maester -MailRecipient [email protected]
Connect-Maester -SendMail
This is the same as running
Connect-MgGraph -Scopes (Get-MtGraphScope -SendMail)
The same applies to the -SendTeamsMessage in Connect-Maester.
Privileged scope
Maester is designed to require read-only access to a tenant to run tests.
However, certain tests like Test-MtExoMoeraMailActivity require privileged permission scopes to call certain APIs. If the permission is not granted, the specific test will be skipped.
Connecting with privileged scopes is optional. To connect with privileged scopes, use the -Privileged switch:
Connect-Maester -Privileged
Device code
The -DeviceCode switch allows you to sign in using the device code flow. This will open a browser window to prompt for authentication and is useful on Windows when you want to avoid single signing on as the current user.
Connect-Maester -UseDeviceCode
Connect to Azure, Exchange Online and Teams
Connect-Maester also provides options to connect to Azure, Exchange Online and Teams for running tests that use the Azure PowerShell, Exchange Online PowerShell or Teams PowerShell modules.
The -All switch can be used to connect to all the services used by the Maester tests. This includes Microsoft Graph, Azure, Exchange Online, Security Compliance and Microsoft Teams.
Connect-Maester -Service All
If you need to connect to just a subset of the services you can specifiy them using the -Service parameter.
Connect-Maester -Service Azure,Graph,Teams
Connect to US Government, US DoD, China and Germany and other clouds
Connect-Maester also provides options to connect to the US Government, China and Germany clouds for Microsoft Graph, Azure and Exchange Online.
US Government
Connect-Maester -Environment USGov -AzureEnvironment AzureUSGovernment -ExchangeEnvironmentName O365USGovGCCHigh
US Department of Defense (DoD)
Connect-Maester -Environment USGovDoD -AzureEnvironment AzureUSGovernment -ExchangeEnvironmentName O365USGovDoD
China
Connect-Maester -Environment China -AzureEnvironment AzureChinaCloud -ExchangeEnvironmentName O365China
Germany
Connect-Maester -Environment Germany
Connect using a custom application
You can use Connect-Maester to connect to Microsoft Graph using a custom application by specifying the -GraphClientId parameter. This is useful if you wish to use a custom application for Maester instead of using the default Graph PowerShell application.
Connect-Maester -GraphClientId 'f45ec3ad-32f0-4c06-8b69-47682afe0216'
To learn more about how to create a custom application for Microsoft Graph PowerShell see Use delegated access with a custom application for Microsoft Graph PowerShell.