diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneRoleAssignment/MSFT_IntuneRoleAssignment.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneRoleAssignment/MSFT_IntuneRoleAssignment.psm1 index c30e8098ef..802529ca5d 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneRoleAssignment/MSFT_IntuneRoleAssignment.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneRoleAssignment/MSFT_IntuneRoleAssignment.psm1 @@ -103,7 +103,7 @@ function Get-TargetResource $getValue = $null if ($Id -match '^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$') { - $getValue = Get-MgDeviceManagementRoleAssignment -DeviceAndAppManagementRoleAssignmentId $id -ErrorAction SilentlyContinue + $getValue = Get-MgBetaDeviceManagementRoleAssignment -DeviceAndAppManagementRoleAssignmentId $id -ErrorAction SilentlyContinue if ($null -ne $getValue) { Write-Verbose -Message "Found something with id {$id}" @@ -113,7 +113,7 @@ function Get-TargetResource { Write-Verbose -Message "Nothing with id {$id} was found" $Filter = "displayName eq '$DisplayName'" - $getValue = Get-MgDeviceManagementRoleAssignment -Filter $Filter -ErrorAction SilentlyContinue + $getValue = Get-MgBetaDeviceManagementRoleAssignment -Filter $Filter -ErrorAction SilentlyContinue if ($null -ne $getValue) { Write-Verbose -Message "Found something with displayname {$DisplayName}" @@ -386,7 +386,7 @@ function Set-TargetResource '@odata.type' = '#microsoft.graph.deviceAndAppManagementRoleAssignment' 'roleDefinition@odata.bind' = "https://graph.microsoft.com/beta/deviceManagement/roleDefinitions('$roleDefinition')" } - $policy = New-MgDeviceManagementRoleAssignment -BodyParameter $CreateParameters + $policy = New-MgBetaDeviceManagementRoleAssignment -BodyParameter $CreateParameters } elseif ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Present') @@ -403,14 +403,14 @@ function Set-TargetResource 'roleDefinition@odata.bind' = "https://graph.microsoft.com/beta/deviceManagement/roleDefinitions('$roleDefinition')" } - Update-MgDeviceManagementRoleAssignment -BodyParameter $UpdateParameters ` + Update-MgBetaDeviceManagementRoleAssignment -BodyParameter $UpdateParameters ` -DeviceAndAppManagementRoleAssignmentId $currentInstance.Id } elseif ($Ensure -eq 'Absent' -and $currentInstance.Ensure -eq 'Present') { Write-Verbose -Message "Removing {$DisplayName}" - Remove-MgDeviceManagementRoleAssignment -DeviceAndAppManagementRoleAssignmentId $currentInstance.Id + Remove-MgBetaDeviceManagementRoleAssignment -DeviceAndAppManagementRoleAssignmentId $currentInstance.Id } } @@ -644,7 +644,7 @@ function Export-TargetResource try { - [array]$getValue = Get-MgDeviceManagementRoleAssignment ` + [array]$getValue = Get-MgBetaDeviceManagementRoleAssignment ` -ErrorAction Stop | Where-Object ` -FilterScript { ` $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.deviceAndAppManagementRoleAssignment' ` @@ -652,7 +652,7 @@ function Export-TargetResource if (-not $getValue) { - [array]$getValue = Get-MgDeviceManagementRoleAssignment ` + [array]$getValue = Get-MgBetaDeviceManagementRoleAssignment ` -ErrorAction Stop } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneRoleAssignment.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneRoleAssignment.Tests.ps1 index e50b849644..79968d0b29 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneRoleAssignment.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneRoleAssignment.Tests.ps1 @@ -33,13 +33,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Mock -CommandName Remove-PSSession -MockWith { } - Mock -CommandName Update-MgDeviceManagementRoleAssignment -MockWith { + Mock -CommandName Update-MgBetaDeviceManagementRoleAssignment -MockWith { } - Mock -CommandName New-MgDeviceManagementRoleAssignment -MockWith { + Mock -CommandName New-MgBetaDeviceManagementRoleAssignment -MockWith { } - Mock -CommandName Remove-MgDeviceManagementRoleAssignment -MockWith { + Mock -CommandName Remove-MgBetaDeviceManagementRoleAssignment -MockWith { } Mock -CommandName New-M365DSCConnection -MockWith { @@ -68,7 +68,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Credential = $Credential } - Mock -CommandName Get-MgDeviceManagementRoleAssignment -MockWith { + Mock -CommandName Get-MgBetaDeviceManagementRoleAssignment -MockWith { return $null } } @@ -80,7 +80,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } It 'Should Create the group from the Set method' { Set-TargetResource @testParams - Should -Invoke -CommandName New-MgDeviceManagementRoleAssignment -Exactly 1 + Should -Invoke -CommandName New-MgBetaDeviceManagementRoleAssignment -Exactly 1 } } @@ -98,7 +98,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Credential = $Credential } - Mock -CommandName Get-MgDeviceManagementRoleAssignment -MockWith { + Mock -CommandName Get-MgBetaDeviceManagementRoleAssignment -MockWith { return @{ Description = 'FakeStringValue' DisplayName = 'FakeStringValue' @@ -130,7 +130,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { It 'Should Remove the group from the Set method' { Set-TargetResource @testParams - Should -Invoke -CommandName Remove-MgDeviceManagementRoleAssignment -Exactly 1 + Should -Invoke -CommandName Remove-MgBetaDeviceManagementRoleAssignment -Exactly 1 } } Context -Name 'The IntuneRoleAssignment Exists and Values are already in the desired state' -Fixture { @@ -147,7 +147,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Credential = $Credential } - Mock -CommandName Get-MgDeviceManagementRoleAssignment -MockWith { + Mock -CommandName Get-MgBetaDeviceManagementRoleAssignment -MockWith { return @{ Description = 'FakeStringValue' DisplayName = 'FakeStringValue' @@ -192,7 +192,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Credential = $Credential } - Mock -CommandName Get-MgDeviceManagementRoleAssignment -MockWith { + Mock -CommandName Get-MgBetaDeviceManagementRoleAssignment -MockWith { return @{ AdditionalProperties = @{ '@odata.type' = '#microsoft.graph.' @@ -229,7 +229,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { It 'Should call the Set method' { Set-TargetResource @testParams - Should -Invoke -CommandName Update-MgDeviceManagementRoleAssignment -Exactly 1 + Should -Invoke -CommandName Update-MgBetaDeviceManagementRoleAssignment -Exactly 1 } } @@ -241,7 +241,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Credential = $Credential } - Mock -CommandName Get-MgDeviceManagementRoleAssignment -MockWith { + Mock -CommandName Get-MgBetaDeviceManagementRoleAssignment -MockWith { return @{ Description = 'FakeStringValue' DisplayName = 'FakeStringValue' diff --git a/Tests/Unit/Stubs/Microsoft365.psm1 b/Tests/Unit/Stubs/Microsoft365.psm1 index 002a47a3f0..8b41f10e85 100644 --- a/Tests/Unit/Stubs/Microsoft365.psm1 +++ b/Tests/Unit/Stubs/Microsoft365.psm1 @@ -60037,7 +60037,84 @@ function Remove-MgDeviceManagementRoleDefinition $Break ) } -function Update-MgDeviceManagementRoleAssignment +function Get-MgBetaDeviceManagementRoleAssignment +{ + [CmdletBinding()] + param( + [Parameter()] + [System.String[]] + $Property, + + [Parameter()] + [PSObject] + $InputObject, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $ProxyUseDefaultCredentials, + + [Parameter()] + [System.Int32] + $PageSize, + + [Parameter()] + [PSObject] + $HttpPipelinePrepend, + + [Parameter()] + [System.Int32] + $Skip, + + [Parameter()] + [System.Int32] + $Top, + + [Parameter()] + [System.String] + $CountVariable, + + [Parameter()] + [System.Uri] + $Proxy, + + [Parameter()] + [System.String] + $DeviceAndAppManagementRoleAssignmentId, + + [Parameter()] + [System.String[]] + $Sort, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $All, + + [Parameter()] + [System.String] + $Filter, + + [Parameter()] + [System.Management.Automation.PSCredential] + $ProxyCredential, + + [Parameter()] + [System.String] + $Search, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $Break, + + [Parameter()] + [System.String[]] + $ExpandProperty, + + [Parameter()] + [PSObject] + $HttpPipelineAppend + ) +} +function New-MgBetaDeviceManagementRoleAssignment { [CmdletBinding()] param( @@ -60061,18 +60138,148 @@ function Update-MgDeviceManagementRoleAssignment [System.Management.Automation.SwitchParameter] $ProxyUseDefaultCredentials, + [Parameter()] + [PSObject] + $RoleScopeTags, + + [Parameter()] + [PSObject] + $HttpPipelinePrepend, + + [Parameter()] + [PSObject] + $ScopeType, + + [Parameter()] + [System.String[]] + $Members, + + [Parameter()] + [System.Uri] + $Proxy, + + [Parameter()] + [System.String[]] + $ScopeMembers, + + [Parameter()] + [PSObject] + $BodyParameter, + [Parameter()] [System.String] - $DeviceAndAppManagementRoleAssignmentId, + $Id, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $Confirm, + [Parameter()] + [PSObject] + $RoleDefinition, + + [Parameter()] + [System.Management.Automation.PSCredential] + $ProxyCredential, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $Break, + + [Parameter()] + [PSObject] + $HttpPipelineAppend + ) +} +function Remove-MgBetaDeviceManagementRoleAssignment +{ + [CmdletBinding()] + param( [Parameter()] [PSObject] $HttpPipelinePrepend, + [Parameter()] + [System.Management.Automation.PSCredential] + $ProxyCredential, + + [Parameter()] + [System.Uri] + $Proxy, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $PassThru, + + [Parameter()] + [System.String] + $IfMatch, + + [Parameter()] + [PSObject] + $InputObject, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $Confirm, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $ProxyUseDefaultCredentials, + + [Parameter()] + [System.String] + $DeviceAndAppManagementRoleAssignmentId, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $Break, + + [Parameter()] + [PSObject] + $HttpPipelineAppend + ) +} +function Update-MgBetaDeviceManagementRoleAssignment +{ + [CmdletBinding()] + param( + [Parameter()] + [System.String] + $Description, + + [Parameter()] + [System.String] + $DisplayName, + + [Parameter()] + [System.String[]] + $ResourceScopes, + [Parameter()] [PSObject] $InputObject, + [Parameter()] + [System.Collections.Hashtable] + $AdditionalProperties, + + [Parameter()] + [System.Management.Automation.SwitchParameter] + $ProxyUseDefaultCredentials, + + [Parameter()] + [System.String] + $DeviceAndAppManagementRoleAssignmentId, + + [Parameter()] + [PSObject] + $HttpPipelinePrepend, + + [Parameter()] + [PSObject] + $ScopeType, + [Parameter()] [System.String[]] $Members, @@ -60081,6 +60288,10 @@ function Update-MgDeviceManagementRoleAssignment [System.Uri] $Proxy, + [Parameter()] + [System.String[]] + $ScopeMembers, + [Parameter()] [PSObject] $BodyParameter, @@ -60101,6 +60312,10 @@ function Update-MgDeviceManagementRoleAssignment [System.Management.Automation.PSCredential] $ProxyCredential, + [Parameter()] + [PSObject] + $RoleScopeTags, + [Parameter()] [System.Management.Automation.SwitchParameter] $Break,