Skip to content

Commit

Permalink
Merge pull request #5341 from mpoulson/mpoulson/5339_5340
Browse files Browse the repository at this point in the history
Fixes Static references to graph.microsoft.com
  • Loading branch information
ykuijs authored Nov 6, 2024
2 parents 036eb41 + 2762a26 commit f7cbfa6
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 27 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@
export. We will only append a GUID if the IsSingleInstance property is not found on the resource.
* Add check in AADGroupSettings for NewUnifiedGroupWritebackDefault not existing in Government by default
FIXES [#5213](https://github.com/microsoft/Microsoft365DSC/issues/5213)
* Fix static refrences to graph.microsoft.com
FIXES [#5339](https://github.com/microsoft/Microsoft365DSC/issues/5339)
AADNetworkAccessForwardingPolicy. AADOrganizationCertificateBasedAuthConfiguration,
AADAuthenticationMethodPolicyExternal, AADEnrichedAuditLogs
FIXES [#5340](https://github.com/microsoft/Microsoft365DSC/issues/5340)
IntuneDeviceManagementEnrollmentAndroidGooglePlay, IntuneAppleMDMPushNotificationCertificate
* Fixes static OData refrences to graph.microsoft.com
AADApplication, AADEntitlementManagementAccessPackage, AADEntitlementManagementConnectedOrganization
AADServicePrincipal
FIXES [#5342](https://github.com/microsoft/Microsoft365DSC/issues/5342)
* DEPENDENCIES
* Updated Microsoft.Graph to version 2.24.0.
* Updated Microsoft.PowerApps.Administration.PowerShell to version 2.0.199.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ function Set-TargetResource
{
$Type = 'directoryObjects'
}
$ObjectUri = 'https://graph.microsoft.com/v1.0/{0}/{1}' -f $Type, $diff.InputObject
$ObjectUri = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + 'v1.0/{0}/{1}' -f $Type, $diff.InputObject
$ownerObject = @{
'@odata.id' = $ObjectUri
}
Expand Down Expand Up @@ -1136,7 +1136,7 @@ function Set-TargetResource
$onPremisesPublishingValue.Add('singleSignOnSettings', $singleSignOnValues)
$onPremisesPayload = ConvertTo-Json $onPremisesPublishingValue -Depth 10 -Compress
Write-Verbose -Message "Updating the OnPremisesPublishing settings for application {$($currentAADApp.DisplayName)} with payload: $onPremisesPayload"

$Uri = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/applications/$($currentAADApp.Id)/onPremisesPublishing"
Invoke-MgGraphRequest -Method 'PATCH' `
-Uri $Uri `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function Get-TargetResource
}
else
{
$response = Invoke-MgGraphRequest -Method Get -Uri "https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy/"
$response = Invoke-MgGraphRequest -Method Get -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/policies/authenticationMethodsPolicy/"
$getValue = $response.authenticationMethodConfigurations | Where-Object -FilterScript {$_.DisplayName -eq $DisplayName}
}
}
Expand Down Expand Up @@ -300,7 +300,7 @@ function Set-TargetResource
{
Write-Verbose -Message "Updating the Azure AD Authentication Method Policy External with name {$($currentInstance.displayName)}"

$response = Invoke-MgGraphRequest -Method Get -Uri "https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy/"
$response = Invoke-MgGraphRequest -Method Get -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/policies/authenticationMethodsPolicy/"
$getValue = $response.authenticationMethodConfigurations | Where-Object -FilterScript {$_.displayName -eq $currentInstance.displayName}

$params.Remove('displayName') | Out-Null
Expand All @@ -313,7 +313,7 @@ function Set-TargetResource
{
Write-Verbose -Message "Removing the Azure AD Authentication Method Policy External with Id {$($currentInstance.displayName)}"

$response = Invoke-MgGraphRequest -Method Get -Uri "https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy/"
$response = Invoke-MgGraphRequest -Method Get -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/policies/authenticationMethodsPolicy/"
$getValue = $response.authenticationMethodConfigurations | Where-Object -FilterScript {$_.displayName -eq $currentInstance.displayName}

Remove-MgBetaPolicyAuthenticationMethodPolicyAuthenticationMethodConfiguration -AuthenticationMethodConfigurationId $getValue.Id
Expand Down Expand Up @@ -505,7 +505,7 @@ function Export-TargetResource
{
#region resource generator code
$desiredType = "#microsoft.graph.externalAuthenticationMethodConfiguration"
$getPolicy = Invoke-MgGraphRequest -Method Get -Uri "https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy/"
$getPolicy = Invoke-MgGraphRequest -Method Get -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/policies/authenticationMethodsPolicy/"
$getValue = $getPolicy.AuthenticationMethodConfigurations | Where-Object -FilterScript {$_.'@odata.type' -eq $desiredType}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ function Set-TargetResource
if ($currentParameters.ContainsKey('ServicePrincipalFilterMode') -and $currentParameters.ContainsKey('ServicePrincipalFilterRule'))
{
#check if the custom attribute exist.
$customattribute = Invoke-MgGraphRequest -Method GET -Uri https://graph.microsoft.com/v1.0/directory/customSecurityAttributeDefinitions
$customattribute = Invoke-MgGraphRequest -Method GET -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "v1.0/directory/customSecurityAttributeDefinitions"
$ServicePrincipalFilterRule -match "CustomSecurityAttribute.(?<attribute>.*) -.*"
$attrinrule = $matches.attribute
if ($customattribute.value.id -contains $attrinrule){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function Set-TargetResource
}
}
$body = ConvertTo-Json $values -Depth 10 -Compress
Invoke-MgGraphRequest -Uri 'https://graph.microsoft.com/beta/networkAccess/settings/enrichedAuditLogs' -Method PATCH -Body $body
Invoke-MgGraphRequest -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + 'beta/networkAccess/settings/enrichedAuditLogs' -Method PATCH -Body $body
}

function Test-TargetResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ function Set-TargetResource
foreach ($incompatibleAccessPackage in $IncompatibleAccessPackages)
{
$ref = @{
'@odata.id' = "https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackages/$incompatibleAccessPackage"
'@odata.id' = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/identityGovernance/entitlementManagement/accessPackages/$incompatibleAccessPackage"
}

New-MgBetaEntitlementManagementAccessPackageIncompatibleAccessPackageByRef `
Expand All @@ -368,7 +368,7 @@ function Set-TargetResource
foreach ($IncompatibleGroup in $IncompatibleGroups)
{
$ref = @{
'@odata.id' = "https://graph.microsoft.com/beta/groups/$IncompatibleGroup"
'@odata.id' = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/groups/$IncompatibleGroup"
}

New-MgBetaEntitlementManagementAccessPackageIncompatibleGroupByRef `
Expand Down Expand Up @@ -485,7 +485,7 @@ function Set-TargetResource
foreach ($incompatibleAccessPackage in $toBeAdded.InputObject)
{
$ref = @{
'@odata.id' = "https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackages/$incompatibleAccessPackage"
'@odata.id' = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/identityGovernance/entitlementManagement/accessPackages/$incompatibleAccessPackage"
}

New-MgBetaEntitlementManagementAccessPackageIncompatibleAccessPackageByRef `
Expand Down Expand Up @@ -522,7 +522,7 @@ function Set-TargetResource
{

$ref = @{
'@odata.id' = "https://graph.microsoft.com/beta/groups/$incompatibleGroup"
'@odata.id' = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/groups/$incompatibleGroup"
}

New-MgBetaEntitlementManagementAccessPackageIncompatibleGroupByRef `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ function Set-TargetResource
$directoryObjectType=$directoryObject.AdditionalProperties."@odata.type"
$directoryObjectType=($directoryObject.AdditionalProperties."@odata.type").split(".")|select-object -last 1
$directoryObjectRef=@{
"@odata.id" = "https://graph.microsoft.com/beta/$($directoryObjectType)s/$($sponsor)"
"@odata.id" = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/$($directoryObjectType)s/$($sponsor)"
}

New-MgBetaEntitlementManagementConnectedOrganizationExternalSponsorByRef `
Expand All @@ -459,7 +459,7 @@ function Set-TargetResource
$directoryObject = Get-MgBetaDirectoryObject -DirectoryObjectId $sponsor
$directoryObjectType=($directoryObject.AdditionalProperties."@odata.type").split(".")|select-object -last 1
$directoryObjectRef=@{
"@odata.id" = "https://graph.microsoft.com/beta/$($directoryObjectType)s/$($sponsor)"
"@odata.id" = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/$($directoryObjectType)s/$($sponsor)"
}

New-MgBetaEntitlementManagementConnectedOrganizationInternalSponsorByRef `
Expand Down Expand Up @@ -515,7 +515,7 @@ function Set-TargetResource
$directoryObjectType=$directoryObject.AdditionalProperties."@odata.type"
$directoryObjectType=($directoryObject.AdditionalProperties."@odata.type").split(".")|select-object -last 1
$directoryObjectRef=@{
"@odata.id" = "https://graph.microsoft.com/beta/$($directoryObjectType)s/$($sponsor)"
"@odata.id" = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/$($directoryObjectType)s/$($sponsor)"
}

New-MgBetaEntitlementManagementConnectedOrganizationExternalSponsorByRef `
Expand Down Expand Up @@ -553,7 +553,7 @@ function Set-TargetResource
$directoryObjectType=$directoryObject.AdditionalProperties."@odata.type"
$directoryObjectType=($directoryObject.AdditionalProperties."@odata.type").split(".")|select-object -last 1
$directoryObjectRef=@{
"@odata.id" = "https://graph.microsoft.com/beta/$($directoryObjectType)s/$($sponsor)"
"@odata.id" = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/$($directoryObjectType)s/$($sponsor)"
}

New-MgBetaEntitlementManagementConnectedOrganizationInternalSponsorByRef `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function Set-TargetResource
rules = $rulesParam
}

Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/networkAccess/forwardingPolicies/$($currentPolicy.ID)/updatePolicyRules" -Method Post -Body $updateParams
Invoke-MgGraphRequest -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/networkAccess/forwardingPolicies/$($currentPolicy.ID)/updatePolicyRules" -Method Post -Body $updateParams
}
else {
Write-Verbose "Can not modify the list of poilicy rules for the forwarding policy with name: $($setParameters.Name)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function Set-TargetResource

# Delete the old configuration
Write-Verbose -Message "Removing the current Azure AD Organization Certificate Based Auth Configuration."
Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/organization/$OrganizationId/certificateBasedAuthConfiguration/$CertificateBasedAuthConfigurationId" -Method DELETE
Invoke-MgGraphRequest -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/organization/$OrganizationId/certificateBasedAuthConfiguration/$CertificateBasedAuthConfigurationId" -Method DELETE

if ($Ensure -eq 'Present')
{
Expand All @@ -225,7 +225,7 @@ function Set-TargetResource
certificateAuthorities = $createCertAuthorities
}

$policy = Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/organization/$OrganizationId/certificateBasedAuthConfiguration/" -Method POST -Body $params
$policy = Invoke-MgGraphRequest -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/organization/$OrganizationId/certificateBasedAuthConfiguration/" -Method POST -Body $params
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ function Set-TargetResource
{
$userInfo = Get-MgUser -UserId $owner
$body = @{
'@odata.id' = "https://graph.microsoft.com/v1.0/directoryObjects/$($userInfo.Id)"
'@odata.id' = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "v1.0/directoryObjects/$($userInfo.Id)"
}
Write-Verbose -Message "Adding new owner {$owner}"
$newOwner = New-MgServicePrincipalOwnerByRef -ServicePrincipalId $newSP.Id -BodyParameter $body
Expand Down Expand Up @@ -593,7 +593,7 @@ function Set-TargetResource
$CSAParams = @{
customSecurityAttributes = $currentAADServicePrincipal.CustomSecurityAttributes
}
Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/servicePrincipals(appId='$($currentParameters.AppId)')" -Method Patch -Body $CSAParams
Invoke-MgGraphRequest -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/servicePrincipals(appId='$($currentParameters.AppId)')" -Method Patch -Body $CSAParams
}

Update-MgServicePrincipal -ServicePrincipalId $currentAADServicePrincipal.ObjectID @currentParameters
Expand Down Expand Up @@ -701,7 +701,7 @@ function Set-TargetResource
if ($diff.SideIndicator -eq '=>')
{
$body = @{
'@odata.id' = "https://graph.microsoft.com/v1.0/directoryObjects/$($userInfo.Id)"
'@odata.id' = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "v1.0/directoryObjects/$($userInfo.Id)"
}
Write-Verbose -Message "Adding owner {$($userInfo.Id)}"
New-MgServicePrincipalOwnerByRef -ServicePrincipalId $currentAADServicePrincipal.ObjectId `
Expand Down Expand Up @@ -1223,7 +1223,7 @@ function Get-CustomSecurityAttributes {
[String]$ServicePrincipalId
)

$customSecurityAttributes = Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/servicePrincipals/$($ServicePrincipalId)`?`$select=customSecurityAttributes" -Method Get
$customSecurityAttributes = Invoke-MgGraphRequest -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/servicePrincipals/$($ServicePrincipalId)`?`$select=customSecurityAttributes" -Method Get
$customSecurityAttributes = $customSecurityAttributes.customSecurityAttributes
$newCustomSecurityAttributes = @()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function Set-TargetResource
# so first check if it is $false, then make a post call to agree to the consent, this set the DataSharingConsetGranted to $true.
$consentInstance = Get-MgBetaDeviceManagementDataSharingConsent -DataSharingConsentId "appleMDMPushCertificate"
If($consentInstance.Granted -eq $False) {
Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/beta/deviceManagement/dataSharingConsents/appleMDMPushCertificate/consentToDataSharing" -Headers @{ "Content-Type" = "application/json" }
Invoke-MgGraphRequest -Method POST -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/deviceManagement/dataSharingConsents/appleMDMPushCertificate/consentToDataSharing" -Headers @{ "Content-Type" = "application/json" }
}
else {
Write-Host "Data sharing conset is already granted, so it can't be revoked."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function Set-TargetResource
if ($dataSharingConsent.granted -eq $false)
{
Write-Verbose -Message "Consent not granted, requesting consent..."
$consentResult = Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/deviceManagement/dataSharingConsents/androidManagedStore/consentToDataSharing" -Method 'POST' -Body @{
$consentResult = Invoke-MgGraphRequest -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/deviceManagement/dataSharingConsents/androidManagedStore/consentToDataSharing" -Method 'POST' -Body @{
DataSharingConsentId = "androidManagedStore"
} -ContentType "application/json"
}
Expand All @@ -238,7 +238,7 @@ function Set-TargetResource
# hostName = "intune.microsoft.com"
# }

# $signupUrl = Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/deviceManagement/androidManagedStoreAccountEnterpriseSettings/requestSignupUrl" -Method 'POST' -Body @{
# $signupUrl = Invoke-MgGraphRequest -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/deviceManagement/androidManagedStoreAccountEnterpriseSettings/requestSignupUrl" -Method 'POST' -Body @{
# hostName = "intune.microsoft.com"
# } -ContentType "application/json"

Expand All @@ -248,7 +248,7 @@ function Set-TargetResource
elseif ($Ensure -eq 'Absent' -and $currentInstance.Ensure -eq 'Present')
{
Write-Host "Remove the Intune Device Management Android Google Play Enrollment with Id {$($currentInstance.Id)}"
$unbindResult = Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/beta/deviceManagement/androidManagedStoreAccountEnterpriseSettings/unbind" -Method 'POST' -Body @{} -ContentType "application/json"
$unbindResult = Invoke-MgGraphRequest -Uri $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + "beta/deviceManagement/androidManagedStoreAccountEnterpriseSettings/unbind" -Method 'POST' -Body @{} -ContentType "application/json"
}
}

Expand Down

0 comments on commit f7cbfa6

Please sign in to comment.