From fe3ec6155f4010329f1b3b9ed05aaa4f6f9d1f97 Mon Sep 17 00:00:00 2001 From: vividDuck <122105925+vividDuck@users.noreply.github.com> Date: Fri, 7 Jul 2023 00:24:49 +0100 Subject: [PATCH] upd cert auth for risky --- collect.ps1 | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) 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 } - - - - - - - - - -