From 2bccb41a16152d88dac84b15b1b1bab07f3ea6d1 Mon Sep 17 00:00:00 2001 From: Esco Date: Wed, 11 Sep 2024 14:00:25 +0200 Subject: [PATCH 1/3] Use Join-Path --- Modules/CIPPCore/CIPPCore.psm1 | 4 ++-- .../CIPPCore/Public/GraphHelper/Get-CippSamPermissions.ps1 | 6 +++--- Modules/CippExtensions/CippExtensions.psm1 | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Modules/CIPPCore/CIPPCore.psm1 b/Modules/CIPPCore/CIPPCore.psm1 index 12f13762d19c..93ce138d723d 100644 --- a/Modules/CIPPCore/CIPPCore.psm1 +++ b/Modules/CIPPCore/CIPPCore.psm1 @@ -1,5 +1,5 @@ -$Public = @(Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -Recurse -ErrorAction SilentlyContinue) -$Private = @(Get-ChildItem -Path $PSScriptRoot\private\*.ps1 -Recurse -ErrorAction SilentlyContinue) +$Public = @(Get-ChildItem -Path (Join-Path $PSScriptRoot "Public\*.ps1") -Recurse -ErrorAction SilentlyContinue) +$Private = @(Get-ChildItem -Path (Join-Path $PSScriptRoot "Private\*.ps1") -Recurse -ErrorAction SilentlyContinue) $Functions = $Public + $Private foreach ($import in @($Functions)) { try { diff --git a/Modules/CIPPCore/Public/GraphHelper/Get-CippSamPermissions.ps1 b/Modules/CIPPCore/Public/GraphHelper/Get-CippSamPermissions.ps1 index 0c356d839202..32ede8169d61 100644 --- a/Modules/CIPPCore/Public/GraphHelper/Get-CippSamPermissions.ps1 +++ b/Modules/CIPPCore/Public/GraphHelper/Get-CippSamPermissions.ps1 @@ -25,14 +25,14 @@ function Get-CippSamPermissions { if (!$SavedOnly.IsPresent) { $ModuleBase = Get-Module -Name CIPPCore | Select-Object -ExpandProperty ModuleBase - $SamManifestFile = Get-Item "$ModuleBase\Public\SAMManifest.json" - $AdditionalPermissions = Get-Item "$ModuleBase\Public\AdditionalPermissions.json" + $SamManifestFile = Get-Item (Join-Path $ModuleBase "Public\SAMManifest.json") + $AdditionalPermissions = Get-Item (Join-Path $ModuleBase "Public\AdditionalPermissions.json") $ServicePrincipals = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/servicePrincipals?$top=999&$select=appId,displayName,appRoles,publishedPermissionScopes' -tenantid $env:TenantID -NoAuthCheck $true $SAMManifest = Get-Content -Path $SamManifestFile.FullName | ConvertFrom-Json $AdditionalPermissions = Get-Content -Path $AdditionalPermissions.FullName | ConvertFrom-Json - $RequiredResources = $SamManifest.requiredResourceAccess + $RequiredResources = $SAMManifest.requiredResourceAccess $AppIds = ($RequiredResources.resourceAppId + $AdditionalPermissions.resourceAppId) | Sort-Object -Unique diff --git a/Modules/CippExtensions/CippExtensions.psm1 b/Modules/CippExtensions/CippExtensions.psm1 index d2bab13c84b9..ce47d5f7e719 100644 --- a/Modules/CippExtensions/CippExtensions.psm1 +++ b/Modules/CippExtensions/CippExtensions.psm1 @@ -1,5 +1,5 @@ -$Public = @(Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -Recurse -ErrorAction SilentlyContinue) -$Private = @(Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -Recurse -ErrorAction SilentlyContinue) +$Public = @(Get-ChildItem -Path (Join-Path $PSScriptRoot "Public\*.ps1") -Recurse -ErrorAction SilentlyContinue) +$Private = @(Get-ChildItem -Path (Join-Path $PSScriptRoot "Private\*.ps1") -Recurse -ErrorAction SilentlyContinue) $Functions = $Public + $Private foreach ($import in @($Functions)) { try { From 5b3969dc9d3f08b56ec9863aafb43be8f6f13403 Mon Sep 17 00:00:00 2001 From: Esco Date: Wed, 11 Sep 2024 14:00:52 +0200 Subject: [PATCH 2/3] CIPPDefaults cases sensitivity --- .../Activity Triggers/Push-ExecOnboardTenantQueue.ps1 | 4 ++-- .../Activity Triggers/Push-UpdatePermissionsQueue.ps1 | 4 ++-- .../CIPP/Settings/Invoke-ExecCPVPermissions.ps1 | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOnboardTenantQueue.ps1 b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOnboardTenantQueue.ps1 index f5316ac76a0e..bf9b17bb9dc9 100644 --- a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOnboardTenantQueue.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOnboardTenantQueue.ps1 @@ -312,8 +312,8 @@ Function Push-ExecOnboardTenantQueue { $LastCPVError = '' do { try { - Add-CIPPApplicationPermission -RequiredResourceAccess 'CippDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $Relationship.customer.tenantId - Add-CIPPDelegatedPermission -RequiredResourceAccess 'CippDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $Relationship.customer.tenantId + Add-CIPPApplicationPermission -RequiredResourceAccess 'CIPPDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $Relationship.customer.tenantId + Add-CIPPDelegatedPermission -RequiredResourceAccess 'CIPPDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $Relationship.customer.tenantId $CPVSuccess = $true $Refreshing = $false } catch { diff --git a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-UpdatePermissionsQueue.ps1 b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-UpdatePermissionsQueue.ps1 index cbdab980cb9a..d579d1ad77ec 100644 --- a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-UpdatePermissionsQueue.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-UpdatePermissionsQueue.ps1 @@ -23,8 +23,8 @@ function Push-UpdatePermissionsQueue { $DomainRefreshRequired = $true } Write-Information 'Updating permissions' - Add-CIPPApplicationPermission -RequiredResourceAccess 'CippDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $Item.customerId - Add-CIPPDelegatedPermission -RequiredResourceAccess 'CippDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $Item.customerId + Add-CIPPApplicationPermission -RequiredResourceAccess 'CIPPDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $Item.customerId + Add-CIPPDelegatedPermission -RequiredResourceAccess 'CIPPDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $Item.customerId Write-LogMessage -tenant $Item.defaultDomainName -tenantId $Item.customerId -message "Updated permissions for $($Item.displayName)" -Sev 'Info' -API 'UpdatePermissionsQueue' Write-Information 'Pushing CIPP-SAM admin roles' diff --git a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecCPVPermissions.ps1 b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecCPVPermissions.ps1 index e666476b7b6f..22f7f02c0307 100644 --- a/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecCPVPermissions.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecCPVPermissions.ps1 @@ -33,8 +33,8 @@ Function Invoke-ExecCPVPermissions { } else { $TenantFilter = $env:TenantID } - Add-CIPPApplicationPermission -RequiredResourceAccess 'CippDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $TenantFilter - Add-CIPPDelegatedPermission -RequiredResourceAccess 'CippDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $TenantFilter + Add-CIPPApplicationPermission -RequiredResourceAccess 'CIPPDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $TenantFilter + Add-CIPPDelegatedPermission -RequiredResourceAccess 'CIPPDefaults' -ApplicationId $ENV:ApplicationID -tenantfilter $TenantFilter Set-CIPPSAMAdminRoles -TenantFilter $TenantFilter $Success = $true } catch { From 2f3ee35078cfacb5f22c95ba478864041e0a478b Mon Sep 17 00:00:00 2001 From: Esco Date: Fri, 13 Sep 2024 19:31:33 +0200 Subject: [PATCH 3/3] NCrontab.Advanced.dll case sensetivity --- Modules/CIPPCore/Public/Get-CIPPTimerFunctions.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/CIPPCore/Public/Get-CIPPTimerFunctions.ps1 b/Modules/CIPPCore/Public/Get-CIPPTimerFunctions.ps1 index 9b6decda8af9..07bbb7e36a15 100644 --- a/Modules/CIPPCore/Public/Get-CIPPTimerFunctions.ps1 +++ b/Modules/CIPPCore/Public/Get-CIPPTimerFunctions.ps1 @@ -19,7 +19,7 @@ function Get-CIPPTimerFunctions { if (!('NCronTab.Advanced.CrontabSchedule' -as [type])) { try { - $NCronTab = Join-Path -Path $CIPPCoreModuleRoot -ChildPath 'lib\Ncrontab.Advanced.dll' + $NCronTab = Join-Path -Path $CIPPCoreModuleRoot -ChildPath 'lib\NCrontab.Advanced.dll' Add-Type -Path $NCronTab } catch {} }