Skip to content

Commit

Permalink
earlier filtering of conflicting modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoung012 committed May 25, 2019
1 parent f4b2702 commit 7610d38
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions Update-AutomationAzureModulesForAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,15 @@ function Create-ModuleImportMapOrder([bool] $AzModuleOnly) {
$GetAutomationModule = $script:GetAzureRmAutomationModule
}

# Get all the modules in the current automation account
# Get all the non-conflicting modules in the current automation account
$CurrentAutomationModuleList = & $GetAutomationModule `
-ResourceGroupName $ResourceGroupName `
-AutomationAccountName $AutomationAccountName
-AutomationAccountName $AutomationAccountName |
?{
($AzModuleOnly -and ($_.Name -eq 'Az' -or $_.Name -like 'Az.*')) -or
(!$AzModuleOnly -and ($_.Name -eq 'AzureRM' -or $_.Name -like 'AzureRM.*')) -or
($_.Name -eq 'Azure' -or $_.Name -like 'Azure.*')
}

# Get the latest version of the AzureRM.Profile OR Az.Accounts module
$VersionAndDependencies = Get-ModuleDependencyAndLatestVersion $ProfileOrAccountsModuleName
Expand All @@ -324,16 +329,6 @@ function Create-ModuleImportMapOrder([bool] $AzModuleOnly) {
foreach ($Module in $CurrentAutomationModuleList) {
$Name = $Module.Name

# ignore conflicting modules
if ($AzModuleOnly) {
if ($Name -eq "AzureRM" -Or $Name -Like "AzureRM.*") {
continue
}
} else {
if ($Name -eq "Az" -Or $Name -Like "Az.*") {
continue
}
}
Write-Verbose "Checking dependencies for $Name"
$VersionAndDependencies = Get-ModuleDependencyAndLatestVersion $Module.Name
if ($null -eq $VersionAndDependencies) {
Expand Down

0 comments on commit 7610d38

Please sign in to comment.