Skip to content

Commit

Permalink
Merge pull request #30 from swissbuechi/enhanced-external-dependency-…
Browse files Browse the repository at this point in the history
…management

enhanced external dependency management
  • Loading branch information
swissbuechi authored May 24, 2023
2 parents 52e6704 + e42242f commit 553d215
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 43 deletions.
51 changes: 11 additions & 40 deletions AzureAdDeployer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'AzureAdDeployer.psm1'

# Version number of this module.
ModuleVersion = '2.16.4'
ModuleVersion = '2.16.5'

# Supported PSEditions
CompatiblePSEditions = @("Core")
Expand Down Expand Up @@ -50,20 +50,7 @@
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(
@{
ModuleName = "PnP.PowerShell";
ModuleVersion = "2.1.1";
Guid = "0b0430ce-d799-4f3b-a565-f0dca1f31e17"
}, @{
ModuleName = "ExchangeOnlineManagement";
ModuleVersion = "3.1.0";
Guid = "b5eced50-afa4-455b-847a-d8fb64140a22"
}, @{
ModuleName = "DnsClient-PS";
ModuleVersion = "1.1.0";
Guid = "698438cc-f80d-4b88-aa04-16e302c1f326"
})
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
Expand Down Expand Up @@ -128,31 +115,15 @@

# External dependent modules of this module
ExternalModuleDependencies = @(
@{
ModuleName = "Microsoft.Graph.Authentication";
ModuleVersion = "1.25.0";
Guid = "883916f2-9184-46ee-b1f8-b6a2fb784cee"
}, @{
ModuleName = "Microsoft.Graph.Users";
ModuleVersion = "1.25.0";
Guid = "71150504-37a3-48c6-82c7-7a00a12168db"
}, @{
ModuleName = "Microsoft.Graph.Identity.DirectoryManagement";
ModuleVersion = "1.25.0";
Guid = "c767240d-585c-42cb-bb2f-6e76e6d639d4"
}, @{
ModuleName = "Microsoft.Graph.DeviceManagement.Enrolment";
ModuleVersion = "1.25.0";
Guid = "447dd5b5-a01b-45bb-a55c-c9ecce3e820f"
}, @{
ModuleName = "Microsoft.Graph.Identity.SignIns";
ModuleVersion = "1.25.0";
Guid = "60f889fa-f873-43ad-b7d3-b7fc1273a44f"
}, @{
ModuleName = "Microsoft.Graph.Devices.CorporateManagement";
ModuleVersion = "1.25.0";
Guid = "39dbb3bc-1a84-424a-9efe-683be70a1810"
}
"PnP.PowerShell",
"ExchangeOnlineManagement",
"DnsClient-PS",
"Microsoft.Graph.Authentication",
"Microsoft.Graph.Users",
"Microsoft.Graph.Identity.DirectoryManagement",
"Microsoft.Graph.DeviceManagement.Enrolment",
"Microsoft.Graph.Identity.SignIns",
"Microsoft.Graph.Devices.CorporateManagement"
)

} # End of PSData hashtable
Expand Down
51 changes: 48 additions & 3 deletions public/Helper/Invoke-DependencyCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,50 @@ Function Get-AllModulesInstalled {
param (
[switch]$Install
)

$Dependencies = @(
@{
ModuleName = "PnP.PowerShell";
ModuleVersion = "2.1.1";
Guid = "0b0430ce-d799-4f3b-a565-f0dca1f31e17"
}, @{
ModuleName = "ExchangeOnlineManagement";
ModuleVersion = "3.1.0";
Guid = "b5eced50-afa4-455b-847a-d8fb64140a22"
}, @{
ModuleName = "DnsClient-PS";
ModuleVersion = "1.1.1";
Guid = "698438cc-f80d-4b88-aa04-16e302c1f326"
}, @{
ModuleName = "Microsoft.Graph.Authentication";
ModuleVersion = "1.27.0";
Guid = "883916f2-9184-46ee-b1f8-b6a2fb784cee"
}, @{
ModuleName = "Microsoft.Graph.Users";
ModuleVersion = "1.27.0";
Guid = "71150504-37a3-48c6-82c7-7a00a12168db"
}, @{
ModuleName = "Microsoft.Graph.Identity.DirectoryManagement";
ModuleVersion = "1.27.0";
Guid = "c767240d-585c-42cb-bb2f-6e76e6d639d4"
}, @{
ModuleName = "Microsoft.Graph.DeviceManagement.Enrolment";
ModuleVersion = "1.27.0";
Guid = "447dd5b5-a01b-45bb-a55c-c9ecce3e820f"
}, @{
ModuleName = "Microsoft.Graph.Identity.SignIns";
ModuleVersion = "1.27.0";
Guid = "60f889fa-f873-43ad-b7d3-b7fc1273a44f"
}, @{
ModuleName = "Microsoft.Graph.Devices.CorporateManagement";
ModuleVersion = "1.27.0";
Guid = "39dbb3bc-1a84-424a-9efe-683be70a1810"
}
)

$AllModulesInstalled = $true
$AvailableModules = Get-Module -ListAvailable
foreach ($Dependency in $script:Dependencies) {
foreach ($Dependency in $Dependencies) {
$Module = $AvailableModules | Where-Object { $_.Name -eq $Dependency.ModuleName -and $_.Version -eq $Dependency.ModuleVersion }
if ($null -eq $Module) {
if ($Install) {
Expand All @@ -13,10 +54,14 @@ Function Get-AllModulesInstalled {
}
else {
Write-Host "Module $($Dependency.ModuleName) with version $($Dependency.ModuleVersion) is not installed. Please install it first." -ForegroundColor Red
Write-Host "Install-Module -Name $($Dependency.ModuleName) -RequiredVersion $($Dependency.ModuleVersion) -Force"
$AllModulesInstalled = $false
}
}
}
return $AllModulesInstalled
if (-not ($AllModulesInstalled)) {
Write-Host "Install dependencies: aaddepl -InstallDependencies"
}
if (-not ($Install)) {
return $AllModulesInstalled
}
}

0 comments on commit 553d215

Please sign in to comment.