From 74f192834e30eb55c0f1e2d79dd60539a2dd9bf5 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Fri, 22 Nov 2024 12:25:55 -0500 Subject: [PATCH 01/10] Teams Policies Improvements --- CHANGELOG.md | 5 + .../MSFT_TeamsUpgradePolicy.psm1 | 23 +- .../MSFT_TeamsUpgradePolicy.schema.mof | 2 +- .../MSFT_TeamsUserPolicyAssignment.psm1 | 314 +++++++++++++++--- .../1-AssignUsersToTeamsUpgradePolicy.ps1 | 1 - .../Microsoft365DSC/Modules/M365DSCUtil.psm1 | 4 + 6 files changed, 284 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b280da23f7..c436c282bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ * Added support for AccessTokens. * IntuneAndroidManagedStoreAppConfiguration * Initial release. +* TeamsUserPolicyAssignment + * Added support for the Global policies. +* TeamsUpgradePolicy + * DEPRECATED: Users properties. Use the TeamsUserPolicyAssignment resource + instead. * MISC * Removed hardcoded Graph urls and replaced by MSCloudLoginAssistant values. diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUpgradePolicy/MSFT_TeamsUpgradePolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUpgradePolicy/MSFT_TeamsUpgradePolicy.psm1 index e845b47cb9..7bbc0ac35a 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUpgradePolicy/MSFT_TeamsUpgradePolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUpgradePolicy/MSFT_TeamsUpgradePolicy.psm1 @@ -8,6 +8,7 @@ function Get-TargetResource [System.String] $Identity, + # DEPRECATED [Parameter()] [System.String[]] $Users, @@ -66,22 +67,6 @@ function Get-TargetResource $policy = Get-CsTeamsUpgradePolicy -Identity $Identity ` -ErrorAction SilentlyContinue - if ($Identity -eq 'Global') - { - [array]$users = Get-CsOnlineUser -Filter "TeamsUpgradePolicy eq null" - } - else - { - try - { - [array]$users = Get-CsOnlineUser -Filter "TeamsUpgradePolicy eq '$Identity'" - } - catch - { - [array]$users = Get-CsOnlineUser | Where-Object -Filter { $_.TeamsUpgradePolicy -eq $Identity } - } - } - if ($null -eq $policy) { throw "No Teams Upgrade Policy with Identity {$Identity} was found" @@ -95,7 +80,8 @@ function Get-TargetResource Write-Verbose -Message "Found Teams Upgrade Policy with Identity {$Identity}" return @{ Identity = $Identity - Users = $usersList + #DEPRECATED + #Users = $usersList MigrateMeetingsToTeams = $MigrateMeetingsToTeams Credential = $Credential ApplicationId = $ApplicationId @@ -126,6 +112,7 @@ function Set-TargetResource [System.String] $Identity, + # DEPRECATED [Parameter()] [System.String[]] $Users, @@ -204,6 +191,7 @@ function Test-TargetResource [System.String] $Identity, + # DEPRECATED [Parameter()] [System.String[]] $Users, @@ -255,6 +243,7 @@ function Test-TargetResource Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $PSBoundParameters)" $ValuesToCheck = $PSBoundParameters + $ValuesToCheck.Remove("Users") | Out-Null $TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` -Source $($MyInvocation.MyCommand.Source) ` diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUpgradePolicy/MSFT_TeamsUpgradePolicy.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUpgradePolicy/MSFT_TeamsUpgradePolicy.schema.mof index dcd1b3df49..6168d86186 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUpgradePolicy/MSFT_TeamsUpgradePolicy.schema.mof +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUpgradePolicy/MSFT_TeamsUpgradePolicy.schema.mof @@ -2,7 +2,7 @@ class MSFT_TeamsUpgradePolicy : OMI_BaseResource { [Key, Description("Identity of the Teams Upgrade Policy.")] String Identity; - [Write, Description("List of users that will be granted the Upgrade Policy to. Use value * to apply the policy globally.")] String Users[]; + [Write, Description("DEPRECATED. Use the TeamsUserPolicyAssignment resource instead.")] String Users[]; [Write, Description("Specifies whether to move existing Skype for Business meetings organized by the user to Teams. This parameter can only be true if the mode of the specified policy instance is either TeamsOnly or SfBWithTeamsCollabAndMeetings, and if the policy instance is being granted to a specific user. It not possible to trigger meeting migration when granting TeamsUpgradePolicy to the entire tenant.")] Boolean MigrateMeetingsToTeams; [Write, Description("Credentials of the Teams Admin"), EmbeddedInstance("MSFT_Credential")] string Credential; [Write, Description("Id of the Azure Active Directory application to authenticate with.")] String ApplicationId; diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUserPolicyAssignment/MSFT_TeamsUserPolicyAssignment.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUserPolicyAssignment/MSFT_TeamsUserPolicyAssignment.psm1 index ce927c2248..76c6feb52f 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUserPolicyAssignment/MSFT_TeamsUserPolicyAssignment.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsUserPolicyAssignment/MSFT_TeamsUserPolicyAssignment.psm1 @@ -143,31 +143,164 @@ function Get-TargetResource Write-Verbose -Message "User Policy Assignment not found for $User" return $null } + + $CallingLineIdentityValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'CallingLineIdentity'}).PolicyName + if ([System.String]::IsNullOrEmpty($CallingLineIdentityValue)) + { + $CallingLineIdentityValue = 'Global' + } + + $ExternalAccessPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'ExternalAccessPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($ExternalAccessPolicyValue)) + { + $ExternalAccessPolicyValue = 'Global' + } + + $OnlineVoicemailPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'OnlineVoicemailPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($OnlineVoicemailPolicyValue)) + { + $OnlineVoicemailPolicyValue = 'Global' + } + + $OnlineVoiceRoutingPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'OnlineVoiceRoutingPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($OnlineVoiceRoutingPolicyValue)) + { + $OnlineVoiceRoutingPolicyValue = 'Global' + } + + $TeamsAppPermissionPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsAppPermissionPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsAppPermissionPolicyValue)) + { + $TeamsAppPermissionPolicyValue = 'Global' + } + + $TeamsAppSetupPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsAppSetupPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsAppSetupPolicyValue)) + { + $TeamsAppSetupPolicyValue = 'Global' + } + + $TeamsAudioConferencingPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsAudioConferencingPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsAudioConferencingPolicyValue)) + { + $TeamsAudioConferencingPolicyValue = 'Global' + } + + $TeamsCallHoldPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsCallHoldPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsCallHoldPolicyValue)) + { + $TeamsCallHoldPolicyValue = 'Global' + } + + $TeamsCallingPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsCallingPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsCallingPolicyValue)) + { + $TeamsCallingPolicyValue = 'Global' + } + + $TeamsCallParkPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsCallParkPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsCallParkPolicyValue)) + { + $TeamsCallParkPolicyValue = 'Global' + } + + $TeamsChannelsPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsChannelsPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsChannelsPolicyValue)) + { + $TeamsChannelsPolicyValue = 'Global' + } + + $TeamsEmergencyCallingPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsEmergencyCallingPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsEmergencyCallingPolicyValue)) + { + $TeamsEmergencyCallingPolicyValue = 'Global' + } + + $TeamsEmergencyCallRoutingPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsEmergencyCallRoutingPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsEmergencyCallRoutingPolicyValue)) + { + $TeamsEmergencyCallRoutingPolicyValue = 'Global' + } + + $TeamsEnhancedEncryptionPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsEnhancedEncryptionPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsEnhancedEncryptionPolicyValue)) + { + $TeamsEnhancedEncryptionPolicyValue = 'Global' + } + + $TeamsEventsPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsEventsPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsEventsPolicyValue)) + { + $TeamsEventsPolicyValue = 'Global' + } + + $TeamsMeetingBroadcastPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsMeetingBroadcastPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsMeetingBroadcastPolicyValue)) + { + $TeamsMeetingBroadcastPolicyValue = 'Global' + } + + $TeamsMeetingPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsMeetingPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsMeetingPolicyValue)) + { + $TeamsMeetingPolicyValue = 'Global' + } + + $TeamsMessagingPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsMessagingPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsMessagingPolicyValue)) + { + $TeamsMessagingPolicyValue = 'Global' + } + + $TeamsMobilityPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsMobilityPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsMobilityPolicyValue)) + { + $TeamsMobilityPolicyValue = 'Global' + } + + $TeamsUpdateManagementPolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsUpdateManagementPolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsUpdateManagementPolicyValue)) + { + $TeamsUpdateManagementPolicyValue = 'Global' + } + + $TeamsUpgradePolicyValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsUpgradePolicy'}).PolicyName + if ([System.String]::IsNullOrEmpty($TeamsUpgradePolicyValue)) + { + $TeamsUpgradePolicyValue = 'Global' + } + + $TenantDialPlanValue = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TenantDialPlan'}).PolicyName + if ([System.String]::IsNullOrEmpty($TenantDialPlanValue)) + { + $TenantDialPlanValue = 'Global' + } + Write-Verbose -Message "Found Policy Assignment for user {$User}" return @{ User = $User - CallingLineIdentity = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'CallingLineIdentity'}).PolicyName - ExternalAccessPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'ExternalAccessPolicy'}).PolicyName - OnlineVoicemailPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'OnlineVoicemailPolicy'}).PolicyName - OnlineVoiceRoutingPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'OnlineVoiceRoutingPolicy'}).PolicyName - TeamsAppPermissionPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsAppPermissionPolicy'}).PolicyName - TeamsAppSetupPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsAppSetupPolicy'}).PolicyName - TeamsAudioConferencingPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsAudioConferencingPolicy'}).PolicyName - TeamsCallHoldPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsCallHoldPolicy'}).PolicyName - TeamsCallingPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsCallingPolicy'}).PolicyName - TeamsCallParkPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsCallParkPolicy'}).PolicyName - TeamsChannelsPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsChannelsPolicy'}).PolicyName - TeamsEmergencyCallingPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsEmergencyCallingPolicy'}).PolicyName - TeamsEmergencyCallRoutingPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsEmergencyCallRoutingPolicy'}).PolicyName - TeamsEnhancedEncryptionPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsEnhancedEncryptionPolicy'}).PolicyName - TeamsEventsPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsEventsPolicy'}).PolicyName - TeamsMeetingBroadcastPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsMeetingBroadcastPolicy'}).PolicyName - TeamsMeetingPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsMeetingPolicy'}).PolicyName - TeamsMessagingPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsMessagingPolicy'}).PolicyName - TeamsMobilityPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsMobilityPolicy'}).PolicyName - TeamsUpdateManagementPolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsUpdateManagementPolicy'}).PolicyName - TeamsUpgradePolicy = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TeamsUpgradePolicy'}).PolicyName - TenantDialPlan = ($assignment | Where-Object -FilterScript {$_.PolicyType -eq 'TenantDialPlan'}).PolicyName + CallingLineIdentity = $CallingLineIdentityValue + ExternalAccessPolicy = $ExternalAccessPolicyValue + OnlineVoicemailPolicy = $OnlineVoicemailPolicyValue + OnlineVoiceRoutingPolicy = $OnlineVoiceRoutingPolicyValue + TeamsAppPermissionPolicy = $TeamsAppPermissionPolicyValue + TeamsAppSetupPolicy = $TeamsAppSetupPolicyValue + TeamsAudioConferencingPolicy = $TeamsAudioConferencingPolicyValue + TeamsCallHoldPolicy = $TeamsCallHoldPolicyValue + TeamsCallingPolicy = $TeamsCallingPolicyValue + TeamsCallParkPolicy = $TeamsCallParkPolicyValue + TeamsChannelsPolicy = $TeamsChannelsPolicyValue + TeamsEmergencyCallingPolicy = $TeamsEmergencyCallingPolicyValue + TeamsEmergencyCallRoutingPolicy = $TeamsEmergencyCallRoutingPolicyValue + TeamsEnhancedEncryptionPolicy = $TeamsEnhancedEncryptionPolicyValue + TeamsEventsPolicy = $TeamsEventsPolicyValue + TeamsMeetingBroadcastPolicy = $TeamsMeetingBroadcastPolicyValue + TeamsMeetingPolicy = $TeamsMeetingPolicyValue + TeamsMessagingPolicy = $TeamsMessagingPolicyValue + TeamsMobilityPolicy = $TeamsMobilityPolicyValue + TeamsUpdateManagementPolicy = $TeamsUpdateManagementPolicyValue + TeamsUpgradePolicy = $TeamsUpgradePolicyValue + TenantDialPlan = $TenantDialPlanValue Credential = $Credential ApplicationId = $ApplicationId TenantId = $TenantId @@ -324,116 +457,205 @@ function Set-TargetResource $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftTeams' -InboundParameters $PSBoundParameters + $currentInstance = Get-TargetResource @PSBoundParameters try { - if ($null -ne $CallingLineIdentity) + if ($null -ne $CallingLineIdentity -and $CallingLineIdentity -ne $currentInstance.CallingLineIdentity) { Write-Verbose -Message "Assigning the Call Line Identity Policy {$CallingLineIdentity} to user {$User}" + if ($CallingLineIdentity -eq 'Global') + { + $CallingLineIdentity = $null + } Grant-CsCallingLineIdentity -Identity $User -PolicyName $CallingLineIdentity | Out-Null } - if ($null -ne $ExternalAccessPolicy) + if ($null -ne $ExternalAccessPolicy -and $ExternalAccessPolicy -ne $currentInstance.ExternalAccessPolicy) { Write-Verbose -Message "Assigning the External Access Policy {$ExternalAccessPolicy} to user {$User}" - Grant-CsExternalAccessPolicy -Identity $User -PolicyName $CallingLineIdentity | Out-Null + if ($ExternalAccessPolicy -eq 'Global') + { + $ExternalAccessPolicy = $null + } + Grant-CsExternalAccessPolicy -Identity $User -PolicyName $ExternalAccessPolicy | Out-Null } - if ($null -ne $OnlineVoicemailPolicy) + if ($null -ne $OnlineVoicemailPolicy -and $OnlineVoicemailPolicy -ne $currentInstance.OnlineVoicemailPolicy) { Write-Verbose -Message "Assigning the Online Voicemail Policy {$OnlineVoicemailPolicy} to user {$User}" + if ($OnlineVoicemailPolicy -eq 'Global') + { + $OnlineVoicemailPolicy = $null + } Grant-CsOnlineVoicemailPolicy -Identity $User -PolicyName $OnlineVoicemailPolicy | Out-Null } - if ($null -ne $OnlineVoiceRoutingPolicy) + if ($null -ne $OnlineVoiceRoutingPolicy -and $OnlineVoiceRoutingPolicy -ne $currentInstance.OnlineVoiceRoutingPolicy) { Write-Verbose -Message "Assigning the Online Voice Routing Policy {$OnlineVoiceRoutingPolicy} to user {$User}" + if ($OnlineVoiceRoutingPolicy -eq 'Global') + { + $OnlineVoiceRoutingPolicy = $null + } Grant-CsOnlineVoiceRoutingPolicy -Identity $User -PolicyName $OnlineVoiceRoutingPolicy | Out-Null } - if ($null -ne $TeamsAppPermissionPolicy) + if ($null -ne $TeamsAppPermissionPolicy -and $TeamsAppPermissionPolicy -ne $currentInstance.TeamsAppPermissionPolicy) { Write-Verbose -Message "Assigning the Apps Permission Policy {$TeamsAppPermissionPolicy} to user {$User}" + if ($TeamsAppPermissionPolicy -eq 'Global') + { + $TeamsAppPermissionPolicy = $null + } Grant-CsTeamsAppPermissionPolicy -Identity $User -PolicyName $TeamsAppPermissionPolicy | Out-Null } - if ($null -ne $TeamsAppSetupPolicy) + if ($null -ne $TeamsAppSetupPolicy -and $TeamsAppSetupPolicy -ne $currentInstance.TeamsAppSetupPolicy) { Write-Verbose -Message "Assigning the Apps Setup Policy {$TeamsAppSetupPolicy} to user {$User}" + if ($TeamsAppSetupPolicy -eq 'Global') + { + $TeamsAppSetupPolicy = $null + } Grant-CsTeamsAppSetupPolicy -Identity $User -PolicyName $TeamsAppSetupPolicy | Out-Null } - if ($null -ne $TeamsAudioConferencingPolicy) + if ($null -ne $TeamsAudioConferencingPolicy -and $TeamsAudioConferencingPolicy -ne $currentInstance.TeamsAudioConferencingPolicy) { Write-Verbose -Message "Assigning the Audio COnferencing Policy {$TeamsAudioConferencingPolicy} to user {$User}" + if ($TeamsAudioConferencingPolicy -eq 'Global') + { + $TeamsAudioConferencingPolicy = $null + } Grant-CsTeamsAudioConferencingPolicy -Identity $User -PolicyName $TeamsAudioConferencingPolicy | Out-Null } - if ($null -ne $TeamsCallHoldPolicy) + if ($null -ne $TeamsCallHoldPolicy -and $TeamsCallHoldPolicy -ne $currentInstance.TeamsCallHoldPolicy) { Write-Verbose -Message "Assigning the Call Hold Policy {$TeamsCallHoldPolicy} to user {$User}" + if ($TeamsCallHoldPolicy -eq 'Global') + { + $TeamsCallHoldPolicy = $null + } Grant-CsTeamsCallHoldPolicy -Identity $User -PolicyName $TeamsCallHoldPolicy | Out-Null } - if ($null -ne $TeamsCallingPolicy) + if ($null -ne $TeamsCallingPolicy -and $TeamsCallingPolicy -ne $currentInstance.TeamsCallingPolicy) { - Write-Verbose -Message "Assigning the Calling Policy {$TeamsCallingPolicy} to user {$User}" + Write-Verbose -Message "Assigning the Calling Policy {$TeamsCallParkPolicy} to user {$User}" + if ($TeamsCallParkPolicy -eq 'Global') + { + $TeamsCallParkPolicy = $null + } Grant-CsTeamsCallingPolicy -Identity $User -PolicyName $TeamsCallingPolicy | Out-Null } - if ($null -ne $TeamsCallParkPolicy) + if ($null -ne $TeamsCallParkPolicy -and $TeamsCallParkPolicy -ne $currentInstance.TeamsCallParkPolicy) { Write-Verbose -Message "Assigning the Call Park Policy {$TeamsCallParkPolicy} to user {$User}" + if ($TeamsCallParkPolicy -eq 'Global') + { + $TeamsCallParkPolicy = $null + } Grant-CsTeamsCallParkPolicy -Identity $User -PolicyName $TeamsCallParkPolicy | Out-Null } - if ($null -ne $TeamsChannelsPolicy) + if ($null -ne $TeamsChannelsPolicy -and $TeamsChannelsPolicy -ne $currentInstance.TeamsChannelsPolicy) { Write-Verbose -Message "Assigning the Channels Policy {$TeamsChannelsPolicy} to user {$User}" + if ($TeamsChannelsPolicy -eq 'Global') + { + $TeamsChannelsPolicy = $null + } Grant-CsTeamsChannelsPolicy -Identity $User -PolicyName $TeamsChannelsPolicy | Out-Null } - if ($null -ne $TeamsEmergencyCallingPolicy) + if ($null -ne $TeamsEmergencyCallingPolicy -and $TeamsEmergencyCallingPolicy -ne $currentInstance.TeamsEmergencyCallingPolicy) { Write-Verbose -Message "Assigning the Emergency Calling Policy {$TeamsEmergencyCallingPolicy} to user {$User}" + if ($TeamsEmergencyCallingPolicy -eq 'Global') + { + $TeamsEmergencyCallingPolicy = $null + } Grant-CsTeamsEmergencyCallingPolicy -Identity $User -PolicyName $TeamsEmergencyCallingPolicy | Out-Null } - if ($null -ne $TeamsEmergencyCallRoutingPolicy) + if ($null -ne $TeamsEmergencyCallRoutingPolicy -and $TeamsEmergencyCallRoutingPolicy -ne $currentInstance.TeamsEmergencyCallRoutingPolicy) { Write-Verbose -Message "Assigning the Emergency Call Routing Policy {$TeamsEmergencyCallRoutingPolicy} to user {$User}" + if ($TeamsEmergencyCallRoutingPolicy -eq 'Global') + { + $TeamsEmergencyCallRoutingPolicy = $null + } Grant-CsTeamsEmergencyCallRoutingPolicy -Identity $User -PolicyName $TeamsEmergencyCallRoutingPolicy | Out-Null } - if ($null -ne $TeamsEnhancedEncryptionPolicy) + if ($null -ne $TeamsEnhancedEncryptionPolicy -and $TeamsEnhancedEncryptionPolicy -ne $currentInstance.TeamsEnhancedEncryptionPolicy) { Write-Verbose -Message "Assigning the Enhanced Encryption Policy {$TeamsEnhancedEncryptionPolicy} to user {$User}" + if ($TeamsEnhancedEncryptionPolicy -eq 'Global') + { + $TeamsEnhancedEncryptionPolicy = $null + } Grant-CsTeamsEnhancedEncryptionPolicy -Identity $User -PolicyName $TeamsEnhancedEncryptionPolicy | Out-Null } - if ($null -ne $TeamsEventsPolicy) + if ($null -ne $TeamsEventsPolicy -and $TeamsEventsPolicy -ne $currentInstance.TeamsEventsPolicy) { Write-Verbose -Message "Assigning the Events Policy {$TeamsEventsPolicy} to user {$User}" + if ($TeamsEventsPolicy -eq 'Global') + { + $TeamsEventsPolicy = $null + } Grant-CsTeamsEventsPolicy -Identity $User -PolicyName $TeamsEventsPolicy | Out-Null } - if ($null -ne $TeamsMeetingBroadcastPolicy) + if ($null -ne $TeamsMeetingBroadcastPolicy -and $TeamsMeetingBroadcastPolicy -ne $currentInstance.TeamsMeetingBroadcastPolicy) { Write-Verbose -Message "Assigning the Meeting Broadcast Policy {$TeamsMeetingBroadcastPolicy} to user {$User}" + if ($TeamsMeetingBroadcastPolicy -eq 'Global') + { + $TeamsMeetingBroadcastPolicy = $null + } Grant-CsTeamsMeetingBroadcastPolicy -Identity $User -PolicyName $TeamsMeetingBroadcastPolicy | Out-Null } - if ($null -ne $TeamsMeetingPolicy) + if ($null -ne $TeamsMeetingPolicy -and $TeamsMeetingPolicy -ne $currentInstance.TeamsMeetingPolicy) { Write-Verbose -Message "Assigning the Meeting Policy {$TeamsMeetingPolicy} to user {$User}" + if ($TeamsMeetingPolicy -eq 'Global') + { + $TeamsMeetingPolicy = $null + } Grant-CsTeamsMeetingPolicy -Identity $User -PolicyName $TeamsMeetingPolicy | Out-Null } - if ($null -ne $TeamsMessagingPolicy) + if ($null -ne $TeamsMessagingPolicy -and $TeamsMessagingPolicy -ne $currentInstance.TeamsMessagingPolicy) { Write-Verbose -Message "Assigning the Messaging Policy {$TeamsMessagingPolicy} to user {$User}" + if ($TeamsMessagingPolicy -eq 'Global') + { + $TeamsMessagingPolicy = $null + } Grant-CsTeamsMessagingPolicy -Identity $User -PolicyName $TeamsMessagingPolicy | Out-Null } - if ($null -ne $TeamsMobilityPolicy) + if ($null -ne $TeamsMobilityPolicy -and $TeamsMobilityPolicy -ne $currentInstance.TeamsMobilityPolicy) { Write-Verbose -Message "Assigning the Mobility Policy {$TeamsMobilityPolicy} to user {$User}" + if ($TeamsMobilityPolicy -eq 'Global') + { + $TeamsMobilityPolicy = $null + } Grant-CsTeamsMobilityPolicy -Identity $User -PolicyName $TeamsMobilityPolicy | Out-Null } - if ($null -ne $TeamsUpdateManagementPolicy) + if ($null -ne $TeamsUpdateManagementPolicy -and $TeamsUpdateManagementPolicy -ne $currentInstance.TeamsUpdateManagementPolicy) { Write-Verbose -Message "Assigning the Update Management Policy {$TeamsUpdateManagementPolicy} to user {$User}" + if ($TeamsUpdateManagementPolicy -eq 'Global') + { + $TeamsUpdateManagementPolicy = $null + } Grant-CsTeamsUpdateManagementPolicy -Identity $User -PolicyName $TeamsUpdateManagementPolicy | Out-Null } - if ($null -ne $TeamsUpgradePolicy) + if ($null -ne $TeamsUpgradePolicy -and $TeamsUpgradePolicy -ne $currentInstance.TeamsUpgradePolicy) { Write-Verbose -Message "Assigning the Upgrade Policy {$TeamsUpgradePolicy} to user {$User}" + if ($TeamsUpgradePolicy -eq 'Global') + { + $TeamsUpgradePolicy = $null + } Grant-CsTeamsUpgradePolicy -Identity $User -PolicyName $TeamsUpgradePolicy | Out-Null } - if ($null -ne $TenantDialPlan) + if ($null -ne $TenantDialPlan -and $TenantDialPlan -ne $currentInstance.TenantDialPlan) { Write-Verbose -Message "Assigning the Tenant Dial Plan {$TenantDialPlan} to user {$User}" + if ($TenantDialPlan -eq 'Global') + { + $TenantDialPlan = $null + } Grant-CsTenantDialPlan -Identity $User -PolicyName $TenantDialPlan | Out-Null } } diff --git a/Modules/Microsoft365DSC/Examples/Resources/TeamsUpgradePolicy/1-AssignUsersToTeamsUpgradePolicy.ps1 b/Modules/Microsoft365DSC/Examples/Resources/TeamsUpgradePolicy/1-AssignUsersToTeamsUpgradePolicy.ps1 index bfefa45dcd..921a068beb 100644 --- a/Modules/Microsoft365DSC/Examples/Resources/TeamsUpgradePolicy/1-AssignUsersToTeamsUpgradePolicy.ps1 +++ b/Modules/Microsoft365DSC/Examples/Resources/TeamsUpgradePolicy/1-AssignUsersToTeamsUpgradePolicy.ps1 @@ -16,7 +16,6 @@ Configuration Example TeamsUpgradePolicy 'ConfigureIslandsPolicy' { Identity = 'Islands' - Users = @("John.Smith@contoso.com", "Nik.Charlebois@contoso.com") MigrateMeetingsToTeams = $true Credential = $Credscredential } diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 0eae31dd77..ed4be1270b 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -3829,6 +3829,10 @@ function Get-M365DSCExportContentForResource { $primaryKey = $Results.UserPrincipalName } + elseif ($Keys.Contains('User')) + { + $primaryKey = $Results.User + } $instanceName = $ResourceName if (-not [System.String]::IsNullOrEmpty($primaryKey)) From bea8ce04a4cc87bd8cecbe0c175726990becaa0f Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Fri, 22 Nov 2024 14:03:10 -0500 Subject: [PATCH 02/10] Update Microsoft365DSC.TeamsUpgradePolicy.Tests.ps1 --- ...crosoft365DSC.TeamsUpgradePolicy.Tests.ps1 | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsUpgradePolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsUpgradePolicy.Tests.ps1 index 04217fe254..53ed733e03 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsUpgradePolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsUpgradePolicy.Tests.ps1 @@ -49,7 +49,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { BeforeAll { $testParams = @{ Identity = 'Test Policy' - Users = @('john.smith@contoso.onmicrosoft.com') MigrateMeetingsToTeams = $false Credential = $Credential } @@ -68,7 +67,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { BeforeAll { $testParams = @{ Identity = 'Test Policy' - Users = @('john.smith@contoso.onmicrosoft.com') MigrateMeetingsToTeams = $false Credential = $Credential } @@ -80,13 +78,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { NotifySfBUsers = $false } } - - Mock -CommandName Get-CsOnlineUser -MockWith { - return @{ - UserPrincipalName = 'Bob.Houle@contoso.onmicrosoft.com' - TeamsUpgradePolicy = 'Global' - } - } } It 'Should return false from the Test method' { @@ -103,7 +94,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { BeforeAll { $testParams = @{ Identity = 'Islands' - Users = @('john.smith@contoso.onmicrosoft.com') MigrateMeetingsToTeams = $false Credential = $Credential } @@ -115,13 +105,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { NotifySfBUsers = $false } } - - Mock -CommandName Get-CsOnlineUser -MockWith { - return @{ - UserPrincipalName = 'John.Smith@contoso.onmicrosoft.com' - TeamsUpgradePolicy = 'Islands' - } - } } It 'Should return true from the Test method' { @@ -144,13 +127,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { NotifySfBUsers = $false } } - - Mock -CommandName Get-CsOnlineUser -MockWith { - return @{ - UserPrincipalName = 'John.Smith@contoso.onmicrosoft.com' - TeamsUpgradePolicy = 'Islands' - } - } } It 'Should Reverse Engineer resource from the Export method' { From 1497c9081eb1fe28e7aa43fc084d096b82b4c927 Mon Sep 17 00:00:00 2001 From: Fabien Tschanz Date: Sun, 24 Nov 2024 17:14:44 +0100 Subject: [PATCH 03/10] Add separate module handling for PowerShell Core --- .github/workflows/CodeCoverage.yml | 8 ++++---- .github/workflows/Unit Tests.yml | 8 ++++---- .vscode/GetTestCoverage.ps1 | 2 +- CHANGELOG.md | 1 + .../Dependencies/Manifest.psd1 | 1 + .../Microsoft365DSC/Modules/M365DSCUtil.psm1 | 19 +++++++++++++++---- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.github/workflows/CodeCoverage.yml b/.github/workflows/CodeCoverage.yml index e636034445..f0d9e8b1df 100644 --- a/.github/workflows/CodeCoverage.yml +++ b/.github/workflows/CodeCoverage.yml @@ -17,10 +17,10 @@ jobs: - name: Install Modules shell: pwsh run: | - Install-Module ReverseDSC -Force -Scope AllUsers - Install-Module DSCParser -Force -Scope AllUsers - Install-Module PSDesiredStateConfiguration -Force -Scope AllUsers - Install-Module Pester -Force -SkipPublisherCheck -Scope AllUsers + Install-PSResource -Name ReverseDSC -Scope AllUsers -TrustRepository + Install-PSResource -Name DSCParser -Scope AllUsers -TrustRepository + Install-PSResource -Name PSDesiredStateConfiguration -Scope AllUsers -TrustRepository + Install-PSResource -Name Pester -Scope AllUsers -TrustRepository [System.Environment]::SetEnvironmentVariable('M365DSCTelemetryEnabled', $false, [System.EnvironmentVariableTarget]::Machine); - name: Run Quality Checks shell: pwsh diff --git a/.github/workflows/Unit Tests.yml b/.github/workflows/Unit Tests.yml index a636b3093d..4b6a772740 100644 --- a/.github/workflows/Unit Tests.yml +++ b/.github/workflows/Unit Tests.yml @@ -21,10 +21,10 @@ jobs: - name: Install Modules shell: pwsh run: | - Install-Module ReverseDSC -Force -Scope AllUsers - Install-Module DSCParser -Force -Scope AllUsers - Install-Module PSDesiredStateConfiguration -Force -Scope AllUsers - Install-Module Pester -Force -SkipPublisherCheck -Scope AllUsers + Install-PSResource -Name ReverseDSC -Scope AllUsers -TrustRepository + Install-PSResource -Name DSCParser -Scope AllUsers -TrustRepository + Install-PSResource -Name PSDesiredStateConfiguration -Scope AllUsers -TrustRepository + Install-PSResource -Name Pester -Scope AllUsers -TrustRepository [System.Environment]::SetEnvironmentVariable('M365DSCTelemetryEnabled', $false, [System.EnvironmentVariableTarget]::Machine); - name: Run Quality Checks shell: pwsh diff --git a/.vscode/GetTestCoverage.ps1 b/.vscode/GetTestCoverage.ps1 index 0b3a88ff68..8d5057208c 100644 --- a/.vscode/GetTestCoverage.ps1 +++ b/.vscode/GetTestCoverage.ps1 @@ -10,7 +10,7 @@ $minVersion = '5.5.0' $module = Get-Module -ListAvailable | Where-Object { $_.Name -eq $moduleName -and $_.Version -ge $minVersion } -if ($module -ne $null) +if ($null -ne $module) { Write-Output "Module $moduleName with version greater than or equal to $minVersion found." } diff --git a/CHANGELOG.md b/CHANGELOG.md index b280da23f7..e180ebffbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * Initial release. * MISC * Removed hardcoded Graph urls and replaced by MSCloudLoginAssistant values. + * Add separate module handling for PowerShell Core. # 1.24.1120.1 diff --git a/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 b/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 index 42d1488d67..5226da5672 100644 --- a/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 +++ b/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 @@ -127,6 +127,7 @@ @{ ModuleName = 'PnP.PowerShell' RequiredVersion = '1.12.0' + InstallLocation = 'WindowsPowerShell' }, @{ ModuleName = 'PSDesiredStateConfiguration' diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 0eae31dd77..be12b81876 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -3204,11 +3204,14 @@ function Update-M365DSCDependencies [Parameter()] [Switch] $ValidateOnly, + [Parameter()] [ValidateSet("CurrentUser", "AllUsers")] $Scope = "AllUsers" ) + $isPSResourceGetInstalled = Get-Module -Name Microsoft.PowerShell.PSResourceGet -ListAvailable + try { $Global:MaximumFunctionCount = 32767 @@ -3258,14 +3261,14 @@ function Update-M365DSCDependencies } if (-not $errorFound) { - if (-not $dependency.PowerShellCore -and $Script:IsPowerShellCore) + if (($dependency.PowerShellCore -eq $false -or $dependency.InstallLocation -eq "WindowsPowerShell") -and $Script:IsPowerShellCore) { - Write-Warning "The dependency {$($dependency.ModuleName)} does not support PowerShell Core. Please run Update-M365DSCDependencies in Windows PowerShell." + Write-Warning "The dependency {$($dependency.ModuleName)} requires Windows PowerShell for installation. Please run Update-M365DSCDependencies in Windows PowerShell." continue } elseif ($dependency.PowerShellCore -and -not $Script:IsPowerShellCore) { - Write-Warning "The dependency {$($dependency.ModuleName)} requires PowerShell Core. Please run Update-M365DSCDependencies in PowerShell Core." + Write-Warning "The dependency {$($dependency.ModuleName)} requires PowerShell Core for installation. Please run Update-M365DSCDependencies in PowerShell Core." continue } @@ -3276,7 +3279,15 @@ function Update-M365DSCDependencies Remove-Module 'Microsoft.Graph.Authentication' -Force -ErrorAction SilentlyContinue } Remove-Module $dependency.ModuleName -Force -ErrorAction SilentlyContinue - Install-Module $dependency.ModuleName -RequiredVersion $dependency.RequiredVersion -AllowClobber -Force -Scope "$Scope" + + if ($null -eq $isPSResourceGetInstalled) + { + Install-Module $dependency.ModuleName -RequiredVersion $dependency.RequiredVersion -AllowClobber -Force -Scope $Scope + } + else + { + Install-PSResource -Name $dependency.ModuleName -Version $dependency.RequiredVersion -AcceptLicense -Scope $Scope -Reinstall -TrustRepository + } } } From ed71c71591d0fa6119baa7cb91cf0f563834246c Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Sun, 24 Nov 2024 11:53:15 -0500 Subject: [PATCH 04/10] Update Microsoft365DSC.TeamsUpgradePolicy.Tests.ps1 --- ...crosoft365DSC.TeamsUpgradePolicy.Tests.ps1 | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsUpgradePolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsUpgradePolicy.Tests.ps1 index 53ed733e03..c8fe4e0e46 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsUpgradePolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsUpgradePolicy.Tests.ps1 @@ -63,33 +63,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { } } - Context -Name 'When the policy already exists and is NOT in the Desired State' -Fixture { - BeforeAll { - $testParams = @{ - Identity = 'Test Policy' - MigrateMeetingsToTeams = $false - Credential = $Credential - } - - Mock -CommandName Get-CsTeamsUpgradePolicy -MockWith { - return @{ - Identity = 'Test Policy' - Description = 'This is a configuration drift' - NotifySfBUsers = $false - } - } - } - - It 'Should return false from the Test method' { - Test-TargetResource @testParams | Should -Be $false - } - - It 'Should update the policy from the Set method' { - Set-TargetResource @testParams - Should -Invoke -CommandName Grant-CsTeamsUpgradePolicy -Exactly 1 - } - } - Context -Name 'When the policy already exists and IS in the Desired State' -Fixture { BeforeAll { $testParams = @{ From 87083c4f84469ebfab5c7dfe2aa4d77b9af27931 Mon Sep 17 00:00:00 2001 From: NikCharlebois Date: Mon, 25 Nov 2024 12:03:45 +0000 Subject: [PATCH 05/10] Updated Resources and Cmdlet documentation pages --- docs/docs/resources/teams/TeamsUpgradePolicy.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/docs/resources/teams/TeamsUpgradePolicy.md b/docs/docs/resources/teams/TeamsUpgradePolicy.md index e27774070c..2ed3aff363 100644 --- a/docs/docs/resources/teams/TeamsUpgradePolicy.md +++ b/docs/docs/resources/teams/TeamsUpgradePolicy.md @@ -5,7 +5,7 @@ | Parameter | Attribute | DataType | Description | Allowed Values | | --- | --- | --- | --- | --- | | **Identity** | Key | String | Identity of the Teams Upgrade Policy. | | -| **Users** | Write | StringArray[] | List of users that will be granted the Upgrade Policy to. Use value * to apply the policy globally. | | +| **Users** | Write | StringArray[] | DEPRECATED. Use the TeamsUserPolicyAssignment resource instead. | | | **MigrateMeetingsToTeams** | Write | Boolean | Specifies whether to move existing Skype for Business meetings organized by the user to Teams. This parameter can only be true if the mode of the specified policy instance is either TeamsOnly or SfBWithTeamsCollabAndMeetings, and if the policy instance is being granted to a specific user. It not possible to trigger meeting migration when granting TeamsUpgradePolicy to the entire tenant. | | | **Credential** | Write | PSCredential | Credentials of the Teams Admin | | | **ApplicationId** | Write | String | Id of the Azure Active Directory application to authenticate with. | | @@ -68,7 +68,6 @@ Configuration Example TeamsUpgradePolicy 'ConfigureIslandsPolicy' { Identity = 'Islands' - Users = @("John.Smith@contoso.com", "Nik.Charlebois@contoso.com") MigrateMeetingsToTeams = $true Credential = $Credscredential } From da8386852279eb89846e7a335f49d05cac81ebf0 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Mon, 25 Nov 2024 08:22:52 -0500 Subject: [PATCH 06/10] Updated Dependencies --- CHANGELOG.md | 4 ++++ Modules/Microsoft365DSC/Dependencies/Manifest.psd1 | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c436c282bb..4f915d2a57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ instead. * MISC * Removed hardcoded Graph urls and replaced by MSCloudLoginAssistant values. +* DEPENDENCIES + * Updated DSCParser to version 2.0.0.13 + * Updated Microsoft.PowerApps.Administration.PowerShell to version 2.0.200. + * Updated MicrosoftTeams to version 6.7.0. # 1.24.1120.1 diff --git a/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 b/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 index 42d1488d67..9aefc1f9f2 100644 --- a/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 +++ b/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 @@ -18,7 +18,7 @@ }, @{ ModuleName = 'DSCParser' - RequiredVersion = '2.0.0.12' + RequiredVersion = '2.0.0.13' }, @{ ModuleName = 'ExchangeOnlineManagement' @@ -114,11 +114,11 @@ }, @{ ModuleName = 'Microsoft.PowerApps.Administration.PowerShell' - RequiredVersion = '2.0.199' + RequiredVersion = '2.0.200' }, @{ ModuleName = 'MicrosoftTeams' - RequiredVersion = '6.6.0' + RequiredVersion = '6.7.0' }, @{ ModuleName = "MSCloudLoginAssistant" From fa86cfeaf09e0b6919bfc9a2ba60a99779955aa6 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Mon, 25 Nov 2024 08:28:12 -0500 Subject: [PATCH 07/10] Updated Dependencies --- CHANGELOG.md | 3 +- .../Dependencies/Manifest.psd1 | 44 +++++++++---------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f915d2a57..d099f0905f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,8 @@ * MISC * Removed hardcoded Graph urls and replaced by MSCloudLoginAssistant values. * DEPENDENCIES - * Updated DSCParser to version 2.0.0.13 + * Updated DSCParser to version 2.0.0.13. + * Updated Microsoft.Graph to version 2.25.0. * Updated Microsoft.PowerApps.Administration.PowerShell to version 2.0.200. * Updated MicrosoftTeams to version 6.7.0. diff --git a/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 b/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 index 9aefc1f9f2..39db52ebef 100644 --- a/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 +++ b/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 @@ -26,91 +26,91 @@ }, @{ ModuleName = 'Microsoft.Graph.Applications' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.Applications' - Requiredversion = '2.24.0' + Requiredversion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Authentication' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.DeviceManagement' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.Devices.CorporateManagement' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.DeviceManagement.Administration' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.DeviceManagement.Enrollment' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.NetworkAccess' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.Identity.DirectoryManagement' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.Identity.Governance' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.Identity.SignIns' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.Reports' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.Search' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.Teams' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.DeviceManagement.Administration' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.DirectoryObjects' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Groups' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Beta.Groups' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Planner' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Sites' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Users' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.Graph.Users.Actions' - RequiredVersion = '2.24.0' + RequiredVersion = '2.25.0' }, @{ ModuleName = 'Microsoft.PowerApps.Administration.PowerShell' From adc3a160d1af526b5eb61ac946f6f3dd54783ef0 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Mon, 25 Nov 2024 14:21:01 -0500 Subject: [PATCH 08/10] Various Fixes --- CHANGELOG.md | 6 +++++- .../MSFT_EXOMailContact/MSFT_EXOMailContact.psm1 | 4 ++++ .../DSCResources/MSFT_EXOPlace/MSFT_EXOPlace.psm1 | 8 +++++++- .../MSFT_EXOTransportRule/MSFT_EXOTransportRule.psm1 | 10 ++++++++++ Modules/Microsoft365DSC/Dependencies/Manifest.psd1 | 2 +- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d099f0905f..fe47039fbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ * AAD * Added ApplicationSecret auth method to multiple resources +* EXOMailContact + * Changed how empty arrays are returned. +* EXOPlace + * Changed how empty arrays are returned. * EXORecipientPermission * Added logic to update an existing recipient's permissions. * EXOEOPProtectionPolicyRule @@ -20,7 +24,7 @@ * MISC * Removed hardcoded Graph urls and replaced by MSCloudLoginAssistant values. * DEPENDENCIES - * Updated DSCParser to version 2.0.0.13. + * Updated DSCParser to version 2.0.0.14. * Updated Microsoft.Graph to version 2.25.0. * Updated Microsoft.PowerApps.Administration.PowerShell to version 2.0.200. * Updated MicrosoftTeams to version 6.7.0. diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailContact/MSFT_EXOMailContact.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailContact/MSFT_EXOMailContact.psm1 index 8553bf9155..cb39fd5900 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailContact/MSFT_EXOMailContact.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOMailContact/MSFT_EXOMailContact.psm1 @@ -268,6 +268,10 @@ function Get-TargetResource { $result."ExtensionCustomAttribute$i" = $contact."ExtensionCustomAttribute$i" } + else + { + $result."ExtensionCustomAttribute$i" = @() + } } Write-Verbose -Message "Found Mail Contact $($Name)" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOPlace/MSFT_EXOPlace.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOPlace/MSFT_EXOPlace.psm1 index 227fc1f57e..9327331b4d 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOPlace/MSFT_EXOPlace.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOPlace/MSFT_EXOPlace.psm1 @@ -181,6 +181,12 @@ function Get-TargetResource } } + $TagsValue = [Array] $place.Tags + if ($place.Tags -eq $null) + { + $TagsValue = @() + } + $result = @{ Identity = $place.Identity AudioDeviceName = $place.AudioDeviceName @@ -203,7 +209,7 @@ function Get-TargetResource PostalCode = $place.PostalCode State = $place.State Street = $place.Street - Tags = [Array] $place.Tags + Tags = $TagsValue VideoDeviceName = $place.VideoDeviceName Credential = $Credential Ensure = 'Present' diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOTransportRule/MSFT_EXOTransportRule.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOTransportRule/MSFT_EXOTransportRule.psm1 index 0cea524e88..89055e9a3f 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOTransportRule/MSFT_EXOTransportRule.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOTransportRule/MSFT_EXOTransportRule.psm1 @@ -967,6 +967,16 @@ function Get-TargetResource TenantId = $TenantId AccessTokens = $AccessTokens } + $inputParams = (Get-Command 'Get-TargetResource').Parameters + foreach ($key in $inputParams.Keys) + { + $propertyInfo = $inputParams.$key + $curVar = Get-Variable -Name $key -ErrorAction SilentlyContinue + if ($propertyInfo.ParameterType.Name -eq 'String[]' -and $curVar -ne $null -and $curVar.Value -eq $null) + { + $result.$key = @() + } + } # Formats DateTime as String if ($null -ne $result.ActivationDate) diff --git a/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 b/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 index 39db52ebef..e04173694f 100644 --- a/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 +++ b/Modules/Microsoft365DSC/Dependencies/Manifest.psd1 @@ -18,7 +18,7 @@ }, @{ ModuleName = 'DSCParser' - RequiredVersion = '2.0.0.13' + RequiredVersion = '2.0.0.14' }, @{ ModuleName = 'ExchangeOnlineManagement' From 892d4f7e0e72997c55a52340a4d393df1db26fe0 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Mon, 25 Nov 2024 14:21:47 -0500 Subject: [PATCH 09/10] Update CHANGELOG.md --- CHANGELOG.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe47039fbe..30dd94522b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,16 +4,19 @@ * AAD * Added ApplicationSecret auth method to multiple resources +* EXOEOPProtectionPolicyRule + * Added support for AccessTokens. +* EXOExternalInOutlook + * Added support for AccessTokens. * EXOMailContact * Changed how empty arrays are returned. * EXOPlace * Changed how empty arrays are returned. * EXORecipientPermission * Added logic to update an existing recipient's permissions. -* EXOEOPProtectionPolicyRule - * Added support for AccessTokens. -* EXOExternalInOutlook - * Added support for AccessTokens. +* EXOTransportRule + * Changed how empty arrays are returned. + * IntuneAndroidManagedStoreAppConfiguration * Initial release. * TeamsUserPolicyAssignment From 616d2a1815005900663925f45e9c98976b388d23 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Mon, 25 Nov 2024 16:07:14 -0500 Subject: [PATCH 10/10] Fixes #5430 --- CHANGELOG.md | 5 ++++- Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30dd94522b..a27150cfa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,9 +16,12 @@ * Added logic to update an existing recipient's permissions. * EXOTransportRule * Changed how empty arrays are returned. - * IntuneAndroidManagedStoreAppConfiguration * Initial release. +* IntuneAppConfigurationPolicy + * Fixes an issue where assignment wasn't properly set if the + groupId was null. + FIXES [#5430](https://github.com/microsoft/Microsoft365DSC/issues/5430) * TeamsUserPolicyAssignment * Added support for the Global policies. * TeamsUpgradePolicy diff --git a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 index 2ba46fb602..22f7ae49f8 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 @@ -982,7 +982,11 @@ function ConvertTo-IntunePolicyAssignment } elseif ($assignment.dataType -like '*GroupAssignmentTarget') { - $group = Get-MgGroup -GroupId ($assignment.groupId) -ErrorAction SilentlyContinue + $group = $null + if (-not [System.String]::IsNullOrEmpty($assignment.groupId)) + { + $group = Get-MgGroup -GroupId ($assignment.groupId) -ErrorAction SilentlyContinue + } if ($null -eq $group) { if ($assignment.groupDisplayName)