Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/public/Initialize-AzOpsGlobalVariables.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,11 @@ function Initialize-AzOpsGlobalVariables {
Write-AzOpsLog -Level Verbose -Topic "Initialize-AzOpsGlobalVariables" -Message "Global Variable AzOpsState or AzOpsAzManagementGroup is not Initialized. Initializing it now"
# Get all managementgroups that principal has access to
$global:AzOpsPartialRoot = @()
# Initialize global variable for Management Groups
$global:AzOpsAzManagementGroup = @()

$managementGroups = (Get-AzManagementGroup -ErrorAction:Stop)
if ($RootScope -in ($managementGroups | Select-Object -Property Id).Id -or 1 -eq $global:AzOpsSupportPartialMgDiscovery) {
# Handle user provided management groups
if (1 -eq $global:AzOpsSupportPartialMgDiscovery -and $global:AzOpsPartialMgDiscoveryRoot) {
if (1 -eq $global:AzOpsSupportPartialMgDiscovery -and $global:AzOpsPartialMgDiscoveryRoot -match '.') {
$ManagementGroups = @()
Write-AzOpsLog -Level Verbose -Topic "Initialize-AzOpsGlobalVariables" -Message "Processing user provided root management groups"
$global:AzOpsPartialMgDiscoveryRoot -split ',' | ForEach-Object -Process {
Expand Down
8 changes: 4 additions & 4 deletions src/public/Initialize-AzOpsRepository.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function Initialize-AzOpsRepository {
Write-AzOpsLog -Level Verbose -Topic "Initialize-AzOpsRepository" -Message "Validating Azure AD Permissions for RoleAssignments/RoleDefinitions"
$TestAADCall = Get-AzADUser -First 1 -ErrorAction Stop
}
catch [System.Exception] {
catch [System.Exception] {
Write-AzOpsLog -Level Warning -Topic "Initialize-AzOpsRepository" -Message "Missing Directory.Read permissions in Azure AD Graph. Skipping discovery of RoleAssingments and RoleDefinitions"
$SkipRole = $true
}
Expand All @@ -123,9 +123,9 @@ function Initialize-AzOpsRepository {
process {
Write-AzOpsLog -Level Debug -Topic "Initialize-AzOpsRepository" -Message ("Initiating function " + $MyInvocation.MyCommand + " process")

#
if (1 -eq $global:AzOpsSupportPartialMgDiscovery -and $global:AzOpsPartialRoot) {
$RootScope = $AzOpsPartialRoot.id
# Set rootscope to discover, either partial or from the root mg
if (1 -eq $global:AzOpsSupportPartialMgDiscovery -and $global:AzOpsPartialRoot -match '.') {
$RootScope = $AzOpsPartialRoot.id | Sort-Object -Unique
}
else {
$RootScope = '/providers/Microsoft.Management/managementGroups/{0}' -f $TenantId
Expand Down