Skip to content

Commit

Permalink
Merge pull request #5769 from NikCharlebois/PP-Fixes
Browse files Browse the repository at this point in the history
Fixing Power Platforms connection issues
  • Loading branch information
NikCharlebois authored Feb 13, 2025
2 parents ec585ae + 293406c commit 48a67bc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change log for Microsoft365DSC

# 1.25.212.2

* MISC
* Fixing connection errors in Power Platforms resources.

# 1.25.212.1

* AADApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function Get-TargetResource

$results = @{
DisplayName = $instance.properties.displayName
PolicyName = $instance.PolicyName
PolicyName = $instance.name
Environments = [array]$instance.properties.definition.constraints.environmentFilter1.parameters.environments.name
FilterType = $instance.properties.definition.constraints.environmentFilter1.parameters.filterType
Ensure = 'Present'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function Get-TargetResource
$AccessTokens
)

New-M365DSCConnection -Workload 'PowerPlatforms' `
New-M365DSCConnection -Workload 'PowerPlatformREST' `
-InboundParameters $PSBoundParameters | Out-Null

#Ensure the proper dependencies are installed in the current environment.
Expand Down Expand Up @@ -321,6 +321,7 @@ function Test-TargetResource
Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)"

#Compare Cim instances
$testResult = $true
foreach ($key in $PSBoundParameters.Keys)
{
$source = $PSBoundParameters.$key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ function Test-TargetResource

Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)"
Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)"
$testResult = $true

#Compare Cim instances
Write-Verbose -Message "Comparing CIMInstances"
Expand Down Expand Up @@ -399,10 +400,9 @@ function Export-TargetResource
"/providers/Microsoft.BusinessAppPlatform/scopes/admin/apiPolicies?api-version=2016-11-01"

[array]$policies = Invoke-M365DSCPowerPlatformRESTWebRequest -Uri $uri -Method 'GET'


$policies = $policies.value | Where-Object -FilterScript {$_.type -eq 'Microsoft.BusinessAppPlatform/scopes/apiPolicies'}
$dscContent = ''
if ($policies.value.Length -eq 0)
if ($policies.Length -eq 0)
{
Write-Host $Global:M365DSCEmojiGreenCheckMark
}
Expand All @@ -411,13 +411,13 @@ function Export-TargetResource
Write-Host "`r`n" -NoNewline
}
$i = 1
foreach ($policy in $policies.value)
foreach ($policy in $policies)
{
if ($null -ne $Global:M365DSCExportResourceInstancesCount)
{
$Global:M365DSCExportResourceInstancesCount++
}
Write-Host " |---[$i/$($policies.value.Count)] $($policy.properties.DisplayName)" -NoNewline
Write-Host " |---[$i/$($policies.Count)] $($policy.properties.DisplayName)" -NoNewline
$params = @{
PPTenantId = $tenantInfo
PolicyName = $policy.properties.DisplayName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ function Test-TargetResource

$driftedRules.($existingRule.TenantName) = @{
CurrentValue = "Direction: $($existingRule.Direction)"
DesiredValue = 'Should not exist'
DesiredValue = "Direction: $($rule.Direction)"
}
$result = $false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ function Set-TargetResource
Add-M365DSCTelemetryEvent -Data $data
#endregion

$ConnectionMode = New-M365DSCConnection -Workload 'PowerPlatforms' `
$ConnectionMode = New-M365DSCConnection -Workload 'PowerPlatformREST' `
-InboundParameters $PSBoundParameters

$SetParameters = $PSBoundParameters
Expand Down Expand Up @@ -1087,7 +1087,7 @@ function Set-M365DSCPPTenantSettings
$Body
)

$url = "$((Get-MSCloudLoginConnectionProfile -Workload 'PowerPlatforms').ResourceUrl)/providers/Microsoft.BusinessAppPlatform/scopes/admin/updateTenantSettings?api-version=2016-11-01"
$url = "$((Get-MSCloudLoginConnectionProfile -Workload 'PowerPlatformREST').ResourceUrl)/providers/Microsoft.BusinessAppPlatform/scopes/admin/updateTenantSettings?api-version=2016-11-01"

}

Expand All @@ -1100,9 +1100,9 @@ function Get-M365DSCPPTenantSettings
$Body
)

$url = "$((Get-MSCloudLoginConnectionProfile -Workload 'PowerPlatforms').ResourceUrl)/providers/Microsoft.BusinessAppPlatform/scopes/admin/getTenantSettings?api-version=2016-11-01"
$url = "$((Get-MSCloudLoginConnectionProfile -Workload 'PowerPlatformREST').ResourceUrl)/providers/Microsoft.BusinessAppPlatform/scopes/admin/getTenantSettings?api-version=2016-11-01"
$headers = @{
Authorization = (Get-MSCloudLoginConnectionProfile -Workload 'PowerPlatforms').AccessToken
Authorization = (Get-MSCloudLoginConnectionProfile -Workload 'PowerPlatformREST').AccessToken
}
Invoke-WebRequest -Uri $url -Headers $headers -ContentType "application/json"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
return @{
value = @(
@{
type = 'Microsoft.BusinessAppPlatform/scopes/apiPolicies'
PolicyName = "MyPolicy"
properties = @{
displayName = "DSCPolicy"
Expand Down

0 comments on commit 48a67bc

Please sign in to comment.