diff --git a/Setup.ps1 b/Setup.ps1 index bcf52f7..e17029a 100644 --- a/Setup.ps1 +++ b/Setup.ps1 @@ -68,6 +68,14 @@ function Get-OrCreateCountryNamedLocations { return $namedLocationIds } +# Ensure Microsoft Graph modules are installed +foreach ($module in @("Microsoft.Graph", "Microsoft.Graph.Beta", "ExchangeOnlineManagement")) { + if (-not (Get-Module -ListAvailable -Name $module)) { + Install-Module -Name $module -Scope CurrentUser -Force + } +} + +Write-Host "🔐 Connecting to MS Graph Online..." Connect-MgGraph -NoWelcome -Scopes ` "Policy.ReadWrite.SecurityDefaults", ` "Policy.ReadWrite.ConditionalAccess", ` @@ -75,8 +83,8 @@ Connect-MgGraph -NoWelcome -Scopes ` "Group.ReadWrite.All", ` "Directory.ReadWrite.All", ` "UserAuthenticationMethod.ReadWrite.All", ` - "Application.ReadWrite.All" - + "Application.ReadWrite.All", ` + "SecurityEvents.ReadWrite.All" Write-Host "Connected to Microsoft Graph" @@ -263,3 +271,4 @@ foreach ($u in $users) { } +