Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/syne0/osprey into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
syne0 committed Sep 11, 2024
2 parents 147f1fa 6294f3b commit 13c3d09
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions Osprey/internal/functions/Connect-Prerequisites.ps1
Original file line number Diff line number Diff line change
@@ -1,7 1,42 @@
Function Connect-Prerequisites {
#Connects to the modules Osprey needs to run.
Write-Information "Connecting to Exchange Online Powershell"
Connect-ExchangeOnline
Write-Information "Connecting to Graph API"
Connect-MgGraph -Scopes "User.Read.All", "Group.Read.All", "Domain.Read.All", "Directory.Read.All", "Application.Read.All"
if (Get-Module -FullyQualifiedName @{ModuleName = "ExchangeOnlineManagement"; RequiredVersion = "3.4.0" } -ListAvailable) {
Write-Host "Supported ExchangeOnlineManagment version installed"
Write-Host "Importing supported version"
}
else {
Write-Host "Supported ExchangeOnlineManagment version not installed"
Write-Host "Installing supported version"
remove-module exchangeonlinemanagement -ErrorAction SilentlyContinue
Install-module exchangeonlinemanagement -requiredversion 3.4.0
}
Try {
Write-Host "Importing ExchangeOnlineManagment"
Import-module exchangeonlinemanagement -RequiredVersion 3.4.0 -scope Local -ErrorAction Stop
Write-Host "Connecting to Exchange Online Powershell"
Connect-ExchangeOnline
}
catch {
Write-Host "Failed to import and connect to Exchange Online Powershell"
}

if (Get-Module -FullyQualifiedName @{ModuleName = "Microsoft.Graph"; RequiredVersion = "2.19.0" } -ListAvailable) {
Write-Host "Supported Graph API version installed"
Write-Host "Importing supported version"
}
else {
Write-Host "Supported Graph API version not installed"
Write-Host "Installing supported version"
remove-module Microsoft.Graph -ErrorAction SilentlyContinue
Install-module Microsoft.Graph -requiredversion 2.19.0
}
Try {
Write-Host "Importing Graph API"
Import-module Microsoft.Graph -RequiredVersion 2.19.0 -scope Local -ErrorAction Stop
Write-Host "Connecting to Graph API"
Connect-MgGraph -Scopes "User.Read.All", "Group.Read.All", "Domain.Read.All", "Directory.Read.All", "Application.Read.All"
}
catch {
Write-Host "Failed to import and connect to Graph API"
}
}

0 comments on commit 13c3d09

Please sign in to comment.