Skip to content

Commit 709a211

Browse files
Merge branch 'Dev' into feat/improve-install-module
2 parents 730330b + 282d2ab commit 709a211

File tree

33 files changed

+211
-130684
lines changed

33 files changed

+211
-130684
lines changed

.github/workflows/website-deploy-prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
name: Deploy to Production
4444
needs: build
4545
steps:
46-
- uses: actions/download-artifact@4
46+
- uses: actions/download-artifact@v4
4747
with:
4848
name: website-build
4949
- name: Deploy

.markdownlint.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"default": true,
3+
"MD013": false,
4+
"MD025": false,
35
"MD029": {
46
"style": "ordered"
57
},

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"type": "PowerShell",
1515
"request": "launch",
1616
"name": "Get current unit test code overage",
17-
"script": "${workspaceRoot}/.vscode/GetTestCoverage.ps1",
17+
"script": "${workspaceRoot}/Tests/Scripts/Get-TestCoverage.ps1",
1818
"args": [
1919
"${file}"
2020
],

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
* IntuneDeviceCompliancePolicyAndroidDeviceOwner
1919
* Fixed an issue where a JSON serialization warning was outputted
2020
due to the object depth exceeding two levels.
21+
* M365DSCDRGUtil
22+
* Fixed an issue where `Rename-M365DSCCimInstanceParameter` omitted values.
23+
FIXES [#6727](https://github.com/microsoft/Microsoft365DSC/issues/6727)
24+
FIXES [#6779](https://github.com/microsoft/Microsoft365DSC/issues/6779)
25+
* M365DSCReverse
26+
* Added `TenantGuid` entry to the `ConfigurationData.psd1` file during export.
27+
FIXES [#6689](https://github.com/microsoft/Microsoft365DSC/issues/6689)
2128
* M365DSCUtil
2229
* Improved module installation speed for `Update-M365DSCModule`.
2330
* MISC
@@ -87,6 +94,8 @@
8794
* Fixed an issue where updating Intune assignments did not include all properties.
8895
FIXES [#6697](https://github.com/microsoft/Microsoft365DSC/issues/6697)
8996
* Updated comparison function `Compare-M365DSCComplexObject` to non-recursive.
97+
* M365DSCResourceGenerator
98+
* Updated example generation to always create examples.
9099
* M365DSCReverse
91100
* Added handling of custom token replacements.
92101
* M365DSCUtil
@@ -100,17 +109,19 @@
100109
* MISC
101110
* Added and removed mismatches between parameters and their schema.
102111
* Added quality assurance checks for parameter and schema mismatches.
103-
* Refactor EXO resources to align with the default resource code layout.
104112
* Moved the `Examples` folder to the top of the repository to reduce core module size.
113+
* Refactored EXO resources to align with the default resource code layout.
114+
* Refactored module structure.
105115
* Removed internal module `M365DSCExoResourceUtils`.
106116
* Removed unused internal functions `Remove-M365DSCCimInstanceTrailingCharacterFromExport`,
107117
`Update-M365DSCExchangeResourcesSettingsJSON`, `Update-M365DSCSharePointResourcesSettingsJSON`,
108118
`Split-ArrayByParts`, `Get-SPOUserProfilePropertyInstance` and `Remove-M365DSCEmptyValue`.
119+
* Streamlined the report generation and added new visual styles.
120+
* Updated the `SchemaDefinition.json` to a compressed version.
109121
* DEPENDENCIES
110122
* Updated DSCParser to version 2.0.0.21.
111123
* Updated MSCloudLoginAssistant to version 1.1.55.
112124
FIXES [#6728](https://github.com/microsoft/Microsoft365DSC/issues/6728)
113-
* Streamlined the report generation and added new visual styles.
114125

115126
# 1.25.1112.1
116127

Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceConfigurationTrustedCertificatePolicyWindows10/MSFT_IntuneDeviceConfigurationTrustedCertificatePolicyWindows10.psm1

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ function Set-TargetResource
273273
#endregion
274274

275275
$currentInstance = Get-TargetResource @PSBoundParameters
276-
277276
$BoundParameters = Remove-M365DSCAuthenticationParameter -BoundParameters $PSBoundParameters
278277

279278
if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Absent')
@@ -285,20 +284,12 @@ function Set-TargetResource
285284
$CreateParameters = Rename-M365DSCCimInstanceParameter -Properties $CreateParameters
286285
$CreateParameters.Remove('Id') | Out-Null
287286

288-
$keys = (([Hashtable]$CreateParameters).Clone()).Keys
289-
foreach ($key in $keys)
290-
{
291-
if ($null -ne $CreateParameters.$key -and $CreateParameters.$key.GetType().Name -like '*cimInstance*')
292-
{
293-
$CreateParameters.$key = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $CreateParameters.$key
294-
}
295-
}
296287
#region resource generator code
297288
$CreateParameters.Add('@odata.type', '#microsoft.graph.windows81TrustedRootCertificate')
298289
$policy = New-MgBetaDeviceManagementDeviceConfiguration -BodyParameter $CreateParameters
299290
$assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments
300291

301-
if ($policy.id)
292+
if ($policy.Id)
302293
{
303294
Update-DeviceConfigurationPolicyAssignment -DeviceConfigurationPolicyId $policy.id `
304295
-Targets $assignmentsHash `
@@ -310,28 +301,19 @@ function Set-TargetResource
310301
{
311302
Write-Verbose -Message "Updating the Intune Device Configuration Trusted Certificate Policy for Windows10 with Id {$($currentInstance.Id)}"
312303
$BoundParameters.Remove('Assignments') | Out-Null
304+
$BoundParameters.Remove('Id') | Out-Null
313305

314306
$UpdateParameters = ([Hashtable]$BoundParameters).Clone()
315307
$UpdateParameters = Rename-M365DSCCimInstanceParameter -Properties $UpdateParameters
316308

317-
$UpdateParameters.Remove('Id') | Out-Null
318-
319-
$keys = (([Hashtable]$UpdateParameters).Clone()).Keys
320-
foreach ($key in $keys)
321-
{
322-
if ($null -ne $UpdateParameters.$key -and $UpdateParameters.$key.GetType().Name -like '*cimInstance*')
323-
{
324-
$UpdateParameters.$key = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $UpdateParameters.$key
325-
}
326-
}
327309
#region resource generator code
328310
$UpdateParameters.Add('@odata.type', '#microsoft.graph.windows81TrustedRootCertificate')
329311
Update-MgBetaDeviceManagementDeviceConfiguration `
330312
-DeviceConfigurationId $currentInstance.Id `
331313
-BodyParameter $UpdateParameters
332314
$assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments
333315
Update-DeviceConfigurationPolicyAssignment `
334-
-DeviceConfigurationPolicyId $currentInstance.id `
316+
-DeviceConfigurationPolicyId $currentInstance.Id `
335317
-Targets $assignmentsHash `
336318
-Repository 'deviceManagement/deviceConfigurations'
337319
#endregion

Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogCustomPolicyWindows10/MSFT_IntuneSettingCatalogCustomPolicyWindows10.psm1

Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ function Set-TargetResource
363363
}
364364
}
365365
#region resource generator code
366-
Update-IntuneDeviceConfigurationPolicy `
367-
-DeviceManagementConfigurationPolicyId $currentInstance.Id `
366+
Update-IntuneDeviceConfigurationPolicy `
367+
-DeviceConfigurationPolicyId $currentInstance.Id `
368368
@UpdateParameters
369369

370370
$assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments
@@ -847,84 +847,4 @@ function Get-SettingValue
847847
return $complexValue
848848
}
849849

850-
function Update-IntuneDeviceConfigurationPolicy
851-
{
852-
[CmdletBinding()]
853-
[OutputType([System.Collections.Hashtable])]
854-
param
855-
(
856-
[Parameter(Mandatory = 'true')]
857-
[System.String]
858-
$DeviceManagementConfigurationPolicyId,
859-
860-
[Parameter()]
861-
[System.String]
862-
$Name,
863-
864-
[Parameter()]
865-
[System.String]
866-
$Description,
867-
868-
[Parameter()]
869-
[System.String]
870-
$Platforms,
871-
872-
[Parameter()]
873-
[System.String]
874-
$Technologies,
875-
876-
[Parameter()]
877-
[System.String]
878-
$TemplateReferenceId,
879-
880-
[Parameter()]
881-
[Array]
882-
$Settings,
883-
884-
[Parameter()]
885-
[System.String[]]
886-
$RoleScopeTagIds
887-
)
888-
889-
try
890-
{
891-
$Uri = (Get-MSCloudLoginConnectionProfile -Workload MicrosoftGraph).ResourceUrl + "beta/deviceManagement/configurationPolicies/$DeviceManagementConfigurationPolicyId"
892-
893-
$policy = @{
894-
'name' = $Name
895-
'description' = $Description
896-
'platforms' = $Platforms
897-
'templateReference' = @{'templateId' = $TemplateReferenceId }
898-
'technologies' = $Technologies
899-
'settings' = $Settings
900-
'roleScopeTagIds' = $RoleScopeTagIds
901-
}
902-
903-
if (-not $RoleScopeTagIds -or $RoleScopeTagIds.Count -eq 0)
904-
{
905-
# No tag IDs provided -> use the default Intune tag "0"
906-
$policy['roleScopeTagIds'] = @("0")
907-
}
908-
else
909-
{
910-
# Tag IDs provided -> force array type to ensure Graph serialization consistency
911-
$policy['roleScopeTagIds'] = @($RoleScopeTagIds)
912-
}
913-
914-
$body = $policy | ConvertTo-Json -Depth 100
915-
#Write-Verbose -Message $body
916-
Invoke-MgGraphRequest -Method PUT -Uri $Uri -Body $body -ErrorAction Stop 4> $null
917-
}
918-
catch
919-
{
920-
New-M365DSCLogEntry -Message 'Error updating data:' `
921-
-Exception $_ `
922-
-Source $($MyInvocation.MyCommand.Source) `
923-
-TenantId $TenantId `
924-
-Credential $Credential
925-
926-
return $null
927-
}
928-
}
929-
930850
Export-ModuleMember -Function *-TargetResource

Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWindowsUpdateForBusinessDriverUpdateProfileWindows10/MSFT_IntuneWindowsUpdateForBusinessDriverUpdateProfileWindows10.psm1

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ function Set-TargetResource
263263
#endregion
264264

265265
$currentInstance = Get-TargetResource @PSBoundParameters
266-
267266
$BoundParameters = Remove-M365DSCAuthenticationParameter -BoundParameters $PSBoundParameters
268267

269268
if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Absent')
@@ -274,23 +273,14 @@ function Set-TargetResource
274273
$CreateParameters = Rename-M365DSCCimInstanceParameter -Properties $CreateParameters
275274
$CreateParameters.Remove('Id') | Out-Null
276275

277-
$keys = (([Hashtable]$CreateParameters).Clone()).Keys
278-
foreach ($key in $keys)
279-
{
280-
if ($null -ne $CreateParameters.$key -and $CreateParameters.$key.GetType().Name -like '*cimInstance*')
281-
{
282-
$CreateParameters.$key = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $CreateParameters.$key
283-
}
284-
}
285-
286276
#region resource generator code
287277
$uri = '/beta/deviceManagement/windowsDriverUpdateProfiles'
288278
$policy = Invoke-MgGraphRequest -Method POST -Uri $uri -Body $($CreateParameters | ConvertTo-Json)
289279
$assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments
290280

291281
if ($policy.id)
292282
{
293-
Update-DeviceConfigurationPolicyAssignment -DeviceConfigurationPolicyId $policy.id `
283+
Update-DeviceConfigurationPolicyAssignment -DeviceConfigurationPolicyId $policy.Id `
294284
-Targets $assignmentsHash `
295285
-Repository 'deviceManagement/windowsDriverUpdateProfiles'
296286
}
@@ -305,14 +295,6 @@ function Set-TargetResource
305295
$UpdateParameters.Remove('ApprovalType') | Out-Null
306296
$UpdateParameters.Remove('Id') | Out-Null
307297

308-
$keys = (([Hashtable]$UpdateParameters).Clone()).Keys
309-
foreach ($key in $keys)
310-
{
311-
if ($null -ne $UpdateParameters.$key -and $UpdateParameters.$key.GetType().Name -like '*cimInstance*')
312-
{
313-
$UpdateParameters.$key = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $UpdateParameters.$key
314-
}
315-
}
316298
#region resource generator code
317299
$uri = "/beta/deviceManagement/windowsDriverUpdateProfiles/$($currentInstance.Id)"
318300
Invoke-MgGraphRequest -Method PATCH -Uri $uri -Body $($UpdateParameters | ConvertTo-Json)

Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWindowsUpdateForBusinessHotpatchProfileWindows10/MSFT_IntuneWindowsUpdateForBusinessHotpatchProfileWindows10.psm1

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,6 @@ function Set-TargetResource
259259
$createParameters = Rename-M365DSCCimInstanceParameter -Properties $createParameters
260260
$createParameters.Remove('Id') | Out-Null
261261

262-
$keys = (([Hashtable]$createParameters).Clone()).Keys
263-
foreach ($key in $keys)
264-
{
265-
if ($null -ne $createParameters.$key -and $createParameters.$key.GetType().Name -like '*CimInstance*')
266-
{
267-
$createParameters.$key = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $createParameters.$key
268-
}
269-
}
270262
#region resource generator code
271263
$policy = Invoke-MgGraphRequest -Method POST -Uri $Script:BaseUrl `
272264
-Body $($createParameters | ConvertTo-Json -Depth 10)
@@ -287,18 +279,8 @@ function Set-TargetResource
287279

288280
$updateParameters = ([Hashtable]$boundParameters).Clone()
289281
$updateParameters = Rename-M365DSCCimInstanceParameter -Properties $updateParameters
290-
291282
$updateParameters.Remove('Id') | Out-Null
292283

293-
$keys = (([Hashtable]$updateParameters).Clone()).Keys
294-
foreach ($key in $keys)
295-
{
296-
if ($null -ne $updateParameters.$key -and $updateParameters.$key.GetType().Name -like '*CimInstance*')
297-
{
298-
$updateParameters.$key = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $updateParameters.$key
299-
}
300-
}
301-
302284
#region resource generator code
303285
Invoke-MgGraphRequest -Method PATCH -Uri "$($Script:BaseUrl)/$($currentInstance.Id)" `
304286
-Body $($updateParameters | ConvertTo-Json -Depth 10)

Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function Get-StringFirstCharacterToLower
2727
function Rename-M365DSCCimInstanceParameter
2828
{
2929
[CmdletBinding()]
30-
[OutputType([System.Collections.Hashtable], [System.Collections.Hashtable[]])]
30+
[OutputType([System.Collections.Hashtable], [System.Object[]])]
3131
param(
3232
[Parameter(Mandatory = $true)]
3333
$Properties,
@@ -45,18 +45,26 @@ function Rename-M365DSCCimInstanceParameter
4545
$values = @()
4646
foreach ($item in $Properties)
4747
{
48-
try
48+
$itemType = $item.GetType().FullName
49+
if ($itemType -like '*Hashtable*' -or $itemType -like '*CimInstance*' -or $itemType -like '*Object*')
4950
{
50-
$values += Rename-M365DSCCimInstanceParameter -Properties $item -KeyMapping $KeyMapping
51+
try
52+
{
53+
$values += Rename-M365DSCCimInstanceParameter -Properties $item -KeyMapping $KeyMapping
54+
}
55+
catch
56+
{
57+
Write-Verbose -Message "Error getting values for item {$item}"
58+
}
5159
}
52-
catch
60+
else
5361
{
54-
Write-Verbose -Message "Error getting values for item {$item}"
62+
$values += $item
5563
}
5664
}
5765
$result = $values
5866

59-
return ,[System.Collections.Hashtable[]]$result
67+
return ,$result
6068
}
6169
#endregion
6270

@@ -69,11 +77,11 @@ function Rename-M365DSCCimInstanceParameter
6977
if ($type -like '*CimInstance*' -or $type -like '*Hashtable*' -or $type -like '*Object*')
7078
{
7179
$hashProperties = Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $result
72-
$keys = ($hashProperties.Clone()).keys
80+
$keys = ($hashProperties.Clone()).Keys
7381

7482
foreach ($key in $keys)
7583
{
76-
$keyName = $key.Substring(0, 1).Tolower() + $key.Substring(1, $key.Length - 1)
84+
$keyName = $key.Substring(0, 1).ToLower() + $key.Substring(1, $key.Length - 1)
7785
if ($key -in $KeyMapping.Keys)
7886
{
7987
$keyName = $KeyMapping.$key

Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,28 @@ function Start-M365DSCConfigurationExtract
661661
}
662662
}
663663

664+
# If the tenant id is not a GUID, retrieve it based on the organization name
665+
# Only implemented for public cloud tenants
666+
if (-not ($TenantId -match ('^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$')))
667+
{
668+
try
669+
{
670+
Write-Verbose -Message "Retrieving Tenant Id based on provided organization name."
671+
$tenantGuid = (Invoke-RestMethod -Uri "https://login.microsoftonline.com/$organization/.well-known/openid-configuration" -Method Get).authorization_endpoint.Split('/')[3]
672+
$currentStringReplacementMap = Get-M365DSCStringReplacementMap
673+
if (-not $currentStringReplacementMap.ContainsKey($tenantGuid))
674+
{
675+
$currentStringReplacementMap.Add($tenantGuid, 'TenantGuid')
676+
Set-M365DSCStringReplacementMap -Map $currentStringReplacementMap
677+
}
678+
}
679+
catch
680+
{
681+
Write-Warning -Message "Failed to resolve current tenant id from organization name '$organization'. Not replacing tenant id in exported configuration.
682+
If you want to have your tenant id replaced in the export, use the -TokenReplacement parameter of Export-M365DSCConfiguration."
683+
}
684+
}
685+
664686
Confirm-M365DSCDependencies
665687
$partialExportName = $Global:PartialExportFileName
666688
$resourcesPath = $resourcesPath | Sort-Object $_.Name

0 commit comments

Comments
 (0)