From dbbbc596de017dabf8500591c64d6699cbb619ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20MICHEL?= Date: Thu, 7 Nov 2024 21:26:23 +0100 Subject: [PATCH 1/3] fix fltering --- .../functions/Get-PIMEntraRolePendingApproval.ps1 | 2 +- EasyPIM/internal/functions/Invoke-ARM.ps1 | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) 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..fb2bac1 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" From 61746dd9163e0b97f1f35ef3789f66f25715d485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20MICHEL?= Date: Thu, 12 Dec 2024 16:47:15 +0100 Subject: [PATCH 2/3] 1.7.2 quickfix for invoke-arm with a managmentgroup scope --- EasyPIM/EasyPIM.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = @() From d6dd455b618974313be9d60348a4b03a6c59f129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20MICHEL?= Date: Thu, 12 Dec 2024 18:47:38 +0100 Subject: [PATCH 3/3] formating --- EasyPIM/internal/functions/Invoke-ARM.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyPIM/internal/functions/Invoke-ARM.ps1 b/EasyPIM/internal/functions/Invoke-ARM.ps1 index fb2bac1..6d58031 100644 --- a/EasyPIM/internal/functions/Invoke-ARM.ps1 +++ b/EasyPIM/internal/functions/Invoke-ARM.ps1 @@ -52,7 +52,7 @@ function Invoke-ARM { 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 - } + } }