Connect to all the Microsoft 365 Services

Connect to all the Microsoft 365 Services
This commit is contained in:
AdminDroid
2023-10-06 17:23:22 +05:30
parent 08a0301e4c
commit bddeec0a0c
23 changed files with 700 additions and 263 deletions

View File

@@ -1,10 +1,26 @@
<#
=============================================================================================
Name: Connect to all the Office 365 services using PowerShell
Description: This script automatically installs all the required modules(upon your confirmation) and connects to the services
Version: 3.5
Website: o365reports.com
1.Installs Office 365 PowerShell modules. ie, Modules required for Office 365 services are automatically downloaded and installed upon your confirmation.
2.You can connect to one or more Office 365 services via PowerShell using a single cmdlet.
3.You can connect to Office 365 services with MFA enabled account.
4.For non-MFA account, you dont need to enter credential for each service. Youll be asked to enter your credential only once!
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.
For detailed script execution: https://o365reports.com/2019/10/05/connect-all-office-365-services-powershell/
============================================================================================
#>
Param
(
[Parameter(Mandatory = $false)]
[switch]$Disconnect,
[ValidateSet('AzureAD','MSOnline','ExchangeOnline','SharePoint','SharePointPnP','SecAndCompCenter','Skype','Teams')]
[string[]]$Services=("AzureAD","MSOnline","ExchangeOnline",'SharePoint','SharePointPnP','SecAndCompCenter','Skype','Teams'),
[ValidateSet('MSOnline','AzureAD','ExchangeOnline','SharePoint','SharePointPnP','SecAndCompCenter','Teams')]
[string[]]$Services=("MSOnline","AzureAD","ExchangeOnline",'SharePoint','SharePointPnP','SecAndCompCenter','Teams'),
[string]$SharePointHostName,
[Switch]$MFA,
[string]$UserName,
@@ -37,7 +53,7 @@ else
$Credential=Get-Credential -Credential $null
}
$ConnectedServices=""
if($Services.Length -eq 8)
if($Services.Length -eq 7)
{
$RequiredServices=$Services
}
@@ -211,7 +227,7 @@ else
{
$ConnectedServices=$ConnectedServices+","
}
$ConnectedServices=$ConnectedServices+"SharePoint Online"
$ConnectedServices=$ConnectedServices+" SharePoint Online"
}
}
@@ -255,47 +271,7 @@ else
{
$ConnectedServices=$ConnectedServices+","
}
$ConnectedServices=$ConnectedServices+"SharePoint PnP"
}
}
#Module and Connection settings for Skype for Business Online module
Skype
{
$Module=Get-InstalledModule -Name MicrosoftTeams -MinimumVersion 1.1.6
if($Module.count -eq 0)
{
Write-Host Required MicrosoftTeams 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]")
{
Install-Module MicrosoftTeams -AllowClobber
}
else
{
Write-Host MicrosoftTeams module is required.Please install module using Install-Module MicrosoftTeams cmdlet.
}
Continue
}
if($MFA.IsPresent)
{
$sfbSession = New-CsOnlineSession
Import-PSSession $sfbSession -AllowClobber | Out-Null
}
else
{
$sfbSession = New-CsOnlineSession -Credential $Credential
Import-PSSession $sfbSession -AllowClobber -WarningAction SilentlyContinue | Out-Null
}
#Check for Skype connectivity
If ((Get-PSSession | Where-Object { $_.ConfigurationName -like "Microsoft.PowerShell" }) -ne $null)
{
if($ConnectedServices -ne "")
{
$ConnectedServices=$ConnectedServices+","
}
$ConnectedServices=$ConnectedServices+"Skype"
$ConnectedServices=$ConnectedServices+" SharePoint PnP"
}
}
@@ -338,16 +314,16 @@ else
}
#Module and Connection settings for Teams Online module
Teams
Teams
{
$Module=Get-InstalledModule -Name MicrosoftTeams -MinimumVersion 1.1.6
$Module=Get-InstalledModule -Name MicrosoftTeams -MinimumVersion 4.0.0
if($Module.count -eq 0)
{
Write-Host Required MicrosoftTeams 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]")
{
Install-Module MicrosoftTeams -AllowClobber
Install-Module MicrosoftTeams -AllowClobber -Force
}
else
{
@@ -370,7 +346,7 @@ else
{
$ConnectedServices=$ConnectedServices+","
}
$ConnectedServices=$ConnectedServices+"Teams"
$ConnectedServices=$ConnectedServices+" Teams"
}
}
}
@@ -379,5 +355,7 @@ else
{
$ConnectedServices="-"
}
Write-Host `n`nConnected Services $ConnectedServices -ForegroundColor DarkYellow
Write-Host `n`nConnected Services - $ConnectedServices -ForegroundColor DarkYellow
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
}