From e7e28115b4c675dcfce0b2e11334867b85e416c4 Mon Sep 17 00:00:00 2001 From: Bjorn Henrik Formo Date: Mon, 16 Jan 2023 13:45:14 +0100 Subject: [PATCH 1/5] removes quotes around vars for auths - fixes #2784 --- .../MSFT_PlannerTask/MSFT_PlannerTask.psm1 | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_PlannerTask/MSFT_PlannerTask.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_PlannerTask/MSFT_PlannerTask.psm1 index cde7355d23..09af045620 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_PlannerTask/MSFT_PlannerTask.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_PlannerTask/MSFT_PlannerTask.psm1 @@ -784,8 +784,34 @@ function Export-TargetResource $currentDSCBlock += ' PlannerTask ' + (New-Guid).ToString() + "`r`n" $currentDSCBlock += " {`r`n" $content = Get-DSCBlock -Params $result -ModulePath $PSScriptRoot - $content = Convert-DSCStringParamToVariable -DSCBlock $content ` - -ParameterName 'Credential' + + # Ensure quotes are removed around auth variables + if ($Credential) + { + $content = Convert-DSCStringParamToVariable -DSCBlock $content ` + -ParameterName 'Credential' + } + if ($ApplicationId) + { + $content = Convert-DSCStringParamToVariable -DSCBlock $content ` + -ParameterName 'ApplicationId' + } + if ($ApplicationSecret) + { + $content = Convert-DSCStringParamToVariable -DSCBlock $content ` + -ParameterName 'ApplicationSecret' + } + if ($TenantId) + { + $content = Convert-DSCStringParamToVariable -DSCBlock $content ` + -ParameterName 'TenantId' + } + if ($CertificateThumbprint) + { + $content = Convert-DSCStringParamToVariable -DSCBlock $content ` + -ParameterName 'CertificateThumbprint' + } + if ($result.Attachments.Length -gt 0) { $content = Convert-DSCStringParamToVariable -DSCBlock $content ` From c3fb01af65627d11a8ccc8c8b30c643319bcbf1a Mon Sep 17 00:00:00 2001 From: Bjorn Henrik Formo Date: Mon, 16 Jan 2023 16:17:19 +0100 Subject: [PATCH 2/5] to conform with PlannerBucket and PlannerPlan --- .../MSFT_PlannerTask/MSFT_PlannerTask.psm1 | 43 ++++--------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_PlannerTask/MSFT_PlannerTask.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_PlannerTask/MSFT_PlannerTask.psm1 index 09af045620..eb0e479b24 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_PlannerTask/MSFT_PlannerTask.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_PlannerTask/MSFT_PlannerTask.psm1 @@ -781,53 +781,26 @@ function Export-TargetResource $result.Notes = $result.Notes.Replace('&', "``&") } - $currentDSCBlock += ' PlannerTask ' + (New-Guid).ToString() + "`r`n" - $currentDSCBlock += " {`r`n" - $content = Get-DSCBlock -Params $result -ModulePath $PSScriptRoot - - # Ensure quotes are removed around auth variables - if ($Credential) - { - $content = Convert-DSCStringParamToVariable -DSCBlock $content ` - -ParameterName 'Credential' - } - if ($ApplicationId) - { - $content = Convert-DSCStringParamToVariable -DSCBlock $content ` - -ParameterName 'ApplicationId' - } - if ($ApplicationSecret) - { - $content = Convert-DSCStringParamToVariable -DSCBlock $content ` - -ParameterName 'ApplicationSecret' - } - if ($TenantId) - { - $content = Convert-DSCStringParamToVariable -DSCBlock $content ` - -ParameterName 'TenantId' - } - if ($CertificateThumbprint) - { - $content = Convert-DSCStringParamToVariable -DSCBlock $content ` - -ParameterName 'CertificateThumbprint' - } + $currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName ` + -ConnectionMode $ConnectionMode ` + -ModulePath $PSScriptRoot ` + -Results $result ` + -Credential $Credential if ($result.Attachments.Length -gt 0) { - $content = Convert-DSCStringParamToVariable -DSCBlock $content ` + $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock ` -ParameterName 'Attachments' ` -IsCIMArray $true } if ($result.Checklist.Length -gt 0) { - $content = Convert-DSCStringParamToVariable -DSCBlock $content ` + $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock ` -ParameterName 'Checklist' ` -IsCIMArray $true } - $currentDSCBlock += $content - $currentDSCBlock += " }`r`n" - $dscContent += $currentDSCBlock + $dscContent += $currentDSCBlock Save-M365DSCPartialExport -Content $currentDSCBlock ` -FileName $Global:PartialExportFileName $k++ From c6efb19c1c7944e5dc11962d371590d1e7360f59 Mon Sep 17 00:00:00 2001 From: Bjorn Henrik Formo Date: Mon, 16 Jan 2023 22:09:04 +0100 Subject: [PATCH 3/5] added to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b633d34bac..5e9dfd716e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ * PlannerTask * Refactored to leverage the official cmdlets instead of using the legacy GraphHandlers. FIXES [#2767](https://github.com/microsoft/Microsoft365DSC/issues/2767) + * Changed PlannerTask/Export-TargetResource to call Get-M365DSCExportContentForResource + to simply/conform + variables for authentation are added correctly + FIXES [#2784](https://github.com/microsoft/Microsoft365DSC/issues/2784) * DEPENDENCIES * Updated Microsoft.Graph.* to version 1.20.0 * Updated MSCloudLoginAssistant to version 1.0.103 From 1209a79cebbe2cdd9386fe1e2b1ae287b69f1dda Mon Sep 17 00:00:00 2001 From: Bjorn Henrik Formo Date: Mon, 16 Jan 2023 22:13:02 +0100 Subject: [PATCH 4/5] bugfix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e9dfd716e..3fd6249dd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ * Refactored to leverage the official cmdlets instead of using the legacy GraphHandlers. FIXES [#2767](https://github.com/microsoft/Microsoft365DSC/issues/2767) * Changed PlannerTask/Export-TargetResource to call Get-M365DSCExportContentForResource - to simply/conform + variables for authentation are added correctly + to simplify/conform + variables for authentation are added correctly FIXES [#2784](https://github.com/microsoft/Microsoft365DSC/issues/2784) * DEPENDENCIES * Updated Microsoft.Graph.* to version 1.20.0 From 264b5f4027dc30f9da01e61270bab877188d82d0 Mon Sep 17 00:00:00 2001 From: Bjorn Henrik Formo Date: Mon, 16 Jan 2023 22:32:36 +0100 Subject: [PATCH 5/5] added back entry to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f91111d6e..c092fb80da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ * PlannerTask * Refactored to leverage the official cmdlets instead of using the legacy GraphHandlers. FIXES [#2767](https://github.com/microsoft/Microsoft365DSC/issues/2767) + * Changed Export-TargetResource to call Get-M365DSCExportContentForResource + to simplify/conform + variables for authentation are added correctly + FIXES [#2784](https://github.com/microsoft/Microsoft365DSC/issues/2784) * SCRetentionCompliancePolicy * Fixes an issue where the SkypeLocation was trying to be converted to a string when it was an array. FIXES [#2789](https://github.com/microsoft/Microsoft365DSC/issues/2789)