Skip to content

Commit

Permalink
Merge pull request microsoft#5155 from NikCharlebois/AADApplication-L…
Browse files Browse the repository at this point in the history
…ogic-Fix-for-Beta-instance

AADApplication Fixes
  • Loading branch information
NikCharlebois authored Oct 7, 2024
2 parents 9e9aad1 + 3ed8681 commit dd20448
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# UNRELEASED

* AADApplication
* Fixed an issue trying to retrieve the beta instance.
* AADDeviceRegistrationPolicy
* Initial release.
* AADEntitlementManagementSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ function Get-TargetResource
Write-Verbose -Message 'An instance of Azure AD App was retrieved.'


$AADBetaApp= Get-MgBetaApplication -Property "id,displayName,appId,authenticationBehaviors" -ApplicationId $ObjectID -ErrorAction SilentlyContinue
$AADAppKeyCredentials = Get-MgApplication -Property "keyCredentials" -ApplicationId $ObjectID -ErrorAction SilentlyContinue
$AADBetaApp= Get-MgBetaApplication -Property "id,displayName,appId,authenticationBehaviors" -ApplicationId $AADApp.Id -ErrorAction SilentlyContinue
$AADAppKeyCredentials = Get-MgApplication -Property "keyCredentials" -ApplicationId $AADApp.Id -ErrorAction SilentlyContinue

$complexAuthenticationBehaviors = @{}
if ($null -ne $AADBetaApp.authenticationBehaviors.blockAzureADGraphAccess)
Expand Down Expand Up @@ -291,7 +291,7 @@ function Get-TargetResource
$mykeyCredentials.Add('KeyId', $currentkeyCredentials.keyId)


if($null -ne $currentkeyCredentials.Key)
if($null -ne $currentkeyCredentials.Key)
{
$mykeyCredentials.Add('Key', [convert]::ToBase64String($currentkeyCredentials.key))
}
Expand Down Expand Up @@ -629,7 +629,7 @@ function Set-TargetResource
if ($PasswordCredentials)
{
Write-Warning -Message "PasswordCredentials is a readonly property and cannot be configured."

}

if ($currentParameters.AvailableToOtherTenants)
Expand Down Expand Up @@ -934,7 +934,7 @@ function Set-TargetResource
if($needToUpdateKeyCredentials -and $KeyCredentials)
{
Write-Verbose -Message "Updating for Azure AD Application {$($currentAADApp.DisplayName)} with KeyCredentials:`r`n$($KeyCredentials| Out-String)"

if((currentAADApp.KeyCredentials.Length -eq 0 -and $KeyCredentials.Length -eq 1) -or (currentAADApp.KeyCredentials.Length -eq 1 -and $KeyCredentials.Length -eq 0))
{
Update-MgApplication -ApplicationId $currentAADApp.Id -KeyCredentials $KeyCredentials | Out-Null
Expand Down Expand Up @@ -1121,7 +1121,7 @@ function Test-TargetResource
}

$ValuesToCheck = ([Hashtable]$PSBoundParameters).clone()

$testTargetResource = $true

#Compare Cim instances
Expand All @@ -1134,13 +1134,13 @@ function Test-TargetResource
$testResult = Compare-M365DSCComplexObject `
-Source ($source) `
-Target ($target)

if (-not $testResult)
{
Write-Verbose "TestResult returned False for $source"
$testTargetResource = $false
}
else {
else {
$ValuesToCheck.Remove($key) | Out-Null
}
}
Expand Down

0 comments on commit dd20448

Please sign in to comment.