diff --git a/EasyPIM/EasyPIM.psd1 b/EasyPIM/EasyPIM.psd1 index 13af90d..9144682 100644 --- a/EasyPIM/EasyPIM.psd1 +++ b/EasyPIM/EasyPIM.psd1 @@ -4,7 +4,7 @@ RootModule = 'EasyPIM.psm1' # Version number of this module. -ModuleVersion = '1.7.1' +ModuleVersion = '1.7.2' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/EasyPIM/functions/Get-PIMEntraRolePendingApproval.ps1 b/EasyPIM/functions/Get-PIMEntraRolePendingApproval.ps1 index b9a029c..068fdde 100644 --- a/EasyPIM/functions/Get-PIMEntraRolePendingApproval.ps1 +++ b/EasyPIM/functions/Get-PIMEntraRolePendingApproval.ps1 @@ -42,7 +42,7 @@ function Get-PIMEntraRolePendingApproval{ Write-Verbose "Get-PIMAzureResourcePendingApproval start with parameters: tenantID => $tenantID" - $endpoint="/roleManagement/directory/roleAssignmentScheduleRequests/filterByCurrentUser(on='approver')?$filter=status eq 'PendingApproval'" + $endpoint="/roleManagement/directory/roleAssignmentScheduleRequests/filterByCurrentUser(on='approver')?`$filter=status eq 'PendingApproval'" $response = Invoke-Graph -Endpoint $endpoint -Method "GET" $out = @() diff --git a/EasyPIM/internal/functions/Invoke-ARM.ps1 b/EasyPIM/internal/functions/Invoke-ARM.ps1 index 4f5a47d..6d58031 100644 --- a/EasyPIM/internal/functions/Invoke-ARM.ps1 +++ b/EasyPIM/internal/functions/Invoke-ARM.ps1 @@ -44,15 +44,19 @@ function Invoke-ARM { write-verbose "`n>> request body: $body" write-verbose "requested URI : $restURI ; method : $method" - $script:subscriptionID=[regex]::Matches($restURI,".*\/subscriptions\/(.*)\/providers.*$").groups[1].Value + #TODO need better way to handle mangement group scope!! + if($restURI -notmatch "managementgroups"){ + $script:subscriptionID=[regex]::Matches($restURI,".*\/subscriptions\/(.*)\/providers.*$").groups[1].Value - if ( $null -eq (get-azcontext) -or ( (get-azcontext).Tenant.Id -ne $script:tenantID ) ) { - Write-Verbose ">> Connecting to Azure with tenantID $script:tenantID" - Connect-AzAccount -Tenantid $script:tenantID -Subscription $script:subscriptionID + if ( $null -eq (get-azcontext) -or ( (get-azcontext).Tenant.Id -ne $script:tenantID ) ) { + Write-Verbose ">> Connecting to Azure with tenantID $script:tenantID" + Connect-AzAccount -Tenantid $script:tenantID -Subscription $script:subscriptionID + } } + - #todo replace with invoke-azrestmethod + #replaced with invoke-azrestmethod <# # Get access Token Write-Verbose ">> Getting access token"