2024-02-29 12:04:35 +05:30
<#
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Name : Connect to all the Microsoft services using PowerShell
Description : This script automatically installs all the required modules ( upon your confirmation ) and connects to the services
2025-04-03 18:47:34 +05:30
Version : 4.1
2024-02-29 12:04:35 +05:30
Website : o365reports . com
2025-04-03 18:47:34 +05:30
Script Highlights :
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
2024-02-29 12:04:35 +05:30
1 . This script connects to 9 Microsoft 365 services with a single cmdlet .
2 . Installs Microsoft 365 PowerShell modules . ie , Modules required for Microsoft 365 services are automatically downloaded and installed upon your confirmation .
3 . You can connect to one or more Microsoft 365 services via PowerShell using a single cmdlet .
4 . You can connect to Microsoft 365 services with MFA enabled account .
5 . For non-MFA account , you don ’ t need to enter credential for each service .
5 . The script is scheduler friendly . i . e . , credentials can be passed as a parameter instead of saving inside the script .
6 . You can disconnect all service connections using a single cmdlet .
7 . The script supports Certificate-Based Authentication ( CBA ) too .
For detailed script execution : https : / / o365reports . com / 2019 / 10 / 05 / connect-all -office - 365 -services -powershell /
2025-04-03 18:47:34 +05:30
Change Log :
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~
V1 . 0 ( Nov 01 , 2019 ) - File created
V2 . 0 ( Jan 21 , 2020 ) - Added support for MS Online and SharePoint PnP PowerShell modules
V3 . 0 ( Oct 06 , 2023 ) - Removed Skype for Business and minor usability changes
V4 . 0 ( Feb 29 , 2024 ) - Added support for MS Graph and MS Graph beta PowerShell modules
V4 . 1 ( Apr 03 , 2025 ) - Handled ClientId requirement for SharePoint PnP PowerShell module
2024-02-29 12:04:35 +05:30
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#>
2019-11-01 15:04:32 +05:30
Param
(
[ Parameter ( Mandatory = $false ) ]
[ switch ] $Disconnect ,
2024-02-29 12:04:35 +05:30
[ ValidateSet ( 'MSGraph' , 'MSGraphBeta' , 'ExchangeOnline' , 'SharePointOnline' , 'SharePointPnP' , 'SecAndCompCenter' , 'MSTeams' , 'MSOnline' , 'AzureAD' ) ]
[ string[] ] $Services = ( " ExchangeOnline " , 'MSTeams' , 'SharePointOnline' , 'SharePointPnP' , 'SecAndCompCenter' , " MSOnline " , " AzureAD " , 'MSGraph' , 'MSGraphBeta' ) ,
2019-11-01 15:04:32 +05:30
[ string ] $SharePointHostName ,
[ Switch ] $MFA ,
2024-02-29 12:04:35 +05:30
[ Switch ] $CBA ,
[ String ] $TenantName ,
[ string ] $TenantId ,
[ string ] $AppId ,
[ string ] $CertificateThumbprint ,
2019-11-01 15:04:32 +05:30
[ string ] $UserName ,
[ string ] $Password
)
#Disconnecting Sessions
if ( $Disconnect . IsPresent )
{
#Disconnect Exchange Online,Skype and Security & Compliance center session
2024-02-29 12:04:35 +05:30
Disconnect-ExchangeOnline -Confirm: $false -InformationAction Ignore -ErrorAction SilentlyContinue
2019-11-01 15:04:32 +05:30
#Disconnect Teams connection
2024-02-29 12:04:35 +05:30
Disconnect-MicrosoftTeams -ErrorAction SilentlyContinue
2019-11-01 15:04:32 +05:30
#Disconnect SharePoint connection
2024-02-29 12:04:35 +05:30
Disconnect-SPOService -ErrorAction SilentlyContinue
Disconnect-PnPOnline -ErrorAction SilentlyContinue
#Disconnect MS Graph PowerShell
Disconnect-MgGraph -ErrorAction SilentlyContinue
2019-11-01 15:04:32 +05:30
Write-Host All sessions in the current window has been removed . -ForegroundColor Yellow
}
else
{
if ( ( $UserName -ne " " ) -and ( $Password -ne " " ) )
{
$SecuredPassword = ConvertTo-SecureString -AsPlainText $Password -Force
$Credential = New-Object System . Management . Automation . PSCredential $UserName , $SecuredPassword
2024-02-29 12:04:35 +05:30
$CredentialPassed = $true
2019-11-01 15:04:32 +05:30
}
2024-02-29 12:04:35 +05:30
elseif ( ( ( $AppId -ne " " ) -and ( $CertificateThumbPrint -ne " " ) ) -and ( ( $TenantId -ne " " ) -or ( $TenantName -ne " " ) ) )
{
$CBA = $true
}
2019-11-01 15:04:32 +05:30
$ConnectedServices = " "
2024-02-29 12:04:35 +05:30
if ( $Services . Length -eq 9 )
2019-11-01 15:04:32 +05:30
{
$RequiredServices = $Services
}
else
{
$RequiredServices = $PSBoundParameters . Services
}
#Loop through each required services
Foreach ( $Service in $RequiredServices )
{
2024-02-29 12:04:35 +05:30
Write-Host Connecting to $Service . . . -ForegroundColor Green
2019-11-01 15:04:32 +05:30
Switch ( $Service )
{
#Module and Connection settings for Exchange Online module
ExchangeOnline
{
2024-02-29 12:04:35 +05:30
$Module = Get-InstalledModule -Name ExchangeOnlineManagement
2021-01-21 21:01:56 +05:30
if ( $Module . count -eq 0 )
2019-11-01 15:04:32 +05:30
{
2024-02-29 12:04:35 +05:30
Write-Host Required Exchange Online PowerShell module is not available -ForegroundColor yellow
2021-01-21 21:01:56 +05:30
$Confirm = Read-Host Are you sure you want to install module ? [ Y] Yes [N ] No
if ( $Confirm -match " [yY] " )
2019-11-01 15:04:32 +05:30
{
2024-02-29 12:04:35 +05:30
Install-Module ExchangeOnlineManagement -Scope CurrentUser
2021-01-21 21:01:56 +05:30
Import-Module ExchangeOnlineManagement
2019-11-01 15:04:32 +05:30
}
2021-01-21 21:01:56 +05:30
else
{
2024-02-29 12:04:35 +05:30
Write-Host EXO PowerShell module is required to connect Exchange Online . Please install module using Install-Module ExchangeOnlineManagement cmdlet .
2021-01-21 21:01:56 +05:30
}
Continue
}
2024-02-29 12:04:35 +05:30
if ( $CredentialPassed -eq $true )
{
Connect-ExchangeOnline -Credential $Credential -ShowBanner: $false
}
elseif ( $CBA -eq $true )
2021-01-21 21:01:56 +05:30
{
2024-02-29 12:04:35 +05:30
Connect-ExchangeOnline -AppId $AppId -CertificateThumbprint $CertificateThumbprint -Organization $TenantName -ShowBanner: $false
2019-11-01 15:04:32 +05:30
}
else
{
2024-02-29 12:04:35 +05:30
Connect-ExchangeOnline -ShowBanner: $false
2019-11-01 15:04:32 +05:30
}
2021-01-21 21:01:56 +05:30
If ( ( Get-EXOMailbox -ResultSize 1 ) -ne $null )
2019-11-01 15:04:32 +05:30
{
if ( $ConnectedServices -ne " " )
{
$ConnectedServices = $ConnectedServices + " , "
2021-01-21 21:01:56 +05:30
}
$ConnectedServices = $ConnectedServices + " Exchange Online "
2019-11-01 15:04:32 +05:30
}
2021-01-21 21:01:56 +05:30
}
2019-11-01 15:04:32 +05:30
2021-01-21 21:01:56 +05:30
#Module and Connection settings for AzureAD V1 (MSOnline module)
MSOnline
2019-11-01 15:04:32 +05:30
{
$Module = Get-Module -Name MSOnline -ListAvailable
if ( $Module . count -eq 0 )
{
Write-Host MSOnline module is not available -ForegroundColor yellow
$Confirm = Read-Host Are you sure you want to install module ? [ Y] Yes [N ] No
if ( $Confirm -match " [yY] " )
{
2024-02-29 12:04:35 +05:30
Install-Module MSOnline -Scope CurrentUser
2021-01-21 21:01:56 +05:30
Import-Module MSOnline
2019-11-01 15:04:32 +05:30
}
else
{
Write-Host MSOnline module is required to connect AzureAD . Please install module using Install-Module MSOnline cmdlet .
}
Continue
}
2024-02-29 12:04:35 +05:30
if ( $CredentialPassed -eq $true )
2019-11-01 15:04:32 +05:30
{
2024-02-29 12:04:35 +05:30
Connect-MsolService -Credential $Credential
}
elseif ( $CBA -eq $true )
{
Write-Host " MSonline module doesn't support certificate based authentication. Please enter the credential in the prompt "
2019-11-01 15:04:32 +05:30
Connect-MsolService
}
else
{
2024-02-29 12:04:35 +05:30
Connect-MsolService
2019-11-01 15:04:32 +05:30
}
If ( ( Get-MsolUser -MaxResults 1 ) -ne $null )
{
if ( $ConnectedServices -ne " " )
{
$ConnectedServices = $ConnectedServices + " , "
}
2021-01-21 21:01:56 +05:30
$ConnectedServices = $ConnectedServices + " MSOnline "
}
if ( ( $RequiredServices -contains " SharePoint " ) -eq " true " )
2019-11-01 15:04:32 +05:30
{
$SharePointHostName = ( ( Get-MsolDomain ) | where { $_ . IsInitial -eq " True " } ) . name -split " .onmicrosoft.com "
$SharePointHostName = ( $SharePointHostName ) . trim ( )
}
2021-01-21 21:01:56 +05:30
}
#Module and Connection settings for AzureAD V2 (AzureAD module)
AzureAD
{
$Module = Get-Module -Name AzureAD -ListAvailable
if ( $Module . count -eq 0 )
{
Write-Host AzureAD module is not available -ForegroundColor yellow
$Confirm = Read-Host Are you sure you want to install module ? [ Y] Yes [N ] No
if ( $Confirm -match " [yY] " )
{
2024-02-29 12:04:35 +05:30
Install-Module AzureAD -Scope CurrentUser
2021-01-21 21:01:56 +05:30
Import-Module AzureAD
}
else
{
Write-Host AzureAD module is required to connect AzureAD . Please install module using Install-Module AzureAD cmdlet .
}
Continue
}
2024-02-29 12:04:35 +05:30
if ( $CredentialPassed -eq $true )
{
$AzureAD = Connect-AzureAD -Credential $Credential
}
elseif ( $CBA -eq $true )
2021-01-21 21:01:56 +05:30
{
2024-02-29 12:04:35 +05:30
$AzureAD = Connect-AzureAD -ApplicationId $AppId -TenantId $TenantId -CertificateThumbprint $CertificateThumbprint
2021-01-21 21:01:56 +05:30
}
else
{
2024-02-29 12:04:35 +05:30
$AzureAD = Connect-AzureAD
2021-01-21 21:01:56 +05:30
}
2024-02-29 12:04:35 +05:30
#Check for Azure AD connectivity
If ( $AzureAD -ne $null )
2021-01-21 21:01:56 +05:30
{
if ( $ConnectedServices -ne " " )
{
$ConnectedServices = $ConnectedServices + " , "
}
2024-02-29 12:04:35 +05:30
$ConnectedServices = $ConnectedServices + " Azure AD "
2019-11-01 15:04:32 +05:30
}
}
#Module and Connection settings for SharePoint Online module
2024-02-29 12:04:35 +05:30
SharePointOnline
2019-11-01 15:04:32 +05:30
{
$Module = Get-Module -Name Microsoft . Online . SharePoint . PowerShell -ListAvailable
if ( $Module . count -eq 0 )
{
Write-Host SharePoint Online PowerShell module is not available -ForegroundColor yellow
$Confirm = Read-Host Are you sure you want to install module ? [ Y] Yes [N ] No
if ( $Confirm -match " [yY] " )
{
2024-02-29 12:04:35 +05:30
Install-Module Microsoft . Online . SharePoint . PowerShell -Scope CurrentUser
Import-Module Microsoft . Online . SharePoint . PowerShell -DisableNameChecking
2019-11-01 15:04:32 +05:30
}
else
{
Write-Host SharePoint Online PowerShell module is required . Please install module using Install-Module Microsoft . Online . SharePoint . PowerShell cmdlet .
Continue
}
}
if ( ! ( $PSBoundParameters [ 'SharePointHostName' ] ) -and ( [ string ] $SharePointHostName -eq " " ) )
{
Write-Host SharePoint organization name is required . ` nEg : Contoso for admin @Contoso . Onmicrosoft . com -ForegroundColor Yellow
$SharePointHostName = Read-Host " Please enter SharePoint organization name "
}
2024-02-29 12:04:35 +05:30
if ( $CredentialPassed -eq $true )
2019-11-01 15:04:32 +05:30
{
Import-Module Microsoft . Online . SharePoint . PowerShell -DisableNameChecking
2024-02-29 12:04:35 +05:30
Connect-SPOService -Url https : / / $SharePointHostName -admin . sharepoint . com -credential $credential
}
elseif ( $CBA -eq $true )
{
Write-Host " SharePoint Online PowerShell module doesn't support certificate based authentication. Please enter credential in the prompt "
2019-11-01 15:04:32 +05:30
Connect-SPOService -Url https : / / $SharePointHostName -admin . sharepoint . com
}
else
{
2024-02-29 12:04:35 +05:30
Connect-SPOService -Url https : / / $SharePointHostName -admin . sharepoint . com
}
2019-11-01 15:04:32 +05:30
if ( ( Get-SPOTenant ) -ne $null )
{
if ( $ConnectedServices -ne " " )
{
$ConnectedServices = $ConnectedServices + " , "
}
2024-02-29 12:04:35 +05:30
$ConnectedServices = $ConnectedServices + " SharePoint Online "
2019-11-01 15:04:32 +05:30
}
}
2021-01-21 21:01:56 +05:30
#Module and Connection settings for Sharepoint PnP module
SharePointPnP
{
$Module = Get-InstalledModule -Name SharePointPnPPowerShellOnline
if ( $Module . count -eq 0 )
{
Write-Host SharePoint PnP module module is not available -ForegroundColor yellow
$Confirm = Read-Host Are you sure you want to install module ? [ Y] Yes [N ] No
if ( $Confirm -match " [yY] " )
{
2024-02-29 12:04:35 +05:30
Install-Module -Name SharePointPnPPowerShellOnline -AllowClobber -Scope CurrentUser
Import-Module SharepointpnpPowerShellOnline -DisableNameChecking
2021-01-21 21:01:56 +05:30
}
else
{
Write-Host SharePoint Pnp module is required . Please install module using Install-Module SharePointPnPPowerShellOnline cmdlet .
}
Continue
}
if ( ! ( $PSBoundParameters [ 'SharePointHostName' ] ) -and ( [ string ] $SharePointHostName -eq " " ) )
{
Write-Host SharePoint organization name is required . ` nEg : Contoso for admin @Contoso . com -ForegroundColor Yellow
$SharePointHostName = Read-Host " Please enter SharePoint organization name "
}
2025-04-03 18:47:34 +05:30
if ( $AppId -eq " " )
{
Write-Host ` nClient Id is mandatory to connect SharePoint PnP PowerShell -ForegroundColor Yellow
$AppId = Read-Host " Please enter client id to connect PnP PowerShell "
}
2024-02-29 12:04:35 +05:30
if ( $CredentialPassed -eq $true )
2021-01-21 21:01:56 +05:30
{
2025-04-03 18:47:34 +05:30
Connect-PnPOnline -Url https : / / $SharePointHostName -admin . sharepoint . com -credential $credential -ClientId $AppId -WarningAction Ignore
2024-02-29 12:04:35 +05:30
}
elseif ( $CBA -eq $true )
{
if ( $TenantName -eq " " )
{
Write-Host Tenant name is required . ` ne . g . contoso . onmicrosoft . com -ForegroundColor Yellow
$TenantName = Read-Host " Please enter your tenant name "
}
Connect-PnPOnline -Url https : / / $SharePointHostName -admin . sharepoint . com -ClientId $AppId -Thumbprint $CertificateThumbprint -Tenant $TenantName
2021-01-21 21:01:56 +05:30
}
2024-02-29 12:04:35 +05:30
else
2021-01-21 21:01:56 +05:30
{
2024-02-29 12:04:35 +05:30
2025-04-03 18:47:34 +05:30
Connect-PnPOnline -Url https : / / $SharePointHostName -admin . sharepoint . com -ClientId $AppId -WarningAction Ignore -Interactive
2024-02-29 12:04:35 +05:30
}
2021-01-21 21:01:56 +05:30
If ( $ ? -eq $true )
{
if ( $ConnectedServices -ne " " )
{
$ConnectedServices = $ConnectedServices + " , "
}
2024-02-29 12:04:35 +05:30
$ConnectedServices = $ConnectedServices + " SharePoint PnP "
2023-10-06 17:28:56 +05:30
}
}
2024-02-29 12:04:35 +05:30
#Module and Connection settings for Security & Compliance center
SecAndCompCenter
{
$Module = Get-InstalledModule -Name ExchangeOnlineManagement
2023-10-06 17:28:56 +05:30
if ( $Module . count -eq 0 )
{
2024-02-29 12:04:35 +05:30
Write-Host Exchange Online PowerShell module is not available -ForegroundColor yellow
2023-10-06 17:28:56 +05:30
$Confirm = Read-Host Are you sure you want to install module ? [ Y] Yes [N ] No
if ( $Confirm -match " [yY] " )
{
2024-02-29 12:04:35 +05:30
Install-Module ExchangeOnlineManagement -Scope CurrentUser
Import-Module ExchangeOnlineManagement
2023-10-06 17:28:56 +05:30
}
else
{
2024-02-29 12:04:35 +05:30
Write-Host EXO PowerShell module is required to connect Security and Compliance PowerShell . Please install module using Install-Module ExchangeOnlineManagement cmdlet .
2023-10-06 17:28:56 +05:30
}
Continue
}
2024-02-29 12:04:35 +05:30
if ( $CredentialPassed -eq $true )
2023-10-06 17:28:56 +05:30
{
2024-02-29 12:04:35 +05:30
Connect-IPPSSession -Credential $Credential -ShowBanner: $false
}
elseif ( $CBA -eq $true )
{
if ( $TenantName -eq " " )
{
Write-Host Orgnaization name is required . ` ne . g . contoso . onmicrosoft . com -ForegroundColor Yellow
$TenantName = Read-Host " Please enter your Organization name "
}
Connect-IPPSSession -AppId $AppId -CertificateThumbprint $CertificateThumbprint -Organization $TenantName -ShowBanner: $false
2023-10-06 17:28:56 +05:30
}
else
{
2024-02-29 12:04:35 +05:30
Connect-IPPSSession -ShowBanner: $false
2023-10-06 17:28:56 +05:30
}
2024-02-29 12:04:35 +05:30
$Result = Get-RetentionCompliancePolicy
If ( ( $ ? ) -eq $true )
2023-10-06 17:28:56 +05:30
{
if ( $ConnectedServices -ne " " )
{
$ConnectedServices = $ConnectedServices + " , "
}
2024-02-29 12:04:35 +05:30
$ConnectedServices = $ConnectedServices + " Security & Compliance Center "
2019-11-01 15:04:32 +05:30
}
}
2024-02-29 12:04:35 +05:30
#Module and Connection settings for Teams Online module
MSTeams
2019-11-01 15:04:32 +05:30
{
2024-02-29 12:04:35 +05:30
$Module = Get-InstalledModule -Name MicrosoftTeams -MinimumVersion 4.0 . 0
2021-01-21 21:01:56 +05:30
if ( $Module . count -eq 0 )
2019-11-01 15:04:32 +05:30
{
2024-02-29 12:04:35 +05:30
Write-Host Required MicrosoftTeams module is not available -ForegroundColor yellow
2021-01-21 21:01:56 +05:30
$Confirm = Read-Host Are you sure you want to install module ? [ Y] Yes [N ] No
if ( $Confirm -match " [yY] " )
2019-11-01 15:04:32 +05:30
{
2024-02-29 12:04:35 +05:30
Install-Module MicrosoftTeams -AllowClobber -Force -Scope CurrentUser
Import-Module MicrosoftTeams
2019-11-01 15:04:32 +05:30
}
else
{
2024-02-29 12:04:35 +05:30
Write-Host MicrosoftTeams module is required . Please install module using Install-Module MicrosoftTeams cmdlet .
2021-01-21 21:01:56 +05:30
}
Continue
}
2024-02-29 12:04:35 +05:30
if ( $CredentialPassed -eq $true )
2021-01-21 21:01:56 +05:30
{
2024-02-29 12:04:35 +05:30
$Teams = Connect-MicrosoftTeams -Credential $Credential
}
elseif ( $CBA -eq $true )
{
$Teams = Connect-MicrosoftTeams -ApplicationId $AppId -TenantId $TenantId -CertificateThumbPrint $CertificateThumbprint
2019-11-01 15:04:32 +05:30
}
else
{
2024-02-29 12:04:35 +05:30
$Teams = Connect-MicrosoftTeams
2019-11-01 15:04:32 +05:30
}
2024-02-29 12:04:35 +05:30
#Check for Teams connectivity
If ( $Teams -ne $null )
2019-11-01 15:04:32 +05:30
{
if ( $ConnectedServices -ne " " )
{
$ConnectedServices = $ConnectedServices + " , "
}
2024-02-29 12:04:35 +05:30
$ConnectedServices = $ConnectedServices + " MS Teams "
2019-11-01 15:04:32 +05:30
}
}
2024-02-29 12:04:35 +05:30
#Module and connection settings for MS Graph PowerShell
MSGraph
2019-11-01 15:04:32 +05:30
{
2024-02-29 12:04:35 +05:30
#Check for module installation
$Module = Get-Module -Name microsoft . graph -ListAvailable
if ( $Module . count -eq 0 )
{
Write-Host Microsoft Graph PowerShell SDK is not available -ForegroundColor yellow
$Confirm = Read-Host Are you sure you want to install module ? [ Y] Yes [N ] No
if ( $Confirm -match " [yY] " )
{
Write-host " Installing Microsoft Graph PowerShell module... "
Install-Module Microsoft . Graph -Repository PSGallery -Scope CurrentUser -AllowClobber -Force
Import-Module Microsoft . Graph . Users
}
else
{
Write-Host " Microsoft Graph PowerShell module is required. Please install module using Install-Module Microsoft.Graph cmdlet. "
}
Continue
}
if ( $CredentialPassed -eq $true )
2019-11-01 15:04:32 +05:30
{
2024-02-29 12:04:35 +05:30
Write-Host " MS Graph doesn't support passing credential as parameters. Please enter the credential in the prompt. "
Connect-MgGraph -NoWelcome
}
elseif ( $CBA -eq $true )
{
Connect-MgGraph -ApplicationId $AppId -TenantId $TenantId -CertificateThumbPrint $CertificateThumbprint -NoWelcome
}
else
{
Connect-MgGraph -NoWelcome
}
#Check for MS Graph connectivity
If ( ( Get-MgUser -Top 1 ) -ne $null )
{
if ( $ConnectedServices -ne " " )
2019-11-01 15:04:32 +05:30
{
2024-02-29 12:04:35 +05:30
$ConnectedServices = $ConnectedServices + " , "
}
$ConnectedServices = $ConnectedServices + " MS Graph "
}
}
#Module and connection settings for MS Graph Beta PowerShell
MSGraphBeta
{
#Check for module installation
$Module = Get-Module -Name microsoft . graph . beta -ListAvailable
if ( $Module . count -eq 0 )
{
Write-Host Microsoft Graph Beta PowerShell SDK is not available -ForegroundColor yellow
$Confirm = Read-Host Are you sure you want to install module ? [ Y] Yes [N ] No
if ( $Confirm -match " [yY] " )
{
Write-host " Installing Microsoft Graph Beta PowerShell module... "
Install-Module Microsoft . Graph . Beta -Repository PSGallery -Scope CurrentUser -AllowClobber -Force
Import-Module Microsoft . Graph . Beta . Users
2019-11-01 15:04:32 +05:30
}
else
{
2024-02-29 12:04:35 +05:30
Write-Host " Microsoft Graph Beta PowerShell module is required. Please install module using Install-Module Microsoft.Graph.Beta cmdlet. "
2019-11-01 15:04:32 +05:30
}
Continue
}
2024-02-29 12:04:35 +05:30
if ( $CredentialPassed -eq $true )
2019-11-01 15:04:32 +05:30
{
2024-02-29 12:04:35 +05:30
Write-Host " MS Graph Beta doesn't support passing credential as parameters. Please enter the credential in the prompt. "
Connect-MgGraph -NoWelcome
}
elseif ( $CBA -eq $true )
{
Connect-MgGraph -ApplicationId $AppId -TenantId $TenantId -CertificateThumbPrint $CertificateThumbprint -NoWelcome
2019-11-01 15:04:32 +05:30
}
else
{
2024-02-29 12:04:35 +05:30
Connect-MgGraph -NoWelcome
2019-11-01 15:04:32 +05:30
}
2024-02-29 12:04:35 +05:30
#Check for MS Graph Beta connectivity
If ( ( Get-MgBetaUser -Top 1 ) -ne $null )
2019-11-01 15:04:32 +05:30
{
if ( $ConnectedServices -ne " " )
{
$ConnectedServices = $ConnectedServices + " , "
}
2024-02-29 12:04:35 +05:30
$ConnectedServices = $ConnectedServices + " MS Graph Beta "
2019-11-01 15:04:32 +05:30
}
}
}
}
if ( $ConnectedServices -eq " " )
{
$ConnectedServices = " - "
}
2024-02-29 12:04:35 +05:30
Write-Host ` n ` nConnected Services - $ConnectedServices -ForegroundColor Cyan
Write-Host ` n ~ ~ Script prepared by AdminDroid Community ~ ~ ` n -ForegroundColor Green
Write-Host " ~~ Check out " -NoNewline -ForegroundColor Green ; Write-Host " admindroid.com " -ForegroundColor Yellow -NoNewline ; Write-Host " to get access to 1800+ Microsoft 365 reports. ~~ " -ForegroundColor Green ` n ` n
2019-11-01 15:04:32 +05:30
}
2024-02-29 12:04:35 +05:30