Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions collect.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ param (

)

#Requires -Version 7.0

# Import the functions from the functions.ps1 script.
. .\lib\functions.ps1

Expand Down Expand Up @@ -142,7 +144,7 @@ if([string]::IsNullOrEmpty($StartDate) -and [string]::IsNullOrEmpty($EndDate)) {
#######################################

# Check if the required PowerShell modules are installed.
$requiredModules = @("ExchangeOnlineManagement", "AzureAD", "PowerShellGet","Microsoft.Graph")
$requiredModules = @("ExchangeOnlineManagement", "AzureAD", "PowerShellGet","Microsoft.Graph.Users","Microsoft.Graph.Identity.SignIns")
# Get the list of missing modules.
$missingModules = $requiredModules | Where-Object { !(Get-Module -Name $_ -ListAvailable) }

Expand Down Expand Up @@ -171,7 +173,7 @@ if ($missingModules) {
# Setup long running session
$PSO = New-PSSessionOption -IdleTimeout 43200000 # 12 hours
# For risky sign-ins we need the beta MgProfile
Select-MgProfile -Name 'beta'
# Select-MgProfile -Name 'beta'

if($AppAuthentication) {
Connect-ExchangeOnline `
Expand All @@ -182,12 +184,12 @@ if($AppAuthentication) {
-ShowBanner:$false

# Get the Tenant ID
$acc_context = Connect-AzAccount
$tenant_id = (Get-ConnectionInformation | Select-Object -First 1).TenantID

# Connect to MS Graph
Connect-MgGraph `
-ClientID $AppID `
-TenantId $acc_context.Context.Tenant.Id `
-TenantId $tenant_id `
-CertificateThumbprint $Cert
}
else {
Expand Down Expand Up @@ -479,15 +481,6 @@ finally {
Write-Host ""

Disconnect-ExchangeOnline -Confirm:$false
Disconnect-MgGraph

}