diff --git a/collect.ps1 b/collect.ps1 index 3106d0a..4204627 100644 --- a/collect.ps1 +++ b/collect.ps1 @@ -32,6 +32,8 @@ param ( ) +#Requires -Version 7.0 + # Import the functions from the functions.ps1 script. . .\lib\functions.ps1 @@ -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) } @@ -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 ` @@ -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 { @@ -479,15 +481,6 @@ finally { Write-Host "" Disconnect-ExchangeOnline -Confirm:$false + Disconnect-MgGraph } - - - - - - - - - -