From 09afa70ae2c5358d48166aad5d67b4dae6089612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20Kr=C3=BCger?= <15608729+andikrueger@users.noreply.github.com> Date: Wed, 22 Nov 2023 15:24:14 +0100 Subject: [PATCH 1/5] Update launch.json - Fixes #3922 --- .vscode/launch.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 3bd859a536..67cd3116e1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,9 +6,7 @@ "request": "launch", "name": "Run current unit test", "script": "${file}", - "args": [ - "${workspaceRoot}/Tests/Unit/Stubs/Microsoft365.psm1" - ], + "args": [], "cwd": "${file}", "createTemporaryIntegratedConsole": true }, From ce758b06ab6e67bd78281e46b7cdcc620acd491e Mon Sep 17 00:00:00 2001 From: Philippe Kernevez Date: Fri, 19 Jan 2024 12:36:42 +0100 Subject: [PATCH 2/5] Share conversion and avoid useless requests --- CHANGELOG.md | 3 + .../MSFT_TeamsCallQueue.psm1 | 164 +++++++++++------- 2 files changed, 102 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c63de705..255a65f80c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,9 @@ FIXES [#4231](https://github.com/microsoft/Microsoft365DSC/issues/4231) * DEPENDENCIES * Updated Microsoft.Graph dependencies to version 2.12.0. +* TeamsCallQueue + * Reduce the number of Calls for Export using new cache pattern + FIXES [[#4191](https://github.com/microsoft/Microsoft365DSC/issues/4192)] # 1.24.117.1 diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 index 6c3f10b87a..209f711370 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 @@ -241,75 +241,13 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullReturn = $PSBoundParameters - $nullReturn.Ensure = 'Absent' try { $queue = Get-CsCallQueue -NameFilter $Name ` -ErrorAction SilentlyContinue | Where-Object -FilterScript {$_.Name -eq $Name} - if ($null -eq $queue) - { - return $nullReturn - } - else - { - return @{ - Name = $queue.Name - AgentAlertTime = $queue.AgentAlertTime - AllowOptOut = $queue.AllowOptOut - DistributionLists = [String[]]$queue.DistributionLists - UseDefaultMusicOnHold = $queue.UseDefaultMusicOnHold - WelcomeMusicAudioFileId = $queue.WelcomeMusicAudioFileId - MusicOnHoldAudioFileId = $queue.MusicOnHoldAudioFileId - OverflowAction = $queue.OverflowAction - OverflowActionTarget = $queue.OverflowActionTarget.Id - OverflowThreshold = $queue.OverflowThreshold - TimeoutAction = $queue.TimeoutAction - TimeoutActionTarget = $queue.TimeoutActionTarget.Id - TimeoutThreshold = $queue.TimeoutThreshold - RoutingMethod = $queue.RoutingMethod - PresenceBasedRouting = $queue.PresenceBasedRouting - ConferenceMode = $queue.ConferenceMode - Users = [String[]]$queue.Users - LanguageId = $queue.LanguageId - OboResourceAccountIds = [String[]]$queue.OboResourceAccountIds - OverflowDisconnectTextToSpeechPrompt = $queue.OverflowDisconnectTextToSpeechPrompt - OverflowDisconnectAudioFilePrompt = $queue.OverflowDisconnectAudioFilePrompt - OverflowRedirectPersonTextToSpeechPrompt = $queue.OverflowRedirectPersonTextToSpeechPrompt - OverflowRedirectPersonAudioFilePrompt = $queue.OverflowRedirectPersonAudioFilePrompt - OverflowRedirectVoiceAppTextToSpeechPrompt = $queue.OverflowRedirectVoiceAppTextToSpeechPrompt - OverflowRedirectVoiceAppAudioFilePrompt = $queue.OverflowRedirectVoiceAppAudioFilePrompt - OverflowRedirectPhoneNumberTextToSpeechPrompt = $queue.OverflowRedirectPhoneNumberTextToSpeechPrompt - OverflowRedirectPhoneNumberAudioFilePrompt = $queue.OverflowRedirectPhoneNumberAudioFilePrompt - OverflowRedirectVoicemailTextToSpeechPrompt = $queue.OverflowRedirectVoicemailTextToSpeechPrompt - OverflowRedirectVoicemailAudioFilePrompt = $queue.OverflowRedirectVoicemailAudioFilePrompt - OverflowSharedVoicemailTextToSpeechPrompt = $queue.OverflowSharedVoicemailTextToSpeechPrompt - OverflowSharedVoicemailAudioFilePrompt = $queue.OverflowSharedVoicemailAudioFilePrompt - EnableOverflowSharedVoicemailTranscription = $queue.EnableOverflowSharedVoicemailTranscription - TimeoutDisconnectTextToSpeechPrompt = $queue.TimeoutDisconnectTextToSpeechPrompt - TimeoutDisconnectAudioFilePrompt = $queue.TimeoutDisconnectAudioFilePrompt - TimeoutRedirectPersonTextToSpeechPrompt = $queue.TimeoutRedirectPersonTextToSpeechPrompt - TimeoutRedirectPersonAudioFilePrompt = $queue.TimeoutRedirectPersonAudioFilePrompt - TimeoutRedirectVoiceAppTextToSpeechPrompt = $queue.TimeoutRedirectVoiceAppTextToSpeechPrompt - TimeoutRedirectVoiceAppAudioFilePrompt = $queue.TimeoutRedirectVoiceAppAudioFilePrompt - TimeoutRedirectPhoneNumberTextToSpeechPrompt = $queue.TimeoutRedirectPhoneNumberTextToSpeechPrompt - TimeoutRedirectPhoneNumberAudioFilePrompt = $queue.TimeoutRedirectPhoneNumberAudioFilePrompt - TimeoutRedirectVoicemailTextToSpeechPrompt = $queue.TimeoutRedirectVoicemailTextToSpeechPrompt - TimeoutRedirectVoicemailAudioFilePrompt = $queue.TimeoutRedirectVoicemailAudioFilePrompt - TimeoutSharedVoicemailTextToSpeechPrompt = $queue.TimeoutSharedVoicemailTextToSpeechPrompt - TimeoutSharedVoicemailAudioFilePrompt = $queue.TimeoutSharedVoicemailAudioFilePrompt - EnableTimeoutSharedVoicemailTranscription = $queue.EnableTimeoutSharedVoicemailTranscription - ChannelId = $queue.ChannelId - ChannelUserObjectId = $queue.ChannelUserObjectId - AuthorizedUsers = [String[]]$queue.AuthorizedUsers - Ensure = 'Present' - Credential = $Credential - ApplicationId = $ApplicationId - TenantId = $TenantId - CertificateThumbprint = $CertificateThumbprint - } - } + return Convert-Resource -queue $queue -OriginBoundParameters $PSBoundParameters + } catch { @@ -323,6 +261,101 @@ function Get-TargetResource } } +function Convert-Resource +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [System.Object] + $queue, + + # [Parameter()] + # [System.Management.Automation.PSCredential] + # $Credential, + + # [Parameter()] + # [System.String] + # $ApplicationId, + + # [Parameter()] + # [System.String] + # $TenantId, + + # [Parameter()] + # [System.String] + # $CertificateThumbprint + [Parameter()] + [System.Collections.Hashtable] + $OriginBoundParameters + ) + + $nullReturn = $OriginBoundParameters + $nullReturn.Ensure = 'Absent' + if ($null -eq $queue) + { + return $nullReturn + } + else + { + return @{ + Name = $queue.Name + AgentAlertTime = $queue.AgentAlertTime + AllowOptOut = $queue.AllowOptOut + DistributionLists = [String[]]$queue.DistributionLists + UseDefaultMusicOnHold = $queue.UseDefaultMusicOnHold + WelcomeMusicAudioFileId = $queue.WelcomeMusicAudioFileId + MusicOnHoldAudioFileId = $queue.MusicOnHoldAudioFileId + OverflowAction = $queue.OverflowAction + OverflowActionTarget = $queue.OverflowActionTarget.Id + OverflowThreshold = $queue.OverflowThreshold + TimeoutAction = $queue.TimeoutAction + TimeoutActionTarget = $queue.TimeoutActionTarget.Id + TimeoutThreshold = $queue.TimeoutThreshold + RoutingMethod = $queue.RoutingMethod + PresenceBasedRouting = $queue.PresenceBasedRouting + ConferenceMode = $queue.ConferenceMode + Users = [String[]]$queue.Users + LanguageId = $queue.LanguageId + OboResourceAccountIds = [String[]]$queue.OboResourceAccountIds + OverflowDisconnectTextToSpeechPrompt = $queue.OverflowDisconnectTextToSpeechPrompt + OverflowDisconnectAudioFilePrompt = $queue.OverflowDisconnectAudioFilePrompt + OverflowRedirectPersonTextToSpeechPrompt = $queue.OverflowRedirectPersonTextToSpeechPrompt + OverflowRedirectPersonAudioFilePrompt = $queue.OverflowRedirectPersonAudioFilePrompt + OverflowRedirectVoiceAppTextToSpeechPrompt = $queue.OverflowRedirectVoiceAppTextToSpeechPrompt + OverflowRedirectVoiceAppAudioFilePrompt = $queue.OverflowRedirectVoiceAppAudioFilePrompt + OverflowRedirectPhoneNumberTextToSpeechPrompt = $queue.OverflowRedirectPhoneNumberTextToSpeechPrompt + OverflowRedirectPhoneNumberAudioFilePrompt = $queue.OverflowRedirectPhoneNumberAudioFilePrompt + OverflowRedirectVoicemailTextToSpeechPrompt = $queue.OverflowRedirectVoicemailTextToSpeechPrompt + OverflowRedirectVoicemailAudioFilePrompt = $queue.OverflowRedirectVoicemailAudioFilePrompt + OverflowSharedVoicemailTextToSpeechPrompt = $queue.OverflowSharedVoicemailTextToSpeechPrompt + OverflowSharedVoicemailAudioFilePrompt = $queue.OverflowSharedVoicemailAudioFilePrompt + EnableOverflowSharedVoicemailTranscription = $queue.EnableOverflowSharedVoicemailTranscription + TimeoutDisconnectTextToSpeechPrompt = $queue.TimeoutDisconnectTextToSpeechPrompt + TimeoutDisconnectAudioFilePrompt = $queue.TimeoutDisconnectAudioFilePrompt + TimeoutRedirectPersonTextToSpeechPrompt = $queue.TimeoutRedirectPersonTextToSpeechPrompt + TimeoutRedirectPersonAudioFilePrompt = $queue.TimeoutRedirectPersonAudioFilePrompt + TimeoutRedirectVoiceAppTextToSpeechPrompt = $queue.TimeoutRedirectVoiceAppTextToSpeechPrompt + TimeoutRedirectVoiceAppAudioFilePrompt = $queue.TimeoutRedirectVoiceAppAudioFilePrompt + TimeoutRedirectPhoneNumberTextToSpeechPrompt = $queue.TimeoutRedirectPhoneNumberTextToSpeechPrompt + TimeoutRedirectPhoneNumberAudioFilePrompt = $queue.TimeoutRedirectPhoneNumberAudioFilePrompt + TimeoutRedirectVoicemailTextToSpeechPrompt = $queue.TimeoutRedirectVoicemailTextToSpeechPrompt + TimeoutRedirectVoicemailAudioFilePrompt = $queue.TimeoutRedirectVoicemailAudioFilePrompt + TimeoutSharedVoicemailTextToSpeechPrompt = $queue.TimeoutSharedVoicemailTextToSpeechPrompt + TimeoutSharedVoicemailAudioFilePrompt = $queue.TimeoutSharedVoicemailAudioFilePrompt + EnableTimeoutSharedVoicemailTranscription = $queue.EnableTimeoutSharedVoicemailTranscription + ChannelId = $queue.ChannelId + ChannelUserObjectId = $queue.ChannelUserObjectId + AuthorizedUsers = [String[]]$queue.AuthorizedUsers + Ensure = 'Present' + Credential = $OriginBoundParameters.Credential + ApplicationId = $OriginBoundParameters.ApplicationId + TenantId = $OriginBoundParameters.TenantId + CertificateThumbprint = $OriginBoundParameters.CertificateThumbprint + } + } +} + function Set-TargetResource { [CmdletBinding()] @@ -907,7 +940,8 @@ function Export-TargetResource TenantId = $TenantId CertificateThumbprint = $CertificateThumbprint } - $Results = Get-TargetResource @Params + # $Results = Get-TargetResource @Params + $Results = Convert-Resource -queue $instance -OriginBoundParameters $params $Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode ` -Results $Results $currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName ` From 0b59d34af90a9cf548f49541f8003726f8b1b5a3 Mon Sep 17 00:00:00 2001 From: Philippe Kernevez Date: Thu, 25 Jan 2024 12:44:30 +0100 Subject: [PATCH 3/5] Use cache mecanism --- .../MSFT_TeamsCallQueue.psm1 | 176 ++++++++---------- 1 file changed, 76 insertions(+), 100 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 index 209f711370..902e561704 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsCallQueue/MSFT_TeamsCallQueue.psm1 @@ -241,13 +241,85 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion + $nullReturn = $PSBoundParameters + $nullReturn.Ensure = 'Absent' try { - $queue = Get-CsCallQueue -NameFilter $Name ` - -ErrorAction SilentlyContinue | Where-Object -FilterScript {$_.Name -eq $Name} + if (-not $Script:ExportMode) + { + Write-Host -Message "Getting Office 365 queue $Name" + $queue = Get-CsCallQueue -NameFilter $Name ` + -ErrorAction SilentlyContinue | Where-Object -FilterScript {$_.Name -eq $Name} + } + else + { + Write-Host -Message "Retrieving queue $Name from the exported instances" + $queue = $Script:exportedInstances | Where-Object -FilterScript {$_.Name -eq $Name} + } - return Convert-Resource -queue $queue -OriginBoundParameters $PSBoundParameters + if ($null -eq $queue) + { + return $nullReturn + } + else + { + return @{ + Name = $queue.Name + AgentAlertTime = $queue.AgentAlertTime + AllowOptOut = $queue.AllowOptOut + DistributionLists = [String[]]$queue.DistributionLists + UseDefaultMusicOnHold = $queue.UseDefaultMusicOnHold + WelcomeMusicAudioFileId = $queue.WelcomeMusicAudioFileId + MusicOnHoldAudioFileId = $queue.MusicOnHoldAudioFileId + OverflowAction = $queue.OverflowAction + OverflowActionTarget = $queue.OverflowActionTarget.Id + OverflowThreshold = $queue.OverflowThreshold + TimeoutAction = $queue.TimeoutAction + TimeoutActionTarget = $queue.TimeoutActionTarget.Id + TimeoutThreshold = $queue.TimeoutThreshold + RoutingMethod = $queue.RoutingMethod + PresenceBasedRouting = $queue.PresenceBasedRouting + ConferenceMode = $queue.ConferenceMode + Users = [String[]]$queue.Users + LanguageId = $queue.LanguageId + OboResourceAccountIds = [String[]]$queue.OboResourceAccountIds + OverflowDisconnectTextToSpeechPrompt = $queue.OverflowDisconnectTextToSpeechPrompt + OverflowDisconnectAudioFilePrompt = $queue.OverflowDisconnectAudioFilePrompt + OverflowRedirectPersonTextToSpeechPrompt = $queue.OverflowRedirectPersonTextToSpeechPrompt + OverflowRedirectPersonAudioFilePrompt = $queue.OverflowRedirectPersonAudioFilePrompt + OverflowRedirectVoiceAppTextToSpeechPrompt = $queue.OverflowRedirectVoiceAppTextToSpeechPrompt + OverflowRedirectVoiceAppAudioFilePrompt = $queue.OverflowRedirectVoiceAppAudioFilePrompt + OverflowRedirectPhoneNumberTextToSpeechPrompt = $queue.OverflowRedirectPhoneNumberTextToSpeechPrompt + OverflowRedirectPhoneNumberAudioFilePrompt = $queue.OverflowRedirectPhoneNumberAudioFilePrompt + OverflowRedirectVoicemailTextToSpeechPrompt = $queue.OverflowRedirectVoicemailTextToSpeechPrompt + OverflowRedirectVoicemailAudioFilePrompt = $queue.OverflowRedirectVoicemailAudioFilePrompt + OverflowSharedVoicemailTextToSpeechPrompt = $queue.OverflowSharedVoicemailTextToSpeechPrompt + OverflowSharedVoicemailAudioFilePrompt = $queue.OverflowSharedVoicemailAudioFilePrompt + EnableOverflowSharedVoicemailTranscription = $queue.EnableOverflowSharedVoicemailTranscription + TimeoutDisconnectTextToSpeechPrompt = $queue.TimeoutDisconnectTextToSpeechPrompt + TimeoutDisconnectAudioFilePrompt = $queue.TimeoutDisconnectAudioFilePrompt + TimeoutRedirectPersonTextToSpeechPrompt = $queue.TimeoutRedirectPersonTextToSpeechPrompt + TimeoutRedirectPersonAudioFilePrompt = $queue.TimeoutRedirectPersonAudioFilePrompt + TimeoutRedirectVoiceAppTextToSpeechPrompt = $queue.TimeoutRedirectVoiceAppTextToSpeechPrompt + TimeoutRedirectVoiceAppAudioFilePrompt = $queue.TimeoutRedirectVoiceAppAudioFilePrompt + TimeoutRedirectPhoneNumberTextToSpeechPrompt = $queue.TimeoutRedirectPhoneNumberTextToSpeechPrompt + TimeoutRedirectPhoneNumberAudioFilePrompt = $queue.TimeoutRedirectPhoneNumberAudioFilePrompt + TimeoutRedirectVoicemailTextToSpeechPrompt = $queue.TimeoutRedirectVoicemailTextToSpeechPrompt + TimeoutRedirectVoicemailAudioFilePrompt = $queue.TimeoutRedirectVoicemailAudioFilePrompt + TimeoutSharedVoicemailTextToSpeechPrompt = $queue.TimeoutSharedVoicemailTextToSpeechPrompt + TimeoutSharedVoicemailAudioFilePrompt = $queue.TimeoutSharedVoicemailAudioFilePrompt + EnableTimeoutSharedVoicemailTranscription = $queue.EnableTimeoutSharedVoicemailTranscription + ChannelId = $queue.ChannelId + ChannelUserObjectId = $queue.ChannelUserObjectId + AuthorizedUsers = [String[]]$queue.AuthorizedUsers + Ensure = 'Present' + Credential = $Credential + ApplicationId = $ApplicationId + TenantId = $TenantId + CertificateThumbprint = $CertificateThumbprint + } + } } catch { @@ -261,101 +333,6 @@ function Get-TargetResource } } -function Convert-Resource -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [System.Object] - $queue, - - # [Parameter()] - # [System.Management.Automation.PSCredential] - # $Credential, - - # [Parameter()] - # [System.String] - # $ApplicationId, - - # [Parameter()] - # [System.String] - # $TenantId, - - # [Parameter()] - # [System.String] - # $CertificateThumbprint - [Parameter()] - [System.Collections.Hashtable] - $OriginBoundParameters - ) - - $nullReturn = $OriginBoundParameters - $nullReturn.Ensure = 'Absent' - if ($null -eq $queue) - { - return $nullReturn - } - else - { - return @{ - Name = $queue.Name - AgentAlertTime = $queue.AgentAlertTime - AllowOptOut = $queue.AllowOptOut - DistributionLists = [String[]]$queue.DistributionLists - UseDefaultMusicOnHold = $queue.UseDefaultMusicOnHold - WelcomeMusicAudioFileId = $queue.WelcomeMusicAudioFileId - MusicOnHoldAudioFileId = $queue.MusicOnHoldAudioFileId - OverflowAction = $queue.OverflowAction - OverflowActionTarget = $queue.OverflowActionTarget.Id - OverflowThreshold = $queue.OverflowThreshold - TimeoutAction = $queue.TimeoutAction - TimeoutActionTarget = $queue.TimeoutActionTarget.Id - TimeoutThreshold = $queue.TimeoutThreshold - RoutingMethod = $queue.RoutingMethod - PresenceBasedRouting = $queue.PresenceBasedRouting - ConferenceMode = $queue.ConferenceMode - Users = [String[]]$queue.Users - LanguageId = $queue.LanguageId - OboResourceAccountIds = [String[]]$queue.OboResourceAccountIds - OverflowDisconnectTextToSpeechPrompt = $queue.OverflowDisconnectTextToSpeechPrompt - OverflowDisconnectAudioFilePrompt = $queue.OverflowDisconnectAudioFilePrompt - OverflowRedirectPersonTextToSpeechPrompt = $queue.OverflowRedirectPersonTextToSpeechPrompt - OverflowRedirectPersonAudioFilePrompt = $queue.OverflowRedirectPersonAudioFilePrompt - OverflowRedirectVoiceAppTextToSpeechPrompt = $queue.OverflowRedirectVoiceAppTextToSpeechPrompt - OverflowRedirectVoiceAppAudioFilePrompt = $queue.OverflowRedirectVoiceAppAudioFilePrompt - OverflowRedirectPhoneNumberTextToSpeechPrompt = $queue.OverflowRedirectPhoneNumberTextToSpeechPrompt - OverflowRedirectPhoneNumberAudioFilePrompt = $queue.OverflowRedirectPhoneNumberAudioFilePrompt - OverflowRedirectVoicemailTextToSpeechPrompt = $queue.OverflowRedirectVoicemailTextToSpeechPrompt - OverflowRedirectVoicemailAudioFilePrompt = $queue.OverflowRedirectVoicemailAudioFilePrompt - OverflowSharedVoicemailTextToSpeechPrompt = $queue.OverflowSharedVoicemailTextToSpeechPrompt - OverflowSharedVoicemailAudioFilePrompt = $queue.OverflowSharedVoicemailAudioFilePrompt - EnableOverflowSharedVoicemailTranscription = $queue.EnableOverflowSharedVoicemailTranscription - TimeoutDisconnectTextToSpeechPrompt = $queue.TimeoutDisconnectTextToSpeechPrompt - TimeoutDisconnectAudioFilePrompt = $queue.TimeoutDisconnectAudioFilePrompt - TimeoutRedirectPersonTextToSpeechPrompt = $queue.TimeoutRedirectPersonTextToSpeechPrompt - TimeoutRedirectPersonAudioFilePrompt = $queue.TimeoutRedirectPersonAudioFilePrompt - TimeoutRedirectVoiceAppTextToSpeechPrompt = $queue.TimeoutRedirectVoiceAppTextToSpeechPrompt - TimeoutRedirectVoiceAppAudioFilePrompt = $queue.TimeoutRedirectVoiceAppAudioFilePrompt - TimeoutRedirectPhoneNumberTextToSpeechPrompt = $queue.TimeoutRedirectPhoneNumberTextToSpeechPrompt - TimeoutRedirectPhoneNumberAudioFilePrompt = $queue.TimeoutRedirectPhoneNumberAudioFilePrompt - TimeoutRedirectVoicemailTextToSpeechPrompt = $queue.TimeoutRedirectVoicemailTextToSpeechPrompt - TimeoutRedirectVoicemailAudioFilePrompt = $queue.TimeoutRedirectVoicemailAudioFilePrompt - TimeoutSharedVoicemailTextToSpeechPrompt = $queue.TimeoutSharedVoicemailTextToSpeechPrompt - TimeoutSharedVoicemailAudioFilePrompt = $queue.TimeoutSharedVoicemailAudioFilePrompt - EnableTimeoutSharedVoicemailTranscription = $queue.EnableTimeoutSharedVoicemailTranscription - ChannelId = $queue.ChannelId - ChannelUserObjectId = $queue.ChannelUserObjectId - AuthorizedUsers = [String[]]$queue.AuthorizedUsers - Ensure = 'Present' - Credential = $OriginBoundParameters.Credential - ApplicationId = $OriginBoundParameters.ApplicationId - TenantId = $OriginBoundParameters.TenantId - CertificateThumbprint = $OriginBoundParameters.CertificateThumbprint - } - } -} - function Set-TargetResource { [CmdletBinding()] @@ -940,8 +917,7 @@ function Export-TargetResource TenantId = $TenantId CertificateThumbprint = $CertificateThumbprint } - # $Results = Get-TargetResource @Params - $Results = Convert-Resource -queue $instance -OriginBoundParameters $params + $Results = Get-TargetResource @Params $Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode ` -Results $Results $currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName ` From e1a17cafc32adc70aef48e2242f75ce071be65a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20Kr=C3=BCger?= <15608729+andikrueger@users.noreply.github.com> Date: Thu, 22 Feb 2024 09:04:35 +0100 Subject: [PATCH 4/5] Update launch.json script arguments --- .vscode/launch.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 67cd3116e1..00945a4e3e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,8 +16,7 @@ "name": "Get current unit test code overage", "script": "${workspaceRoot}/.vscode/GetTestCoverage.ps1", "args": [ - "${file}", - "${workspaceRoot}/Tests/Unit/Stubs/Microsoft365.psm1" + "${file}" ], "createTemporaryIntegratedConsole": true } From 6d72cc3dc3814cb49682eaa88fcd1f72b9fdb905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20Kr=C3=BCger?= <15608729+andikrueger@users.noreply.github.com> Date: Mon, 26 Feb 2024 21:16:23 +0100 Subject: [PATCH 5/5] Add code coverage and test launch configurations --- .vscode/GetTestCoverage.ps1 | 41 ++++++++++++++++++++++--------------- .vscode/launch.json | 16 +++++++++++++++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/.vscode/GetTestCoverage.ps1 b/.vscode/GetTestCoverage.ps1 index 458df495a2..0b3a88ff68 100644 --- a/.vscode/GetTestCoverage.ps1 +++ b/.vscode/GetTestCoverage.ps1 @@ -2,31 +2,38 @@ param( [Parameter(Mandatory = $true)] [string] - $UnitTestFilePath, - - [Parameter(Mandatory = $true)] - [string] - $CmdletModule = (Join-Path -Path $PSScriptRoot ` - -ChildPath '..\Stubs\Microsoft365.psm1' ` - -Resolve) + $UnitTestFilePath ) -if ($UnitTestFilePath.EndsWith('Tests.ps1')) -{ +$moduleName = 'Pester' +$minVersion = '5.5.0' - $pesterParameters = @{ - Path = $unitTestFilePath - Parameters = @{ - CmdletModule = $CmdletModule - } - } +$module = Get-Module -ListAvailable | Where-Object { $_.Name -eq $moduleName -and $_.Version -ge $minVersion } +if ($module -ne $null) +{ + Write-Output "Module $moduleName with version greater than or equal to $minVersion found." +} +else +{ + Write-Output "Module $moduleName with version greater than or equal to $minVersion not found." + Write-Output 'Please install the module using the following command:' + Write-Output "Install-Module -Name $moduleName -MinimumVersion $minVersion" + return +} + +if ($UnitTestFilePath.EndsWith('Tests.ps1')) +{ $unitTest = Get-Item -Path $UnitTestFilePath $unitTestName = "$($unitTest.Name.Split('.')[1])" - $unitTestFilePath = (Join-Path -Path $PSScriptRoot ` + $coveragePath = (Join-Path -Path $PSScriptRoot ` -ChildPath "..\Modules\Microsoft365DSC\DSCResources\MSFT_$($unitTestName)\MSFT_$($unitTestName).psm1" ` -Resolve) - Invoke-Pester -Script $pesterParameters -CodeCoverage $UnitTestFilePath -Verbose + $config = New-PesterConfiguration + $config.Run.Path = $UnitTestFilePath + $config.CodeCoverage.Enabled = $true + $config.CodeCoverage.Path = $coveragePath + Invoke-Pester -Configuration $config } diff --git a/.vscode/launch.json b/.vscode/launch.json index 00945a4e3e..1258adeb13 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -19,6 +19,22 @@ "${file}" ], "createTemporaryIntegratedConsole": true + }, + { + "type": "PowerShell", + "request": "launch", + "name": "Run all QA tests", + "script": "Import-Module '${workspaceRoot}/Tests/TestHarness.psm1'; $QaResults = Invoke-QualityChecksHarness ", + "args": [], + "createTemporaryIntegratedConsole": true + }, + { + "type": "PowerShell", + "request": "launch", + "name": "Run all Unit Tests", + "script": "Import-Module '${workspaceRoot}/Tests/TestHarness.psm1'; $UnitResults = Invoke-TestHarness", + "args": [], + "createTemporaryIntegratedConsole": true } ] }