From 7ea51947a49415189e7a7ef14676876f1f4d94c2 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Mon, 16 Dec 2024 15:33:15 +0100 Subject: [PATCH 1/6] Fixing #5559 --- .../MSFT_AADAdministrativeUnit.psm1 | 3 +- .../Modules/M365DSCDRGUtil.psm1 | 446 ++++++++++++------ .../Microsoft365DSC/Modules/M365DSCUtil.psm1 | 2 +- 3 files changed, 294 insertions(+), 157 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 index 104f0d3693..6287779158 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 @@ -1149,9 +1149,8 @@ function Export-TargetResource $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Members' -IsCIMArray $true $currentDSCBlock = $currentDSCBlock.Replace("`",`"`r`n", '') $currentDSCBlock = $currentDSCBlock.Replace(",`r`n", '').Replace("`");`r`n", ");`r`n") - $currentDSCBlock = $currentDSCBlock.Replace("Members = @(`"", 'Members = @(') - $currentDSCBlock = $currentDSCBlock.Replace("`$OrganizationName'", "' + `$OrganizationName") } + $dscContent += $currentDSCBlock Save-M365DSCPartialExport -Content $currentDSCBlock ` -FileName $Global:PartialExportFileName diff --git a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 index 9ed3c0922c..5ac589401a 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 @@ -8,7 +8,7 @@ function Get-StringFirstCharacterToUpper $Value ) - return $Value.Substring(0,1).ToUpper() + $Value.Substring(1,$Value.length-1) + return $Value.Substring(0, 1).ToUpper() + $Value.Substring(1, $Value.length - 1) } function Get-StringFirstCharacterToLower @@ -21,7 +21,7 @@ function Get-StringFirstCharacterToLower $Value ) - return $Value.Substring(0,1).ToLower() + $Value.Substring(1,$Value.length-1) + return $Value.Substring(0, 1).ToLower() + $Value.Substring(1, $Value.length - 1) } function Remove-M365DSCCimInstanceTrailingCharacterFromExport @@ -50,7 +50,7 @@ function Rename-M365DSCCimInstanceParameter [Parameter(Mandatory = $false)] [System.Collections.Hashtable] - $KeyMapping = @{'odataType' = '@odata.type'} + $KeyMapping = @{'odataType' = '@odata.type' } ) $result = $Properties @@ -429,7 +429,7 @@ function Get-M365DSCDRGComplexTypeToString $currentValue = $ComplexObject[$key] if ($currentValue.GetType().Name -eq 'String') { - $currentValue = $ComplexObject[$key].Replace("'", "''").Replace("�", "''") + $currentValue = $ComplexObject[$key].Replace("'", "''").Replace('�', "''") } $currentProperty += Get-M365DSCDRGSimpleObjectTypeToString -Key $key -Value $currentValue -Space ($indent) } @@ -452,7 +452,7 @@ function Get-M365DSCDRGComplexTypeToString } } $indent = '' - $indent = ' ' * ($IndentLevel -1) + $indent = ' ' * ($IndentLevel - 1) if ($key -in $ComplexTypeMapping.Name) { $currentProperty += "`r`n" @@ -467,7 +467,7 @@ function Get-M365DSCDRGComplexTypeToString #Indenting last parenthesis when the cim instance is an array if ($IndentLevel -eq 5) { - $indent = ' ' * ($IndentLevel -2) + $indent = ' ' * ($IndentLevel - 2) $currentProperty += $indent } @@ -479,8 +479,8 @@ function Get-M365DSCDRGComplexTypeToString if ($null -ne $currentProperty) { - $fancySingleQuotes = "[\u2019\u2018]" - $fancyDoubleQuotes = "[\u201C\u201D]" + $fancySingleQuotes = '[\u2019\u2018]' + $fancyDoubleQuotes = '[\u201C\u201D]' $currentProperty = [regex]::Replace($currentProperty, $fancySingleQuotes, "''") $currentProperty = [regex]::Replace($currentProperty, $fancyDoubleQuotes, '"') } @@ -517,11 +517,11 @@ function Get-M365DSCDRGSimpleObjectTypeToString { $key = 'odataType' } - $returnValue = $Space + $Key + " = '" + $Value + "'`r`n" + $returnValue = $Space + $Key + ' = "' + $Value + """`r`n" } '*.DateTime' { - $returnValue = $Space + $Key + " = '" + $Value + "'`r`n" + $returnValue = $Space + $Key + ' = "' + $Value + """`r`n" } '*[[\]]' { @@ -540,11 +540,11 @@ function Get-M365DSCDRGSimpleObjectTypeToString { '*.String' { - $returnValue += "$whitespace'$item'$newline" + $returnValue += "$whitespace""$item""$newline" } '*.DateTime' { - $returnValue += "$whitespace'$item'$newline" + $returnValue += "$whitespace""$item""$newline" } Default { @@ -574,9 +574,11 @@ function Compare-M365DSCComplexObject { [CmdletBinding()] [OutputType([System.Boolean])] - param( + param + ( [Parameter()] $Source, + [Parameter()] $Target ) @@ -660,12 +662,12 @@ function Compare-M365DSCComplexObject return $true } - if ($Source.GetType().FullName -like "*CimInstance") + if ($Source.GetType().FullName -like '*CimInstance') { $keys = @() - $Source.CimInstanceProperties | Foreach-Object { + $Source.CimInstanceProperties | ForEach-Object { if ($_.Name -notin @('PSComputerName', 'CimClass', 'CimInstanceProperties', 'CimSystemProperties') ` - -and $_.IsValueModified) + -and $_.IsValueModified) { $keys += $_.Name } @@ -676,18 +678,18 @@ function Compare-M365DSCComplexObject $keys = $Source.Keys | Where-Object -FilterScript { $_ -ne 'PSComputerName' } } - if ($Target.GetType().FullName -like "*CimInstance") + if ($Target.GetType().FullName -like '*CimInstance') { $targetKeys = @() - $Target.CimInstanceProperties | Foreach-Object { + $Target.CimInstanceProperties | ForEach-Object { if ($_.Name -notin @('PSComputerName', 'CimClass', 'CimInstanceProperties', 'CimSystemProperties') ` - -and $_.IsValueModified) + -and $_.IsValueModified) { $targetKeys += $_.Name } } } - elseif ($Target.GetType().FullName -like "*Hashtable") + elseif ($Target.GetType().FullName -like '*Hashtable') { $targetKeys = $Target.Keys | Where-Object -FilterScript { $_ -ne 'PSComputerName' } } @@ -824,7 +826,8 @@ function Convert-M365DSCDRGComplexTypeToHashtable { [CmdletBinding()] [OutputType([hashtable], [hashtable[]])] - param( + param + ( [Parameter(Mandatory = $true)] [AllowNull()] $ComplexObject, @@ -910,10 +913,12 @@ function ConvertFrom-IntunePolicyAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [Array] $Assignments, + [Parameter()] [System.Boolean] $IncludeDeviceFilter = $true @@ -950,7 +955,7 @@ function ConvertFrom-IntunePolicyAssignment $collectionId = $assignment.Target.AdditionalProperties.collectionId } - $hashAssignment.Add('dataType',$dataType) + $hashAssignment.Add('dataType', $dataType) if (-not [string]::IsNullOrEmpty($groupId)) { $hashAssignment.Add('groupId', $groupId) @@ -992,14 +997,15 @@ function ConvertFrom-IntunePolicyAssignment $assignmentResult += $hashAssignment } - return ,$assignmentResult + return , $assignmentResult } function ConvertTo-IntunePolicyAssignment { [CmdletBinding()] [OutputType([Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [AllowNull()] $Assignments, @@ -1011,13 +1017,13 @@ function ConvertTo-IntunePolicyAssignment if ($null -eq $Assignments) { - return ,@() + return , @() } $assignmentResult = @() foreach ($assignment in $Assignments) { - $target = @{"@odata.type" = $assignment.dataType} + $target = @{'@odata.type' = $assignment.dataType } if ($IncludeDeviceFilter) { if ($null -ne $assignment.DeviceAndAppManagementAssignmentFilterType) @@ -1045,14 +1051,14 @@ function ConvertTo-IntunePolicyAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.Count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1061,7 +1067,7 @@ function ConvertTo-IntunePolicyAssignment else { $message = "Skipping assignment for the group with Id {$($assignment.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } @@ -1075,21 +1081,23 @@ function ConvertTo-IntunePolicyAssignment if ($target) { - $assignmentResult += @{target = $target} + $assignmentResult += @{target = $target } } } - return ,$assignmentResult + return , $assignmentResult } function ConvertFrom-IntuneMobileAppAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [Array] $Assignments, + [Parameter()] [System.Boolean] $IncludeDeviceFilter = $true @@ -1169,14 +1177,15 @@ function ConvertFrom-IntuneMobileAppAssignment $assignmentResult += $hashAssignment } - return ,$assignmentResult + return , $assignmentResult } function ConvertTo-IntuneMobileAppAssignment { [CmdletBinding()] [OutputType([Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [AllowNull()] $Assignments, @@ -1188,14 +1197,14 @@ function ConvertTo-IntuneMobileAppAssignment if ($null -eq $Assignments) { - return ,@() + return , @() } $assignmentResult = @() foreach ($assignment in $Assignments) { $formattedAssignment = @{} - $target = @{"@odata.type" = $assignment.dataType} + $target = @{'@odata.type' = $assignment.dataType } if ($IncludeDeviceFilter) { if ($null -ne $assignment.DeviceAndAppManagementAssignmentFilterType) @@ -1218,14 +1227,14 @@ function ConvertTo-IntuneMobileAppAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.Count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1234,12 +1243,13 @@ function ConvertTo-IntuneMobileAppAssignment else { $message = "Skipping assignment for the group with Id {$($assignment.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } } - else { + else + { #Skipping assignment if group not found from either groupId or groupDisplayName $target.Add('groupId', $group.Id) } @@ -1252,18 +1262,22 @@ function ConvertTo-IntuneMobileAppAssignment $assignmentResult += $formattedAssignment } - return ,$assignmentResult + return , $assignmentResult } function Compare-M365DSCIntunePolicyAssignment { [CmdletBinding()] [OutputType([System.Boolean])] - param ( + param + ( [Parameter()] - [array]$Source, + [array] + $Source, + [Parameter()] - [array]$Target + [array] + $Target ) $testResult = $Source.Count -eq $Target.Count @@ -1282,7 +1296,7 @@ function Compare-M365DSCIntunePolicyAssignment if (-not $testResult) { Write-Verbose 'Group not found by groupId, checking if group exists by id' - $groupNotFound = $null -eq (Get-MgGroup -GroupId ($assignment.groupId) -ErrorAction SilentlyContinue) + $groupNotFound = $null -eq (Get-MgGroup -GroupId ($assignment.groupId) -ErrorAction SilentlyContinue) } if (-not $testResult -and $groupNotFound) { @@ -1295,9 +1309,9 @@ function Compare-M365DSCIntunePolicyAssignment { Write-Verbose 'Group found by groupId or groupDisplayName, checking filters' $isFilterTypeSpecified = ($null -ne $assignment.deviceAndAppManagementAssignmentFilterType -and $assignment.deviceAndAppManagementAssignmentFilterType -ne 'none') -or ` - ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterType -and $assignmentTarget.deviceAndAppManagementAssignmentFilterType -ne 'none') + ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterType -and $assignmentTarget.deviceAndAppManagementAssignmentFilterType -ne 'none') $isFilterIdSpecified = ($null -ne $assignment.deviceAndAppManagementAssignmentFilterId -and $assignment.deviceAndAppManagementAssignmentFilterId -ne '00000000-0000-0000-0000-000000000000') -or ` - ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterId -and $assignmentTarget.deviceAndAppManagementAssignmentFilterId -ne '00000000-0000-0000-0000-000000000000') + ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterId -and $assignmentTarget.deviceAndAppManagementAssignmentFilterId -ne '00000000-0000-0000-0000-000000000000') if ($isFilterTypeSpecified) { Write-Verbose 'FilterType specified, checking filterType' @@ -1320,7 +1334,10 @@ function Compare-M365DSCIntunePolicyAssignment { $testResult = $null -ne ($Target | Where-Object -FilterScript { $_.dataType -eq $assignment.DataType }) } - if (-not $testResult) { break } + if (-not $testResult) + { + break + } } } @@ -1331,7 +1348,8 @@ function Update-DeviceConfigurationPolicyAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param ( + param + ( [Parameter(Mandatory = $true)] [System.String] $DeviceConfigurationPolicyId, @@ -1345,7 +1363,7 @@ function Update-DeviceConfigurationPolicyAssignment $Repository = 'deviceManagement/configurationPolicies', [Parameter()] - [ValidateSet('v1.0','beta')] + [ValidateSet('v1.0', 'beta')] [System.String] $APIVersion = 'beta', @@ -1366,10 +1384,10 @@ function Update-DeviceConfigurationPolicyAssignment $target = $target.target } - $formattedTarget = @{"@odata.type" = $target.dataType} - if(-not $formattedTarget."@odata.type" -and $target."@odata.type") + $formattedTarget = @{'@odata.type' = $target.dataType } + if (-not $formattedTarget.'@odata.type' -and $target.'@odata.type') { - $formattedTarget."@odata.type" = $target."@odata.type" + $formattedTarget.'@odata.type' = $target.'@odata.type' } if ($target.groupId) { @@ -1382,14 +1400,14 @@ function Update-DeviceConfigurationPolicyAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1398,7 +1416,7 @@ function Update-DeviceConfigurationPolicyAssignment else { $message = "Skipping assignment for the group with Id {$($target.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } @@ -1406,25 +1424,25 @@ function Update-DeviceConfigurationPolicyAssignment #Skipping assignment if group not found from either groupId or groupDisplayName if ($null -ne $group) { - $formattedTarget.Add('groupId',$group.Id) + $formattedTarget.Add('groupId', $group.Id) } } if ($target.collectionId) { - $formattedTarget.Add('collectionId',$target.collectionId) + $formattedTarget.Add('collectionId', $target.collectionId) } if ($target.deviceAndAppManagementAssignmentFilterType) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType',$target.deviceAndAppManagementAssignmentFilterType) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType', $target.deviceAndAppManagementAssignmentFilterType) } if ($target.deviceAndAppManagementAssignmentFilterId) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId',$target.deviceAndAppManagementAssignmentFilterId) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId', $target.deviceAndAppManagementAssignmentFilterId) } - $deviceManagementPolicyAssignments += @{'target' = $formattedTarget} + $deviceManagementPolicyAssignments += @{'target' = $formattedTarget } } - $body = @{$RootIdentifier = $deviceManagementPolicyAssignments} | ConvertTo-Json -Depth 20 + $body = @{$RootIdentifier = $deviceManagementPolicyAssignments } | ConvertTo-Json -Depth 20 Write-Verbose -Message $body Invoke-MgGraphRequest -Method POST -Uri $Uri -Body $body -ErrorAction Stop @@ -1445,7 +1463,8 @@ function Update-DeviceAppManagementPolicyAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param ( + param + ( [Parameter(Mandatory = $true)] [System.String] $AppManagementPolicyId, @@ -1459,7 +1478,7 @@ function Update-DeviceAppManagementPolicyAssignment $Repository = 'deviceAppManagement/mobileApps', [Parameter()] - [ValidateSet('v1.0','beta')] + [ValidateSet('v1.0', 'beta')] [System.String] $APIVersion = 'beta', @@ -1477,7 +1496,7 @@ function Update-DeviceAppManagementPolicyAssignment { $formattedAssignment = @{ '@odata.type' = '#microsoft.graph.mobileAppAssignment' - intent = $assignment.intent + intent = $assignment.intent } if ($assigment.settings) { @@ -1489,10 +1508,10 @@ function Update-DeviceAppManagementPolicyAssignment $target = $assignment.target } - $formattedTarget = @{"@odata.type" = $target.dataType} - if(-not $formattedTarget."@odata.type" -and $target."@odata.type") + $formattedTarget = @{'@odata.type' = $target.dataType } + if (-not $formattedTarget.'@odata.type' -and $target.'@odata.type') { - $formattedTarget."@odata.type" = $target."@odata.type" + $formattedTarget.'@odata.type' = $target.'@odata.type' } if ($target.groupId) { @@ -1505,14 +1524,14 @@ function Update-DeviceAppManagementPolicyAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1521,7 +1540,7 @@ function Update-DeviceAppManagementPolicyAssignment else { $message = "Skipping assignment for the group with Id {$($target.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } @@ -1529,22 +1548,22 @@ function Update-DeviceAppManagementPolicyAssignment #Skipping assignment if group not found from either groupId or groupDisplayName if ($null -ne $group) { - $formattedTarget.Add('groupId',$group.Id) + $formattedTarget.Add('groupId', $group.Id) } } if ($target.deviceAndAppManagementAssignmentFilterType) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType',$target.deviceAndAppManagementAssignmentFilterType) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType', $target.deviceAndAppManagementAssignmentFilterType) } if ($target.deviceAndAppManagementAssignmentFilterId) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId',$target.deviceAndAppManagementAssignmentFilterId) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId', $target.deviceAndAppManagementAssignmentFilterId) } $formattedAssignment.Add('target', $formattedTarget) $appManagementPolicyAssignments += $formattedAssignment } - $body = @{$RootIdentifier = $appManagementPolicyAssignments} | ConvertTo-Json -Depth 20 + $body = @{$RootIdentifier = $appManagementPolicyAssignments } | ConvertTo-Json -Depth 20 Write-Verbose -Message $body Invoke-MgGraphRequest -Method POST -Uri $Uri -Body $body -ErrorAction Stop @@ -1565,7 +1584,8 @@ function Get-OmaSettingPlainTextValue { [CmdletBinding()] [OutputType([System.String])] - Param( + param + ( [Parameter(Mandatory = $true)] [System.String] $SecretReferenceValueId, @@ -1582,7 +1602,7 @@ function Get-OmaSettingPlainTextValue e.g. PolicyId for SecretReferenceValueId '35ea58ec-2a79-471d-8eea-7e28e6cd2722_bdf6c690-05fb-4d02-835d-5a7406c35d58_abe32712-2255-445f-a35e-0c6f143d82ca' is 'bdf6c690-05fb-4d02-835d-5a7406c35d58' #> - $SplitSecretReferenceValueId = $SecretReferenceValueId.Split("_") + $SplitSecretReferenceValueId = $SecretReferenceValueId.Split('_') if ($SplitSecretReferenceValueId.Count -eq 3) { $PolicyId = $SplitSecretReferenceValueId[1] @@ -1606,7 +1626,7 @@ function Get-OmaSettingPlainTextValue } catch { - $Message = "Error decrypting OmaSetting with SecretReferenceValueId {0}:" -f $SecretReferenceValueId + $Message = 'Error decrypting OmaSetting with SecretReferenceValueId {0}:' -f $SecretReferenceValueId New-M365DSCLogEntry -Message $Message ` -Exception $_ ` -Source $($MyInvocation.MyCommand.Source) ` @@ -1619,7 +1639,9 @@ function Get-OmaSettingPlainTextValue if (![String]::IsNullOrEmpty($Result.Value)) { return $Result.Value - } else { + } + else + { return $null } } @@ -1628,7 +1650,8 @@ function Get-IntuneSettingCatalogPolicySetting { [CmdletBinding()] [OutputType([System.Array])] - param ( + param + ( [Parameter(Mandatory = $true)] [System.Collections.Hashtable] $DSCParams, @@ -1672,11 +1695,11 @@ function Get-IntuneSettingCatalogPolicySetting if ($ContainsDeviceAndUserSettings) { - $deviceSettingTemplates = $SettingTemplates | Where-object -FilterScript { - $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith("device_") + $deviceSettingTemplates = $SettingTemplates | Where-Object -FilterScript { + $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith('device_') } - $userSettingTemplates = $SettingTemplates | Where-object -FilterScript { - $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith("user_") + $userSettingTemplates = $SettingTemplates | Where-Object -FilterScript { + $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith('user_') } $deviceDscParams = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $DSCParams.DeviceSettings -SingleLevel -ExcludeUnchangedProperties $userDscParams = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $DSCParams.UserSettings -SingleLevel -ExcludeUnchangedProperties @@ -1684,7 +1707,7 @@ function Get-IntuneSettingCatalogPolicySetting $combinedSettingInstances += Get-IntuneSettingCatalogPolicySetting -DSCParams $deviceDscParams -SettingTemplates $deviceSettingTemplates $combinedSettingInstances += Get-IntuneSettingCatalogPolicySetting -DSCParams $userDscParams -SettingTemplates $userSettingTemplates - return ,$combinedSettingInstances + return , $combinedSettingInstances } } @@ -1760,14 +1783,15 @@ function Get-IntuneSettingCatalogPolicySetting } } - return ,$settingInstances + return , $settingInstances } function Get-IntuneSettingCatalogPolicySettingInstanceValue { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param( + param + ( [Parameter(Mandatory = 'true')] [System.Collections.Hashtable] $DSCParams, @@ -1829,12 +1853,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $instanceCount = 1 if (($Level -gt 1 -and $groupSettingCollectionDefinitionChildren.Count -gt 1) -or - ($Level -eq 1 -and $SettingDefinition.AdditionalProperties.maximumCount -gt 1 -and $groupSettingCollectionDefinitionChildren.Count -ge 1 -and $groupSettingCollectionDefinitionChildren.AdditionalProperties.'@odata.type' -notcontains "#microsoft.graph.deviceManagementConfigurationSettingGroupCollectionDefinition")) + ($Level -eq 1 -and $SettingDefinition.AdditionalProperties.maximumCount -gt 1 -and $groupSettingCollectionDefinitionChildren.Count -ge 1 -and $groupSettingCollectionDefinitionChildren.AdditionalProperties.'@odata.type' -notcontains '#microsoft.graph.deviceManagementConfigurationSettingGroupCollectionDefinition')) { $SettingInstanceName += Get-SettingsCatalogSettingName -SettingDefinition $SettingDefinition -AllSettingDefinitions $AllSettingDefinitions - $settingInstanceNameAlternate = $SettingInstanceName + "_Intune" + $settingInstanceNameAlternate = $SettingInstanceName + '_Intune' $cimDSCParams = @() - $cimDSCParamsName = "" + $cimDSCParamsName = '' $DSCParams.GetEnumerator() | ForEach-Object { if ($_.Value.CimClass.CimClassName -eq $SettingInstanceName -or $_.Value.CimClass.CimClassName -like "$settingInstanceNameAlternate*") { @@ -1845,10 +1869,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $newDSCParams = @{ $cimDSCParamsName = @() } - foreach ($instance in $cimDSCParams) { + foreach ($instance in $cimDSCParams) + { $newInstanceDSCParams = @{} # Preserve CIM instances when converting to hashtable - foreach ($property in $instance.CimInstanceProperties) { + foreach ($property in $instance.CimInstanceProperties) + { if ($property.IsValueModified) { $newInstanceDSCParams.Add($property.Name, $property.Value) @@ -1858,7 +1884,14 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } $instanceCount = $newDSCParams.$cimDSCParamsName.Count $DSCParams = @{ - $cimDSCParamsName = if ($instanceCount -eq 1) { $newDSCParams.$cimDSCParamsName[0] } else { $newDSCParams.$cimDSCParamsName } + $cimDSCParamsName = if ($instanceCount -eq 1) + { + $newDSCParams.$cimDSCParamsName[0] + } + else + { + $newDSCParams.$cimDSCParamsName + } } $AllSettingDefinitions = $groupSettingCollectionDefinitionChildren + $SettingDefinition } @@ -1866,16 +1899,25 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue for ($i = 0; $i -lt $instanceCount; $i++) { $groupSettingCollectionValueChildren = @() - $currentDSCParams = if ($instanceCount -eq 1) { - if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) { + $currentDSCParams = if ($instanceCount -eq 1) + { + if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) + { $DSCParams.$cimDSCParamsName - } else { + } + else + { $DSCParams } - } else { - if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) { + } + else + { + if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) + { $DSCParams.$cimDSCParamsName[$i] - } else { + } + else + { $DSCParams[$i] } } @@ -1891,9 +1933,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $childSettingValueName = $childSettingType.Replace('#microsoft.graph.deviceManagementConfiguration', '').Replace('Instance', 'Value') $childSettingValueType = "#microsoft.graph.deviceManagementConfiguration$($childSettingValueName)" $childSettingValueName = $childSettingValueName.Substring(0, 1).ToLower() + $childSettingValueName.Substring(1, $childSettingValueName.length - 1 ) - $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) { + $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) + { $SettingInstanceTemplate.AdditionalProperties.groupSettingCollectionValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } | Select-Object -First 1 - } else { + } + else + { $SettingInstanceTemplate.groupSettingCollectionValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } | Select-Object -First 1 } @@ -1929,13 +1974,13 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } $childSettingValueItem.Add('@odata.type', $childSettingType) $childSettingValueInner.children += @{ - '@odata.type' = '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance' + '@odata.type' = '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance' groupSettingCollectionValue = @( @{ children = $childSettingValueItem.children } ) - settingDefinitionId = $childDefinition.Id + settingDefinitionId = $childDefinition.Id } <# GroupSettingCollection do not have a setting instance template reference if (-not [string]::IsNullOrEmpty($childSettingInstanceTemplate.settingInstanceTemplateId)) @@ -1976,7 +2021,8 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } } - if ($groupSettingCollectionDefinitionChildren.Count -gt 0 -and $groupSettingCollectionValue.Count -gt 0) { + if ($groupSettingCollectionDefinitionChildren.Count -gt 0 -and $groupSettingCollectionValue.Count -gt 0) + { $settingValuesToReturn.Add('groupSettingCollectionValue', @($groupSettingCollectionValue)) } } @@ -2002,9 +2048,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $childSettingValueName = $childSettingType.Replace('#microsoft.graph.deviceManagementConfiguration', '').Replace('Instance', 'Value') $childSettingValueType = "#microsoft.graph.deviceManagementConfiguration$($childSettingValueName)" $childSettingValueName = $childSettingValueName.Substring(0, 1).ToLower() + $childSettingValueName.Substring(1, $childSettingValueName.Length - 1 ) - $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) { + $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) + { $SettingInstanceTemplate.AdditionalProperties.choiceSettingValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } - } else { + } + else + { $SettingInstanceTemplate.choiceSettingValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } } $childSettingValueTemplateId = $childSettingInstanceTemplate."$($childSettingValueName)Template" | Where-Object { @@ -2038,9 +2087,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } # Depending on the children count, we add the children to the choice setting or an empty array since the children property is required - if ($choiceSettingDefinitionChildren.Count -gt 0) { + if ($choiceSettingDefinitionChildren.Count -gt 0) + { $choiceSettingValue.Add('children', $choiceSettingValueChildren) - } else { + } + else + { $choiceSettingValue.Add('children', @()) } @@ -2089,8 +2141,8 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue foreach ($value in $values) { $choiceSettingValueCollection += @{ - value = $value - children = @() + value = $value + children = @() '@odata.type' = '#microsoft.graph.deviceManagementConfigurationChoiceSettingValue' } } @@ -2123,7 +2175,8 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue '@odata.type' = $SettingValueType } } - if ($settingValueCollection.Count -gt 0) { + if ($settingValueCollection.Count -gt 0) + { $settingValuesToReturn.Add($SettingValueName, $settingValueCollection) } } @@ -2150,7 +2203,7 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue { if ($SettingDefinition.AdditionalProperties.valueDefinition.isSecret) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationSecretSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationSecretSettingValue' $settingValue.Add('valueState', 'NotEncrypted') } $settingValue.Add('@odata.type', $SettingValueType) @@ -2174,7 +2227,7 @@ function Get-IntuneSettingCatalogPolicySettingDSCValue ( [Parameter()] [System.String] - $SettingValueType = "", + $SettingValueType = '', [Parameter()] $SettingDefinition, @@ -2196,37 +2249,44 @@ function Get-IntuneSettingCatalogPolicySettingDSCValue } $isArray = $false - if ($SettingValueType -like "*Simple*") + if ($SettingValueType -like '*Simple*') { if ($DSCParams[$key] -is [System.String]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationStringSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationStringSettingValue' } elseif ($DSCParams[$key] -is [System.Int32]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationIntegerSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue' } elseif ($DSCParams[$key] -is [System.String[]]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationStringSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationStringSettingValue' $isArray = $true } elseif ($DSCParams[$key] -is [System.Int32[]]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationIntegerSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue' $isArray = $true } } - if ($SettingValueType -like "*Simple*" -or $SettingValueType -in @("#microsoft.graph.deviceManagementConfigurationIntegerSettingValue", "#microsoft.graph.deviceManagementConfigurationStringSettingValue")) + if ($SettingValueType -like '*Simple*' -or $SettingValueType -in @('#microsoft.graph.deviceManagementConfigurationIntegerSettingValue', '#microsoft.graph.deviceManagementConfigurationStringSettingValue')) { return @{ SettingDefinition = $SettingDefinition - SettingValueType = $SettingValueType - Value = if ($isArray) { ,$DSCParams[$key] } else { $DSCParams[$key] } + SettingValueType = $SettingValueType + Value = if ($isArray) + { + , $DSCParams[$key] + } + else + { + $DSCParams[$key] + } } } - elseif ($SettingValueType -like "*ChoiceSettingCollection*") + elseif ($SettingValueType -like '*ChoiceSettingCollection*') { $values = @() foreach ($value in $DSCParams[$key]) @@ -2242,8 +2302,8 @@ function Get-IntuneSettingCatalogPolicySettingDSCValue { return @{ SettingDefinition = $SettingDefinition - SettingValueType = $SettingValueType - Value = "$($SettingDefinition.Id)_$($DSCParams[$key])" + SettingValueType = $SettingValueType + Value = "$($SettingDefinition.Id)_$($DSCParams[$key])" } } } @@ -2252,7 +2312,8 @@ function Export-IntuneSettingCatalogPolicySettings { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param( + param + ( [Parameter( Mandatory = $true, ParameterSetName = 'Start' @@ -2303,7 +2364,7 @@ function Export-IntuneSettingCatalogPolicySettings { $deviceSettingsReturnHashtable = @{} $deviceSettings = $Settings | Where-Object -FilterScript { - $_.SettingInstance.settingDefinitionId.StartsWith("device_") + $_.SettingInstance.settingDefinitionId.StartsWith('device_') } if ($AllSettingDefinitions.Count -eq 0) { @@ -2312,7 +2373,7 @@ function Export-IntuneSettingCatalogPolicySettings else { $allDeviceSettingDefinitions = $AllSettingDefinitions | Where-Object -FilterScript { - $_.Id.StartsWith("device_") + $_.Id.StartsWith('device_') } } foreach ($setting in $deviceSettings) @@ -2322,7 +2383,7 @@ function Export-IntuneSettingCatalogPolicySettings $userSettingsReturnHashtable = @{} $userSettings = $Settings | Where-Object -FilterScript { - $_.SettingInstance.settingDefinitionId.StartsWith("user_") + $_.SettingInstance.settingDefinitionId.StartsWith('user_') } if ($AllSettingDefinitions.Count -eq 0) { @@ -2331,7 +2392,7 @@ function Export-IntuneSettingCatalogPolicySettings else { $allUserSettingDefinitions = $AllSettingDefinitions | Where-Object -FilterScript { - $_.Id.StartsWith("user_") + $_.Id.StartsWith('user_') } } @@ -2366,12 +2427,26 @@ function Export-IntuneSettingCatalogPolicySettings $addToParameters = $true $settingDefinition = $SettingDefinitions | Where-Object -FilterScript { $_.Id -eq $SettingInstance.settingDefinitionId } $settingName = Get-SettingsCatalogSettingName -SettingDefinition $settingDefinition -AllSettingDefinitions $AllSettingDefinitions - $odataType = if ($IsRoot) { $SettingInstance.AdditionalProperties.'@odata.type' } else { $SettingInstance.'@odata.type' } + $odataType = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.'@odata.type' + } + else + { + $SettingInstance.'@odata.type' + } switch ($odataType) { '#microsoft.graph.deviceManagementConfigurationSimpleSettingInstance' { - $simpleSetting = if ($IsRoot) { $SettingInstance.AdditionalProperties.simpleSettingValue } else { $SettingInstance.simpleSettingValue } + $simpleSetting = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.simpleSettingValue + } + else + { + $SettingInstance.simpleSettingValue + } if ($simpleSetting.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue') { $settingValue = [int]$simpleSetting.value @@ -2383,9 +2458,23 @@ function Export-IntuneSettingCatalogPolicySettings } '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance' { - $settingValue = if ($IsRoot) { $SettingInstance.AdditionalProperties.choiceSettingValue.value } else { $SettingInstance.choiceSettingValue.value } + $settingValue = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.choiceSettingValue.value + } + else + { + $SettingInstance.choiceSettingValue.value + } $settingValue = $settingValue.Split('_') | Select-Object -Last 1 - $childSettings = if ($IsRoot) { $SettingInstance.AdditionalProperties.choiceSettingValue.children } else { $SettingInstance.choiceSettingValue.children } + $childSettings = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.choiceSettingValue.children + } + else + { + $SettingInstance.choiceSettingValue.children + } foreach ($childSetting in $childSettings) { Export-IntuneSettingCatalogPolicySettings -SettingInstance $childSetting -SettingDefinitions $SettingDefinitions -ReturnHashtable $ReturnHashtable -AllSettingDefinitions $AllSettingDefinitions @@ -2394,7 +2483,14 @@ function Export-IntuneSettingCatalogPolicySettings '#microsoft.graph.deviceManagementConfigurationChoiceSettingCollectionInstance' { $values = @() - $childValues = if ($IsRoot) { $SettingInstance.AdditionalProperties.choiceSettingCollectionValue.value } else { $SettingInstance.choiceSettingCollectionValue.value } + $childValues = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.choiceSettingCollectionValue.value + } + else + { + $SettingInstance.choiceSettingCollectionValue.value + } foreach ($value in $childValues) { $values += $value.Split('_') | Select-Object -Last 1 @@ -2403,7 +2499,14 @@ function Export-IntuneSettingCatalogPolicySettings } '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance' { - $groupSettingCollectionValue = if ($IsRoot) { $SettingInstance.AdditionalProperties.groupSettingCollectionValue } else { $SettingInstance.groupSettingCollectionValue } + $groupSettingCollectionValue = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.groupSettingCollectionValue + } + else + { + $SettingInstance.groupSettingCollectionValue + } [array]$childSettingDefinitions = $SettingDefinitions | Where-Object -FilterScript { $settingDefinition.AdditionalProperties.childIds -contains $_.Id } @@ -2453,7 +2556,14 @@ function Export-IntuneSettingCatalogPolicySettings } $childValue += $childHashtable } - $settingValue = if ($null -eq $childValue) { $childHashtable } else { ,$childValue } + $settingValue = if ($null -eq $childValue) + { + $childHashtable + } + else + { + , $childValue + } } else { @@ -2469,7 +2579,14 @@ function Export-IntuneSettingCatalogPolicySettings '#microsoft.graph.deviceManagementConfigurationSimpleSettingCollectionInstance' { $values = @() - $childValues = if ($IsRoot) { $SettingInstance.AdditionalProperties.simpleSettingCollectionValue } else { $SettingInstance.simpleSettingCollectionValue } + $childValues = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.simpleSettingCollectionValue + } + else + { + $SettingInstance.simpleSettingCollectionValue + } foreach ($value in $childValues) { if ($value.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue') @@ -2573,11 +2690,15 @@ function Update-IntuneDeviceConfigurationPolicy } } -function Get-ComplexFunctionsFromFilterQuery { +function Get-ComplexFunctionsFromFilterQuery +{ [CmdletBinding()] [OutputType([System.Array])] - param ( - [string]$FilterQuery + param + ( + [Parameter()] + [System.String] + $FilterQuery ) $complexFunctionsRegex = "startswith\((.*?),\s*'(.*?)'\)|endswith\((.*?),\s*'(.*?)'\)|contains\((.*?),\s*'(.*?)'\)" @@ -2588,38 +2709,55 @@ function Get-ComplexFunctionsFromFilterQuery { return $complexFunctions } -function Remove-ComplexFunctionsFromFilterQuery { +function Remove-ComplexFunctionsFromFilterQuery +{ [CmdletBinding()] [OutputType([System.String])] - param ( - [string]$FilterQuery + param + ( + [Parameter()] + [System.String] + $FilterQuery ) $complexFunctionsRegex = "startswith\((.*?),\s*'(.*?)'\)|endswith\((.*?),\s*'(.*?)'\)|contains\((.*?),\s*'(.*?)'\)" - $basicFilterQuery = [regex]::Replace($FilterQuery, $complexFunctionsRegex, "").Trim() - $basicFilterQuery = $basicFilterQuery -replace "^and\s","" -replace "\sand$","" -replace "\sand\s+", " and " -replace "\sor\s+", " or " + $basicFilterQuery = [regex]::Replace($FilterQuery, $complexFunctionsRegex, '').Trim() + $basicFilterQuery = $basicFilterQuery -replace '^and\s', '' -replace '\sand$', '' -replace '\sand\s+', ' and ' -replace '\sor\s+', ' or ' return $basicFilterQuery } -function Find-GraphDataUsingComplexFunctions { +function Find-GraphDataUsingComplexFunctions +{ [CmdletBinding()] [OutputType([System.Array])] - param ( - [array]$Policies, - [array]$ComplexFunctions + param + ( + [Parameter()] + [array] + $Policies, + + [Parameter()] + [array] + $ComplexFunctions ) - foreach ($function in $ComplexFunctions) { - if ($function -match "startswith\((.*?),\s*'(.*?)'") { + foreach ($function in $ComplexFunctions) + { + if ($function -match "startswith\((.*?),\s*'(.*?)'") + { $property = $matches[1] $value = $matches[2] $Policies = $Policies | Where-Object { $_.$property -like "$value*" } - } elseif ($function -match "endswith\((.*?),\s*'(.*?)'") { + } + elseif ($function -match "endswith\((.*?),\s*'(.*?)'") + { $property = $matches[1] $value = $matches[2] $Policies = $Policies | Where-Object { $_.$property -like "*$value" } - } elseif ($function -match "contains\((.*?),\s*'(.*?)'") { + } + elseif ($function -match "contains\((.*?),\s*'(.*?)'") + { $property = $matches[1] $value = $matches[2] $Policies = $Policies | Where-Object { $_.$property -like "*$value*" } diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index c5e20e3cfb..d39970c9d4 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -3755,7 +3755,7 @@ function Get-M365DSCExportContentForResource if ($ConnectionMode -like 'ServicePrincipal*' -or ` $ConnectionMode -eq 'ManagedIdentity') { - $OrganizationName = $Results.TenantId + $OrganizationName = $TenantId } elseif ($null -ne $Credential.UserName) { From bfe7cd42978577ec69b907d0377cccab0f315c92 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Mon, 16 Dec 2024 15:33:15 +0100 Subject: [PATCH 2/6] Fixing #5559 --- .../MSFT_AADAdministrativeUnit.psm1 | 3 +- .../Modules/M365DSCDRGUtil.psm1 | 446 ++++++++++++------ .../Microsoft365DSC/Modules/M365DSCUtil.psm1 | 2 +- 3 files changed, 294 insertions(+), 157 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 index 104f0d3693..6287779158 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 @@ -1149,9 +1149,8 @@ function Export-TargetResource $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Members' -IsCIMArray $true $currentDSCBlock = $currentDSCBlock.Replace("`",`"`r`n", '') $currentDSCBlock = $currentDSCBlock.Replace(",`r`n", '').Replace("`");`r`n", ");`r`n") - $currentDSCBlock = $currentDSCBlock.Replace("Members = @(`"", 'Members = @(') - $currentDSCBlock = $currentDSCBlock.Replace("`$OrganizationName'", "' + `$OrganizationName") } + $dscContent += $currentDSCBlock Save-M365DSCPartialExport -Content $currentDSCBlock ` -FileName $Global:PartialExportFileName diff --git a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 index 9ed3c0922c..5ac589401a 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 @@ -8,7 +8,7 @@ function Get-StringFirstCharacterToUpper $Value ) - return $Value.Substring(0,1).ToUpper() + $Value.Substring(1,$Value.length-1) + return $Value.Substring(0, 1).ToUpper() + $Value.Substring(1, $Value.length - 1) } function Get-StringFirstCharacterToLower @@ -21,7 +21,7 @@ function Get-StringFirstCharacterToLower $Value ) - return $Value.Substring(0,1).ToLower() + $Value.Substring(1,$Value.length-1) + return $Value.Substring(0, 1).ToLower() + $Value.Substring(1, $Value.length - 1) } function Remove-M365DSCCimInstanceTrailingCharacterFromExport @@ -50,7 +50,7 @@ function Rename-M365DSCCimInstanceParameter [Parameter(Mandatory = $false)] [System.Collections.Hashtable] - $KeyMapping = @{'odataType' = '@odata.type'} + $KeyMapping = @{'odataType' = '@odata.type' } ) $result = $Properties @@ -429,7 +429,7 @@ function Get-M365DSCDRGComplexTypeToString $currentValue = $ComplexObject[$key] if ($currentValue.GetType().Name -eq 'String') { - $currentValue = $ComplexObject[$key].Replace("'", "''").Replace("�", "''") + $currentValue = $ComplexObject[$key].Replace("'", "''").Replace('�', "''") } $currentProperty += Get-M365DSCDRGSimpleObjectTypeToString -Key $key -Value $currentValue -Space ($indent) } @@ -452,7 +452,7 @@ function Get-M365DSCDRGComplexTypeToString } } $indent = '' - $indent = ' ' * ($IndentLevel -1) + $indent = ' ' * ($IndentLevel - 1) if ($key -in $ComplexTypeMapping.Name) { $currentProperty += "`r`n" @@ -467,7 +467,7 @@ function Get-M365DSCDRGComplexTypeToString #Indenting last parenthesis when the cim instance is an array if ($IndentLevel -eq 5) { - $indent = ' ' * ($IndentLevel -2) + $indent = ' ' * ($IndentLevel - 2) $currentProperty += $indent } @@ -479,8 +479,8 @@ function Get-M365DSCDRGComplexTypeToString if ($null -ne $currentProperty) { - $fancySingleQuotes = "[\u2019\u2018]" - $fancyDoubleQuotes = "[\u201C\u201D]" + $fancySingleQuotes = '[\u2019\u2018]' + $fancyDoubleQuotes = '[\u201C\u201D]' $currentProperty = [regex]::Replace($currentProperty, $fancySingleQuotes, "''") $currentProperty = [regex]::Replace($currentProperty, $fancyDoubleQuotes, '"') } @@ -517,11 +517,11 @@ function Get-M365DSCDRGSimpleObjectTypeToString { $key = 'odataType' } - $returnValue = $Space + $Key + " = '" + $Value + "'`r`n" + $returnValue = $Space + $Key + ' = "' + $Value + """`r`n" } '*.DateTime' { - $returnValue = $Space + $Key + " = '" + $Value + "'`r`n" + $returnValue = $Space + $Key + ' = "' + $Value + """`r`n" } '*[[\]]' { @@ -540,11 +540,11 @@ function Get-M365DSCDRGSimpleObjectTypeToString { '*.String' { - $returnValue += "$whitespace'$item'$newline" + $returnValue += "$whitespace""$item""$newline" } '*.DateTime' { - $returnValue += "$whitespace'$item'$newline" + $returnValue += "$whitespace""$item""$newline" } Default { @@ -574,9 +574,11 @@ function Compare-M365DSCComplexObject { [CmdletBinding()] [OutputType([System.Boolean])] - param( + param + ( [Parameter()] $Source, + [Parameter()] $Target ) @@ -660,12 +662,12 @@ function Compare-M365DSCComplexObject return $true } - if ($Source.GetType().FullName -like "*CimInstance") + if ($Source.GetType().FullName -like '*CimInstance') { $keys = @() - $Source.CimInstanceProperties | Foreach-Object { + $Source.CimInstanceProperties | ForEach-Object { if ($_.Name -notin @('PSComputerName', 'CimClass', 'CimInstanceProperties', 'CimSystemProperties') ` - -and $_.IsValueModified) + -and $_.IsValueModified) { $keys += $_.Name } @@ -676,18 +678,18 @@ function Compare-M365DSCComplexObject $keys = $Source.Keys | Where-Object -FilterScript { $_ -ne 'PSComputerName' } } - if ($Target.GetType().FullName -like "*CimInstance") + if ($Target.GetType().FullName -like '*CimInstance') { $targetKeys = @() - $Target.CimInstanceProperties | Foreach-Object { + $Target.CimInstanceProperties | ForEach-Object { if ($_.Name -notin @('PSComputerName', 'CimClass', 'CimInstanceProperties', 'CimSystemProperties') ` - -and $_.IsValueModified) + -and $_.IsValueModified) { $targetKeys += $_.Name } } } - elseif ($Target.GetType().FullName -like "*Hashtable") + elseif ($Target.GetType().FullName -like '*Hashtable') { $targetKeys = $Target.Keys | Where-Object -FilterScript { $_ -ne 'PSComputerName' } } @@ -824,7 +826,8 @@ function Convert-M365DSCDRGComplexTypeToHashtable { [CmdletBinding()] [OutputType([hashtable], [hashtable[]])] - param( + param + ( [Parameter(Mandatory = $true)] [AllowNull()] $ComplexObject, @@ -910,10 +913,12 @@ function ConvertFrom-IntunePolicyAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [Array] $Assignments, + [Parameter()] [System.Boolean] $IncludeDeviceFilter = $true @@ -950,7 +955,7 @@ function ConvertFrom-IntunePolicyAssignment $collectionId = $assignment.Target.AdditionalProperties.collectionId } - $hashAssignment.Add('dataType',$dataType) + $hashAssignment.Add('dataType', $dataType) if (-not [string]::IsNullOrEmpty($groupId)) { $hashAssignment.Add('groupId', $groupId) @@ -992,14 +997,15 @@ function ConvertFrom-IntunePolicyAssignment $assignmentResult += $hashAssignment } - return ,$assignmentResult + return , $assignmentResult } function ConvertTo-IntunePolicyAssignment { [CmdletBinding()] [OutputType([Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [AllowNull()] $Assignments, @@ -1011,13 +1017,13 @@ function ConvertTo-IntunePolicyAssignment if ($null -eq $Assignments) { - return ,@() + return , @() } $assignmentResult = @() foreach ($assignment in $Assignments) { - $target = @{"@odata.type" = $assignment.dataType} + $target = @{'@odata.type' = $assignment.dataType } if ($IncludeDeviceFilter) { if ($null -ne $assignment.DeviceAndAppManagementAssignmentFilterType) @@ -1045,14 +1051,14 @@ function ConvertTo-IntunePolicyAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.Count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1061,7 +1067,7 @@ function ConvertTo-IntunePolicyAssignment else { $message = "Skipping assignment for the group with Id {$($assignment.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } @@ -1075,21 +1081,23 @@ function ConvertTo-IntunePolicyAssignment if ($target) { - $assignmentResult += @{target = $target} + $assignmentResult += @{target = $target } } } - return ,$assignmentResult + return , $assignmentResult } function ConvertFrom-IntuneMobileAppAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [Array] $Assignments, + [Parameter()] [System.Boolean] $IncludeDeviceFilter = $true @@ -1169,14 +1177,15 @@ function ConvertFrom-IntuneMobileAppAssignment $assignmentResult += $hashAssignment } - return ,$assignmentResult + return , $assignmentResult } function ConvertTo-IntuneMobileAppAssignment { [CmdletBinding()] [OutputType([Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [AllowNull()] $Assignments, @@ -1188,14 +1197,14 @@ function ConvertTo-IntuneMobileAppAssignment if ($null -eq $Assignments) { - return ,@() + return , @() } $assignmentResult = @() foreach ($assignment in $Assignments) { $formattedAssignment = @{} - $target = @{"@odata.type" = $assignment.dataType} + $target = @{'@odata.type' = $assignment.dataType } if ($IncludeDeviceFilter) { if ($null -ne $assignment.DeviceAndAppManagementAssignmentFilterType) @@ -1218,14 +1227,14 @@ function ConvertTo-IntuneMobileAppAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.Count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1234,12 +1243,13 @@ function ConvertTo-IntuneMobileAppAssignment else { $message = "Skipping assignment for the group with Id {$($assignment.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } } - else { + else + { #Skipping assignment if group not found from either groupId or groupDisplayName $target.Add('groupId', $group.Id) } @@ -1252,18 +1262,22 @@ function ConvertTo-IntuneMobileAppAssignment $assignmentResult += $formattedAssignment } - return ,$assignmentResult + return , $assignmentResult } function Compare-M365DSCIntunePolicyAssignment { [CmdletBinding()] [OutputType([System.Boolean])] - param ( + param + ( [Parameter()] - [array]$Source, + [array] + $Source, + [Parameter()] - [array]$Target + [array] + $Target ) $testResult = $Source.Count -eq $Target.Count @@ -1282,7 +1296,7 @@ function Compare-M365DSCIntunePolicyAssignment if (-not $testResult) { Write-Verbose 'Group not found by groupId, checking if group exists by id' - $groupNotFound = $null -eq (Get-MgGroup -GroupId ($assignment.groupId) -ErrorAction SilentlyContinue) + $groupNotFound = $null -eq (Get-MgGroup -GroupId ($assignment.groupId) -ErrorAction SilentlyContinue) } if (-not $testResult -and $groupNotFound) { @@ -1295,9 +1309,9 @@ function Compare-M365DSCIntunePolicyAssignment { Write-Verbose 'Group found by groupId or groupDisplayName, checking filters' $isFilterTypeSpecified = ($null -ne $assignment.deviceAndAppManagementAssignmentFilterType -and $assignment.deviceAndAppManagementAssignmentFilterType -ne 'none') -or ` - ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterType -and $assignmentTarget.deviceAndAppManagementAssignmentFilterType -ne 'none') + ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterType -and $assignmentTarget.deviceAndAppManagementAssignmentFilterType -ne 'none') $isFilterIdSpecified = ($null -ne $assignment.deviceAndAppManagementAssignmentFilterId -and $assignment.deviceAndAppManagementAssignmentFilterId -ne '00000000-0000-0000-0000-000000000000') -or ` - ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterId -and $assignmentTarget.deviceAndAppManagementAssignmentFilterId -ne '00000000-0000-0000-0000-000000000000') + ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterId -and $assignmentTarget.deviceAndAppManagementAssignmentFilterId -ne '00000000-0000-0000-0000-000000000000') if ($isFilterTypeSpecified) { Write-Verbose 'FilterType specified, checking filterType' @@ -1320,7 +1334,10 @@ function Compare-M365DSCIntunePolicyAssignment { $testResult = $null -ne ($Target | Where-Object -FilterScript { $_.dataType -eq $assignment.DataType }) } - if (-not $testResult) { break } + if (-not $testResult) + { + break + } } } @@ -1331,7 +1348,8 @@ function Update-DeviceConfigurationPolicyAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param ( + param + ( [Parameter(Mandatory = $true)] [System.String] $DeviceConfigurationPolicyId, @@ -1345,7 +1363,7 @@ function Update-DeviceConfigurationPolicyAssignment $Repository = 'deviceManagement/configurationPolicies', [Parameter()] - [ValidateSet('v1.0','beta')] + [ValidateSet('v1.0', 'beta')] [System.String] $APIVersion = 'beta', @@ -1366,10 +1384,10 @@ function Update-DeviceConfigurationPolicyAssignment $target = $target.target } - $formattedTarget = @{"@odata.type" = $target.dataType} - if(-not $formattedTarget."@odata.type" -and $target."@odata.type") + $formattedTarget = @{'@odata.type' = $target.dataType } + if (-not $formattedTarget.'@odata.type' -and $target.'@odata.type') { - $formattedTarget."@odata.type" = $target."@odata.type" + $formattedTarget.'@odata.type' = $target.'@odata.type' } if ($target.groupId) { @@ -1382,14 +1400,14 @@ function Update-DeviceConfigurationPolicyAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1398,7 +1416,7 @@ function Update-DeviceConfigurationPolicyAssignment else { $message = "Skipping assignment for the group with Id {$($target.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } @@ -1406,25 +1424,25 @@ function Update-DeviceConfigurationPolicyAssignment #Skipping assignment if group not found from either groupId or groupDisplayName if ($null -ne $group) { - $formattedTarget.Add('groupId',$group.Id) + $formattedTarget.Add('groupId', $group.Id) } } if ($target.collectionId) { - $formattedTarget.Add('collectionId',$target.collectionId) + $formattedTarget.Add('collectionId', $target.collectionId) } if ($target.deviceAndAppManagementAssignmentFilterType) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType',$target.deviceAndAppManagementAssignmentFilterType) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType', $target.deviceAndAppManagementAssignmentFilterType) } if ($target.deviceAndAppManagementAssignmentFilterId) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId',$target.deviceAndAppManagementAssignmentFilterId) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId', $target.deviceAndAppManagementAssignmentFilterId) } - $deviceManagementPolicyAssignments += @{'target' = $formattedTarget} + $deviceManagementPolicyAssignments += @{'target' = $formattedTarget } } - $body = @{$RootIdentifier = $deviceManagementPolicyAssignments} | ConvertTo-Json -Depth 20 + $body = @{$RootIdentifier = $deviceManagementPolicyAssignments } | ConvertTo-Json -Depth 20 Write-Verbose -Message $body Invoke-MgGraphRequest -Method POST -Uri $Uri -Body $body -ErrorAction Stop @@ -1445,7 +1463,8 @@ function Update-DeviceAppManagementPolicyAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param ( + param + ( [Parameter(Mandatory = $true)] [System.String] $AppManagementPolicyId, @@ -1459,7 +1478,7 @@ function Update-DeviceAppManagementPolicyAssignment $Repository = 'deviceAppManagement/mobileApps', [Parameter()] - [ValidateSet('v1.0','beta')] + [ValidateSet('v1.0', 'beta')] [System.String] $APIVersion = 'beta', @@ -1477,7 +1496,7 @@ function Update-DeviceAppManagementPolicyAssignment { $formattedAssignment = @{ '@odata.type' = '#microsoft.graph.mobileAppAssignment' - intent = $assignment.intent + intent = $assignment.intent } if ($assigment.settings) { @@ -1489,10 +1508,10 @@ function Update-DeviceAppManagementPolicyAssignment $target = $assignment.target } - $formattedTarget = @{"@odata.type" = $target.dataType} - if(-not $formattedTarget."@odata.type" -and $target."@odata.type") + $formattedTarget = @{'@odata.type' = $target.dataType } + if (-not $formattedTarget.'@odata.type' -and $target.'@odata.type') { - $formattedTarget."@odata.type" = $target."@odata.type" + $formattedTarget.'@odata.type' = $target.'@odata.type' } if ($target.groupId) { @@ -1505,14 +1524,14 @@ function Update-DeviceAppManagementPolicyAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1521,7 +1540,7 @@ function Update-DeviceAppManagementPolicyAssignment else { $message = "Skipping assignment for the group with Id {$($target.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } @@ -1529,22 +1548,22 @@ function Update-DeviceAppManagementPolicyAssignment #Skipping assignment if group not found from either groupId or groupDisplayName if ($null -ne $group) { - $formattedTarget.Add('groupId',$group.Id) + $formattedTarget.Add('groupId', $group.Id) } } if ($target.deviceAndAppManagementAssignmentFilterType) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType',$target.deviceAndAppManagementAssignmentFilterType) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType', $target.deviceAndAppManagementAssignmentFilterType) } if ($target.deviceAndAppManagementAssignmentFilterId) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId',$target.deviceAndAppManagementAssignmentFilterId) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId', $target.deviceAndAppManagementAssignmentFilterId) } $formattedAssignment.Add('target', $formattedTarget) $appManagementPolicyAssignments += $formattedAssignment } - $body = @{$RootIdentifier = $appManagementPolicyAssignments} | ConvertTo-Json -Depth 20 + $body = @{$RootIdentifier = $appManagementPolicyAssignments } | ConvertTo-Json -Depth 20 Write-Verbose -Message $body Invoke-MgGraphRequest -Method POST -Uri $Uri -Body $body -ErrorAction Stop @@ -1565,7 +1584,8 @@ function Get-OmaSettingPlainTextValue { [CmdletBinding()] [OutputType([System.String])] - Param( + param + ( [Parameter(Mandatory = $true)] [System.String] $SecretReferenceValueId, @@ -1582,7 +1602,7 @@ function Get-OmaSettingPlainTextValue e.g. PolicyId for SecretReferenceValueId '35ea58ec-2a79-471d-8eea-7e28e6cd2722_bdf6c690-05fb-4d02-835d-5a7406c35d58_abe32712-2255-445f-a35e-0c6f143d82ca' is 'bdf6c690-05fb-4d02-835d-5a7406c35d58' #> - $SplitSecretReferenceValueId = $SecretReferenceValueId.Split("_") + $SplitSecretReferenceValueId = $SecretReferenceValueId.Split('_') if ($SplitSecretReferenceValueId.Count -eq 3) { $PolicyId = $SplitSecretReferenceValueId[1] @@ -1606,7 +1626,7 @@ function Get-OmaSettingPlainTextValue } catch { - $Message = "Error decrypting OmaSetting with SecretReferenceValueId {0}:" -f $SecretReferenceValueId + $Message = 'Error decrypting OmaSetting with SecretReferenceValueId {0}:' -f $SecretReferenceValueId New-M365DSCLogEntry -Message $Message ` -Exception $_ ` -Source $($MyInvocation.MyCommand.Source) ` @@ -1619,7 +1639,9 @@ function Get-OmaSettingPlainTextValue if (![String]::IsNullOrEmpty($Result.Value)) { return $Result.Value - } else { + } + else + { return $null } } @@ -1628,7 +1650,8 @@ function Get-IntuneSettingCatalogPolicySetting { [CmdletBinding()] [OutputType([System.Array])] - param ( + param + ( [Parameter(Mandatory = $true)] [System.Collections.Hashtable] $DSCParams, @@ -1672,11 +1695,11 @@ function Get-IntuneSettingCatalogPolicySetting if ($ContainsDeviceAndUserSettings) { - $deviceSettingTemplates = $SettingTemplates | Where-object -FilterScript { - $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith("device_") + $deviceSettingTemplates = $SettingTemplates | Where-Object -FilterScript { + $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith('device_') } - $userSettingTemplates = $SettingTemplates | Where-object -FilterScript { - $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith("user_") + $userSettingTemplates = $SettingTemplates | Where-Object -FilterScript { + $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith('user_') } $deviceDscParams = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $DSCParams.DeviceSettings -SingleLevel -ExcludeUnchangedProperties $userDscParams = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $DSCParams.UserSettings -SingleLevel -ExcludeUnchangedProperties @@ -1684,7 +1707,7 @@ function Get-IntuneSettingCatalogPolicySetting $combinedSettingInstances += Get-IntuneSettingCatalogPolicySetting -DSCParams $deviceDscParams -SettingTemplates $deviceSettingTemplates $combinedSettingInstances += Get-IntuneSettingCatalogPolicySetting -DSCParams $userDscParams -SettingTemplates $userSettingTemplates - return ,$combinedSettingInstances + return , $combinedSettingInstances } } @@ -1760,14 +1783,15 @@ function Get-IntuneSettingCatalogPolicySetting } } - return ,$settingInstances + return , $settingInstances } function Get-IntuneSettingCatalogPolicySettingInstanceValue { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param( + param + ( [Parameter(Mandatory = 'true')] [System.Collections.Hashtable] $DSCParams, @@ -1829,12 +1853,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $instanceCount = 1 if (($Level -gt 1 -and $groupSettingCollectionDefinitionChildren.Count -gt 1) -or - ($Level -eq 1 -and $SettingDefinition.AdditionalProperties.maximumCount -gt 1 -and $groupSettingCollectionDefinitionChildren.Count -ge 1 -and $groupSettingCollectionDefinitionChildren.AdditionalProperties.'@odata.type' -notcontains "#microsoft.graph.deviceManagementConfigurationSettingGroupCollectionDefinition")) + ($Level -eq 1 -and $SettingDefinition.AdditionalProperties.maximumCount -gt 1 -and $groupSettingCollectionDefinitionChildren.Count -ge 1 -and $groupSettingCollectionDefinitionChildren.AdditionalProperties.'@odata.type' -notcontains '#microsoft.graph.deviceManagementConfigurationSettingGroupCollectionDefinition')) { $SettingInstanceName += Get-SettingsCatalogSettingName -SettingDefinition $SettingDefinition -AllSettingDefinitions $AllSettingDefinitions - $settingInstanceNameAlternate = $SettingInstanceName + "_Intune" + $settingInstanceNameAlternate = $SettingInstanceName + '_Intune' $cimDSCParams = @() - $cimDSCParamsName = "" + $cimDSCParamsName = '' $DSCParams.GetEnumerator() | ForEach-Object { if ($_.Value.CimClass.CimClassName -eq $SettingInstanceName -or $_.Value.CimClass.CimClassName -like "$settingInstanceNameAlternate*") { @@ -1845,10 +1869,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $newDSCParams = @{ $cimDSCParamsName = @() } - foreach ($instance in $cimDSCParams) { + foreach ($instance in $cimDSCParams) + { $newInstanceDSCParams = @{} # Preserve CIM instances when converting to hashtable - foreach ($property in $instance.CimInstanceProperties) { + foreach ($property in $instance.CimInstanceProperties) + { if ($property.IsValueModified) { $newInstanceDSCParams.Add($property.Name, $property.Value) @@ -1858,7 +1884,14 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } $instanceCount = $newDSCParams.$cimDSCParamsName.Count $DSCParams = @{ - $cimDSCParamsName = if ($instanceCount -eq 1) { $newDSCParams.$cimDSCParamsName[0] } else { $newDSCParams.$cimDSCParamsName } + $cimDSCParamsName = if ($instanceCount -eq 1) + { + $newDSCParams.$cimDSCParamsName[0] + } + else + { + $newDSCParams.$cimDSCParamsName + } } $AllSettingDefinitions = $groupSettingCollectionDefinitionChildren + $SettingDefinition } @@ -1866,16 +1899,25 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue for ($i = 0; $i -lt $instanceCount; $i++) { $groupSettingCollectionValueChildren = @() - $currentDSCParams = if ($instanceCount -eq 1) { - if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) { + $currentDSCParams = if ($instanceCount -eq 1) + { + if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) + { $DSCParams.$cimDSCParamsName - } else { + } + else + { $DSCParams } - } else { - if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) { + } + else + { + if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) + { $DSCParams.$cimDSCParamsName[$i] - } else { + } + else + { $DSCParams[$i] } } @@ -1891,9 +1933,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $childSettingValueName = $childSettingType.Replace('#microsoft.graph.deviceManagementConfiguration', '').Replace('Instance', 'Value') $childSettingValueType = "#microsoft.graph.deviceManagementConfiguration$($childSettingValueName)" $childSettingValueName = $childSettingValueName.Substring(0, 1).ToLower() + $childSettingValueName.Substring(1, $childSettingValueName.length - 1 ) - $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) { + $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) + { $SettingInstanceTemplate.AdditionalProperties.groupSettingCollectionValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } | Select-Object -First 1 - } else { + } + else + { $SettingInstanceTemplate.groupSettingCollectionValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } | Select-Object -First 1 } @@ -1929,13 +1974,13 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } $childSettingValueItem.Add('@odata.type', $childSettingType) $childSettingValueInner.children += @{ - '@odata.type' = '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance' + '@odata.type' = '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance' groupSettingCollectionValue = @( @{ children = $childSettingValueItem.children } ) - settingDefinitionId = $childDefinition.Id + settingDefinitionId = $childDefinition.Id } <# GroupSettingCollection do not have a setting instance template reference if (-not [string]::IsNullOrEmpty($childSettingInstanceTemplate.settingInstanceTemplateId)) @@ -1976,7 +2021,8 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } } - if ($groupSettingCollectionDefinitionChildren.Count -gt 0 -and $groupSettingCollectionValue.Count -gt 0) { + if ($groupSettingCollectionDefinitionChildren.Count -gt 0 -and $groupSettingCollectionValue.Count -gt 0) + { $settingValuesToReturn.Add('groupSettingCollectionValue', @($groupSettingCollectionValue)) } } @@ -2002,9 +2048,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $childSettingValueName = $childSettingType.Replace('#microsoft.graph.deviceManagementConfiguration', '').Replace('Instance', 'Value') $childSettingValueType = "#microsoft.graph.deviceManagementConfiguration$($childSettingValueName)" $childSettingValueName = $childSettingValueName.Substring(0, 1).ToLower() + $childSettingValueName.Substring(1, $childSettingValueName.Length - 1 ) - $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) { + $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) + { $SettingInstanceTemplate.AdditionalProperties.choiceSettingValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } - } else { + } + else + { $SettingInstanceTemplate.choiceSettingValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } } $childSettingValueTemplateId = $childSettingInstanceTemplate."$($childSettingValueName)Template" | Where-Object { @@ -2038,9 +2087,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } # Depending on the children count, we add the children to the choice setting or an empty array since the children property is required - if ($choiceSettingDefinitionChildren.Count -gt 0) { + if ($choiceSettingDefinitionChildren.Count -gt 0) + { $choiceSettingValue.Add('children', $choiceSettingValueChildren) - } else { + } + else + { $choiceSettingValue.Add('children', @()) } @@ -2089,8 +2141,8 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue foreach ($value in $values) { $choiceSettingValueCollection += @{ - value = $value - children = @() + value = $value + children = @() '@odata.type' = '#microsoft.graph.deviceManagementConfigurationChoiceSettingValue' } } @@ -2123,7 +2175,8 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue '@odata.type' = $SettingValueType } } - if ($settingValueCollection.Count -gt 0) { + if ($settingValueCollection.Count -gt 0) + { $settingValuesToReturn.Add($SettingValueName, $settingValueCollection) } } @@ -2150,7 +2203,7 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue { if ($SettingDefinition.AdditionalProperties.valueDefinition.isSecret) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationSecretSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationSecretSettingValue' $settingValue.Add('valueState', 'NotEncrypted') } $settingValue.Add('@odata.type', $SettingValueType) @@ -2174,7 +2227,7 @@ function Get-IntuneSettingCatalogPolicySettingDSCValue ( [Parameter()] [System.String] - $SettingValueType = "", + $SettingValueType = '', [Parameter()] $SettingDefinition, @@ -2196,37 +2249,44 @@ function Get-IntuneSettingCatalogPolicySettingDSCValue } $isArray = $false - if ($SettingValueType -like "*Simple*") + if ($SettingValueType -like '*Simple*') { if ($DSCParams[$key] -is [System.String]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationStringSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationStringSettingValue' } elseif ($DSCParams[$key] -is [System.Int32]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationIntegerSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue' } elseif ($DSCParams[$key] -is [System.String[]]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationStringSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationStringSettingValue' $isArray = $true } elseif ($DSCParams[$key] -is [System.Int32[]]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationIntegerSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue' $isArray = $true } } - if ($SettingValueType -like "*Simple*" -or $SettingValueType -in @("#microsoft.graph.deviceManagementConfigurationIntegerSettingValue", "#microsoft.graph.deviceManagementConfigurationStringSettingValue")) + if ($SettingValueType -like '*Simple*' -or $SettingValueType -in @('#microsoft.graph.deviceManagementConfigurationIntegerSettingValue', '#microsoft.graph.deviceManagementConfigurationStringSettingValue')) { return @{ SettingDefinition = $SettingDefinition - SettingValueType = $SettingValueType - Value = if ($isArray) { ,$DSCParams[$key] } else { $DSCParams[$key] } + SettingValueType = $SettingValueType + Value = if ($isArray) + { + , $DSCParams[$key] + } + else + { + $DSCParams[$key] + } } } - elseif ($SettingValueType -like "*ChoiceSettingCollection*") + elseif ($SettingValueType -like '*ChoiceSettingCollection*') { $values = @() foreach ($value in $DSCParams[$key]) @@ -2242,8 +2302,8 @@ function Get-IntuneSettingCatalogPolicySettingDSCValue { return @{ SettingDefinition = $SettingDefinition - SettingValueType = $SettingValueType - Value = "$($SettingDefinition.Id)_$($DSCParams[$key])" + SettingValueType = $SettingValueType + Value = "$($SettingDefinition.Id)_$($DSCParams[$key])" } } } @@ -2252,7 +2312,8 @@ function Export-IntuneSettingCatalogPolicySettings { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param( + param + ( [Parameter( Mandatory = $true, ParameterSetName = 'Start' @@ -2303,7 +2364,7 @@ function Export-IntuneSettingCatalogPolicySettings { $deviceSettingsReturnHashtable = @{} $deviceSettings = $Settings | Where-Object -FilterScript { - $_.SettingInstance.settingDefinitionId.StartsWith("device_") + $_.SettingInstance.settingDefinitionId.StartsWith('device_') } if ($AllSettingDefinitions.Count -eq 0) { @@ -2312,7 +2373,7 @@ function Export-IntuneSettingCatalogPolicySettings else { $allDeviceSettingDefinitions = $AllSettingDefinitions | Where-Object -FilterScript { - $_.Id.StartsWith("device_") + $_.Id.StartsWith('device_') } } foreach ($setting in $deviceSettings) @@ -2322,7 +2383,7 @@ function Export-IntuneSettingCatalogPolicySettings $userSettingsReturnHashtable = @{} $userSettings = $Settings | Where-Object -FilterScript { - $_.SettingInstance.settingDefinitionId.StartsWith("user_") + $_.SettingInstance.settingDefinitionId.StartsWith('user_') } if ($AllSettingDefinitions.Count -eq 0) { @@ -2331,7 +2392,7 @@ function Export-IntuneSettingCatalogPolicySettings else { $allUserSettingDefinitions = $AllSettingDefinitions | Where-Object -FilterScript { - $_.Id.StartsWith("user_") + $_.Id.StartsWith('user_') } } @@ -2366,12 +2427,26 @@ function Export-IntuneSettingCatalogPolicySettings $addToParameters = $true $settingDefinition = $SettingDefinitions | Where-Object -FilterScript { $_.Id -eq $SettingInstance.settingDefinitionId } $settingName = Get-SettingsCatalogSettingName -SettingDefinition $settingDefinition -AllSettingDefinitions $AllSettingDefinitions - $odataType = if ($IsRoot) { $SettingInstance.AdditionalProperties.'@odata.type' } else { $SettingInstance.'@odata.type' } + $odataType = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.'@odata.type' + } + else + { + $SettingInstance.'@odata.type' + } switch ($odataType) { '#microsoft.graph.deviceManagementConfigurationSimpleSettingInstance' { - $simpleSetting = if ($IsRoot) { $SettingInstance.AdditionalProperties.simpleSettingValue } else { $SettingInstance.simpleSettingValue } + $simpleSetting = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.simpleSettingValue + } + else + { + $SettingInstance.simpleSettingValue + } if ($simpleSetting.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue') { $settingValue = [int]$simpleSetting.value @@ -2383,9 +2458,23 @@ function Export-IntuneSettingCatalogPolicySettings } '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance' { - $settingValue = if ($IsRoot) { $SettingInstance.AdditionalProperties.choiceSettingValue.value } else { $SettingInstance.choiceSettingValue.value } + $settingValue = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.choiceSettingValue.value + } + else + { + $SettingInstance.choiceSettingValue.value + } $settingValue = $settingValue.Split('_') | Select-Object -Last 1 - $childSettings = if ($IsRoot) { $SettingInstance.AdditionalProperties.choiceSettingValue.children } else { $SettingInstance.choiceSettingValue.children } + $childSettings = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.choiceSettingValue.children + } + else + { + $SettingInstance.choiceSettingValue.children + } foreach ($childSetting in $childSettings) { Export-IntuneSettingCatalogPolicySettings -SettingInstance $childSetting -SettingDefinitions $SettingDefinitions -ReturnHashtable $ReturnHashtable -AllSettingDefinitions $AllSettingDefinitions @@ -2394,7 +2483,14 @@ function Export-IntuneSettingCatalogPolicySettings '#microsoft.graph.deviceManagementConfigurationChoiceSettingCollectionInstance' { $values = @() - $childValues = if ($IsRoot) { $SettingInstance.AdditionalProperties.choiceSettingCollectionValue.value } else { $SettingInstance.choiceSettingCollectionValue.value } + $childValues = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.choiceSettingCollectionValue.value + } + else + { + $SettingInstance.choiceSettingCollectionValue.value + } foreach ($value in $childValues) { $values += $value.Split('_') | Select-Object -Last 1 @@ -2403,7 +2499,14 @@ function Export-IntuneSettingCatalogPolicySettings } '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance' { - $groupSettingCollectionValue = if ($IsRoot) { $SettingInstance.AdditionalProperties.groupSettingCollectionValue } else { $SettingInstance.groupSettingCollectionValue } + $groupSettingCollectionValue = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.groupSettingCollectionValue + } + else + { + $SettingInstance.groupSettingCollectionValue + } [array]$childSettingDefinitions = $SettingDefinitions | Where-Object -FilterScript { $settingDefinition.AdditionalProperties.childIds -contains $_.Id } @@ -2453,7 +2556,14 @@ function Export-IntuneSettingCatalogPolicySettings } $childValue += $childHashtable } - $settingValue = if ($null -eq $childValue) { $childHashtable } else { ,$childValue } + $settingValue = if ($null -eq $childValue) + { + $childHashtable + } + else + { + , $childValue + } } else { @@ -2469,7 +2579,14 @@ function Export-IntuneSettingCatalogPolicySettings '#microsoft.graph.deviceManagementConfigurationSimpleSettingCollectionInstance' { $values = @() - $childValues = if ($IsRoot) { $SettingInstance.AdditionalProperties.simpleSettingCollectionValue } else { $SettingInstance.simpleSettingCollectionValue } + $childValues = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.simpleSettingCollectionValue + } + else + { + $SettingInstance.simpleSettingCollectionValue + } foreach ($value in $childValues) { if ($value.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue') @@ -2573,11 +2690,15 @@ function Update-IntuneDeviceConfigurationPolicy } } -function Get-ComplexFunctionsFromFilterQuery { +function Get-ComplexFunctionsFromFilterQuery +{ [CmdletBinding()] [OutputType([System.Array])] - param ( - [string]$FilterQuery + param + ( + [Parameter()] + [System.String] + $FilterQuery ) $complexFunctionsRegex = "startswith\((.*?),\s*'(.*?)'\)|endswith\((.*?),\s*'(.*?)'\)|contains\((.*?),\s*'(.*?)'\)" @@ -2588,38 +2709,55 @@ function Get-ComplexFunctionsFromFilterQuery { return $complexFunctions } -function Remove-ComplexFunctionsFromFilterQuery { +function Remove-ComplexFunctionsFromFilterQuery +{ [CmdletBinding()] [OutputType([System.String])] - param ( - [string]$FilterQuery + param + ( + [Parameter()] + [System.String] + $FilterQuery ) $complexFunctionsRegex = "startswith\((.*?),\s*'(.*?)'\)|endswith\((.*?),\s*'(.*?)'\)|contains\((.*?),\s*'(.*?)'\)" - $basicFilterQuery = [regex]::Replace($FilterQuery, $complexFunctionsRegex, "").Trim() - $basicFilterQuery = $basicFilterQuery -replace "^and\s","" -replace "\sand$","" -replace "\sand\s+", " and " -replace "\sor\s+", " or " + $basicFilterQuery = [regex]::Replace($FilterQuery, $complexFunctionsRegex, '').Trim() + $basicFilterQuery = $basicFilterQuery -replace '^and\s', '' -replace '\sand$', '' -replace '\sand\s+', ' and ' -replace '\sor\s+', ' or ' return $basicFilterQuery } -function Find-GraphDataUsingComplexFunctions { +function Find-GraphDataUsingComplexFunctions +{ [CmdletBinding()] [OutputType([System.Array])] - param ( - [array]$Policies, - [array]$ComplexFunctions + param + ( + [Parameter()] + [array] + $Policies, + + [Parameter()] + [array] + $ComplexFunctions ) - foreach ($function in $ComplexFunctions) { - if ($function -match "startswith\((.*?),\s*'(.*?)'") { + foreach ($function in $ComplexFunctions) + { + if ($function -match "startswith\((.*?),\s*'(.*?)'") + { $property = $matches[1] $value = $matches[2] $Policies = $Policies | Where-Object { $_.$property -like "$value*" } - } elseif ($function -match "endswith\((.*?),\s*'(.*?)'") { + } + elseif ($function -match "endswith\((.*?),\s*'(.*?)'") + { $property = $matches[1] $value = $matches[2] $Policies = $Policies | Where-Object { $_.$property -like "*$value" } - } elseif ($function -match "contains\((.*?),\s*'(.*?)'") { + } + elseif ($function -match "contains\((.*?),\s*'(.*?)'") + { $property = $matches[1] $value = $matches[2] $Policies = $Policies | Where-Object { $_.$property -like "*$value*" } diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index f2ad02b566..d9c1e821d5 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -3755,7 +3755,7 @@ function Get-M365DSCExportContentForResource if ($ConnectionMode -like 'ServicePrincipal*' -or ` $ConnectionMode -eq 'ManagedIdentity') { - $OrganizationName = $Results.TenantId + $OrganizationName = $TenantId } elseif ($null -ne $Credential.UserName) { From f261a37e7de4753c025775be14bf918d2a46dfb0 Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Mon, 16 Dec 2024 16:29:18 +0100 Subject: [PATCH 3/6] Fixed unit test and supressed Warnings during unit tests --- CHANGELOG.md | 2 ++ Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 | 2 +- .../Microsoft365DSC.AADVerifiedIdAuthority.Tests.ps1 | 2 ++ .../Microsoft365DSC.AADVerifiedIdAuthorityContract.Tests.ps1 | 2 ++ .../Microsoft365DSC.EXODataAtRestEncryptionPolicy.Tests.ps1 | 2 ++ .../Microsoft365DSC/Microsoft365DSC.EXOMigration.Tests.ps1 | 4 ++++ .../Microsoft365DSC.EXOTransportRule.Tests.ps1 | 2 ++ ...tectionLocalAdministratorPasswordSolutionPolicy.Tests.ps1 | 2 ++ ...AccountProtectionLocalUserGroupMembershipPolicy.Tests.ps1 | 2 ++ .../Microsoft365DSC.IntuneAccountProtectionPolicy.Tests.ps1 | 2 ++ ...ft365DSC.IntuneAccountProtectionPolicyWindows10.Tests.ps1 | 2 ++ ...soft365DSC.IntuneAntivirusExclusionsPolicyLinux.Tests.ps1 | 2 ++ ...soft365DSC.IntuneAntivirusExclusionsPolicyMacOS.Tests.ps1 | 2 ++ .../Microsoft365DSC.IntuneAntivirusPolicyLinux.Tests.ps1 | 5 ++++- .../Microsoft365DSC.IntuneAntivirusPolicyMacOS.Tests.ps1 | 3 +++ ...SC.IntuneAntivirusPolicyWindows10SettingCatalog.Tests.ps1 | 3 +++ ...DSC.IntuneAppAndBrowserIsolationPolicyWindows10.Tests.ps1 | 3 +++ ...eAppAndBrowserIsolationPolicyWindows10ConfigMgr.Tests.ps1 | 3 +++ ...t365DSC.IntuneApplicationControlPolicyWindows10.Tests.ps1 | 3 +++ ...eConfigurationIdentityProtectionPolicyWindows10.Tests.ps1 | 3 +++ ...rosoft365DSC.IntuneDeviceControlPolicyWindows10.Tests.ps1 | 3 +++ .../Microsoft365DSC.IntuneDeviceRemediation.Tests.ps1 | 3 +++ ...ft365DSC.IntuneDiskEncryptionPDEPolicyWindows10.Tests.ps1 | 3 +++ .../Microsoft365DSC.IntuneDiskEncryptionWindows10.Tests.ps1 | 3 +++ ...C.IntuneEndpointDetectionAndResponsePolicyLinux.Tests.ps1 | 3 +++ ...C.IntuneEndpointDetectionAndResponsePolicyMacOS.Tests.ps1 | 3 +++ ...tuneEndpointDetectionAndResponsePolicyWindows10.Tests.ps1 | 3 +++ ...eExploitProtectionPolicyWindows10SettingCatalog.Tests.ps1 | 3 +++ .../Microsoft365DSC.IntuneFirewallPolicyWindows10.Tests.ps1 | 3 +++ ...365DSC.IntuneFirewallRulesHyperVPolicyWindows10.Tests.ps1 | 3 +++ ...rosoft365DSC.IntuneFirewallRulesPolicyWindows10.Tests.ps1 | 3 +++ ...DSC.IntuneFirewallRulesPolicyWindows10ConfigMgr.Tests.ps1 | 3 +++ .../Microsoft365DSC.IntunePolicySets.Tests.ps1 | 3 +++ ...65DSC.IntuneSecurityBaselineDefenderForEndpoint.Tests.ps1 | 3 +++ ...neSecurityBaselineMicrosoft365AppsForEnterprise.Tests.ps1 | 3 +++ ...osoft365DSC.IntuneSecurityBaselineMicrosoftEdge.Tests.ps1 | 3 +++ ...DSC.IntuneSettingCatalogASRRulesPolicyWindows10.Tests.ps1 | 3 +++ ...sUpdateForBusinessQualityUpdateProfileWindows10.Tests.ps1 | 3 +++ 38 files changed, 103 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a920b45e5..60f349a01b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * FIXES [#5550](https://github.com/microsoft/Microsoft365DSC/issues/5550) * MISC * Fixed the Fabric web request to use basic parsing. + * Fixed an issue where the export does not convert tenant name into + generic $OrganizationName variable correctly. * M365DSCUtil * Update `Get-M365DSCWorkloadsListFromResourceNames` function for more input types. FIXES [#5525](https://github.com/microsoft/Microsoft365DSC/issues/5525) diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index d9c1e821d5..7681c9f081 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -3935,7 +3935,7 @@ function Get-M365DSCExportContentForResource } } - if ($partialContent.ToLower().IndexOf($OrganizationName.ToLower()) -gt 0) + if ($null -ne $OrganizationName -and $partialContent.ToLower().IndexOf($OrganizationName.ToLower()) -gt 0) { $partialContent = $partialContent -ireplace [regex]::Escape($OrganizationName + ':'), "`$($OrganizationName):" $partialContent = $partialContent -ireplace [regex]::Escape($OrganizationName), "`$OrganizationName" diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthority.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthority.Tests.ps1 index 0c01f44993..3bcd89c608 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthority.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthority.Tests.ps1 @@ -46,6 +46,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthorityContract.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthorityContract.Tests.ps1 index 6e058fd01b..24c255617b 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthorityContract.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthorityContract.Tests.ps1 @@ -46,6 +46,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXODataAtRestEncryptionPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXODataAtRestEncryptionPolicy.Tests.ps1 index 9969ea0126..17e6ab26a5 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXODataAtRestEncryptionPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXODataAtRestEncryptionPolicy.Tests.ps1 @@ -46,6 +46,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMigration.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMigration.Tests.ps1 index 3e7e4c3adb..57d951b08d 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMigration.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMigration.Tests.ps1 @@ -56,6 +56,10 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + + Mock -CommandName Write-Verbose -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOTransportRule.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOTransportRule.Tests.ps1 index 2e501dab08..28e4fbcc8b 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOTransportRule.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOTransportRule.Tests.ps1 @@ -41,6 +41,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.Tests.ps1 index 16a96f1d0b..5a22bdb211 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.Tests.ps1 @@ -114,6 +114,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalUserGroupMembershipPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalUserGroupMembershipPolicy.Tests.ps1 index 50196c8309..10c45c4a9b 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalUserGroupMembershipPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalUserGroupMembershipPolicy.Tests.ps1 @@ -143,6 +143,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicy.Tests.ps1 index 2f60f5a80c..388aa05044 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicy.Tests.ps1 @@ -105,6 +105,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicyWindows10.Tests.ps1 index 2f1b585b8f..02ccabf07d 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicyWindows10.Tests.ps1 @@ -188,6 +188,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyLinux.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyLinux.Tests.ps1 index f29d2fd298..5e742d4a62 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyLinux.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyLinux.Tests.ps1 @@ -201,6 +201,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyMacOS.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyMacOS.Tests.ps1 index 2abd4aed6e..ce067ed413 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyMacOS.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyMacOS.Tests.ps1 @@ -199,6 +199,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyLinux.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyLinux.Tests.ps1 index 48f93a3eb4..98968fa586 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyLinux.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyLinux.Tests.ps1 @@ -511,6 +511,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false @@ -737,7 +740,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Credential = $Credential } } - + It 'Should Reverse Engineer resource from the Export method' { $result = Export-TargetResource @testParams $result | Should -Not -BeNullOrEmpty diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyMacOS.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyMacOS.Tests.ps1 index e2dbb85c46..1ec550f0f3 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyMacOS.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyMacOS.Tests.ps1 @@ -498,6 +498,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyWindows10SettingCatalog.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyWindows10SettingCatalog.Tests.ps1 index 36c563e9cd..6cb3cfe8ee 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyWindows10SettingCatalog.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyWindows10SettingCatalog.Tests.ps1 @@ -117,6 +117,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10.Tests.ps1 index 081fc88e60..173fd37a33 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10.Tests.ps1 @@ -166,6 +166,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10ConfigMgr.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10ConfigMgr.Tests.ps1 index 3f91a6caf3..46b96d756d 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10ConfigMgr.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10ConfigMgr.Tests.ps1 @@ -161,6 +161,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneApplicationControlPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneApplicationControlPolicyWindows10.Tests.ps1 index 84719e3f2f..9cff89677a 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneApplicationControlPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneApplicationControlPolicyWindows10.Tests.ps1 @@ -46,6 +46,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceConfigurationIdentityProtectionPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceConfigurationIdentityProtectionPolicyWindows10.Tests.ps1 index f0f904a249..328c815bbf 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceConfigurationIdentityProtectionPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceConfigurationIdentityProtectionPolicyWindows10.Tests.ps1 @@ -53,6 +53,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceControlPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceControlPolicyWindows10.Tests.ps1 index b15984720e..55b7956cb2 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceControlPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceControlPolicyWindows10.Tests.ps1 @@ -514,6 +514,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceRemediation.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceRemediation.Tests.ps1 index d354e20c66..60870cc47e 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceRemediation.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceRemediation.Tests.ps1 @@ -52,6 +52,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionPDEPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionPDEPolicyWindows10.Tests.ps1 index 0d4905e4bf..a24882a4d3 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionPDEPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionPDEPolicyWindows10.Tests.ps1 @@ -195,6 +195,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionWindows10.Tests.ps1 index 78a4588d0e..7a538c508c 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionWindows10.Tests.ps1 @@ -155,6 +155,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyLinux.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyLinux.Tests.ps1 index fcd8f5ebf6..079389cd7b 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyLinux.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyLinux.Tests.ps1 @@ -145,6 +145,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyMacOS.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyMacOS.Tests.ps1 index 8f490b9735..aa8cda720e 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyMacOS.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyMacOS.Tests.ps1 @@ -145,6 +145,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyWindows10.Tests.ps1 index 85bdc2b60a..c5ea260240 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyWindows10.Tests.ps1 @@ -165,6 +165,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneExploitProtectionPolicyWindows10SettingCatalog.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneExploitProtectionPolicyWindows10SettingCatalog.Tests.ps1 index a5dbf07f70..8f70de56da 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneExploitProtectionPolicyWindows10SettingCatalog.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneExploitProtectionPolicyWindows10SettingCatalog.Tests.ps1 @@ -117,6 +117,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallPolicyWindows10.Tests.ps1 index f4455f536b..742803d4b0 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallPolicyWindows10.Tests.ps1 @@ -433,6 +433,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesHyperVPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesHyperVPolicyWindows10.Tests.ps1 index 42368fc025..20d88f3775 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesHyperVPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesHyperVPolicyWindows10.Tests.ps1 @@ -285,6 +285,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10.Tests.ps1 index 03224a580e..219b0765fe 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10.Tests.ps1 @@ -364,6 +364,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10ConfigMgr.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10ConfigMgr.Tests.ps1 index 14506a6da8..106d42bda6 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10ConfigMgr.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10ConfigMgr.Tests.ps1 @@ -364,6 +364,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntunePolicySets.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntunePolicySets.Tests.ps1 index 4ceff9776a..0b30c17e42 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntunePolicySets.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntunePolicySets.Tests.ps1 @@ -52,6 +52,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineDefenderForEndpoint.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineDefenderForEndpoint.Tests.ps1 index 101a834113..aa7da1a9b5 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineDefenderForEndpoint.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineDefenderForEndpoint.Tests.ps1 @@ -234,6 +234,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoft365AppsForEnterprise.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoft365AppsForEnterprise.Tests.ps1 index 9da29d6d2c..b236c0e6ed 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoft365AppsForEnterprise.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoft365AppsForEnterprise.Tests.ps1 @@ -280,6 +280,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoftEdge.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoftEdge.Tests.ps1 index b69a4786ab..a24d998890 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoftEdge.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoftEdge.Tests.ps1 @@ -182,6 +182,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSettingCatalogASRRulesPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSettingCatalogASRRulesPolicyWindows10.Tests.ps1 index 62fc74e810..ca035ed297 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSettingCatalogASRRulesPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSettingCatalogASRRulesPolicyWindows10.Tests.ps1 @@ -248,6 +248,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWindowsUpdateForBusinessQualityUpdateProfileWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWindowsUpdateForBusinessQualityUpdateProfileWindows10.Tests.ps1 index e6538a3cc9..0046c3af04 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWindowsUpdateForBusinessQualityUpdateProfileWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWindowsUpdateForBusinessQualityUpdateProfileWindows10.Tests.ps1 @@ -49,6 +49,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false From 1bc963938464e44a5a8f5ad87b09e6b9a1e6f95e Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Mon, 16 Dec 2024 15:33:15 +0100 Subject: [PATCH 4/6] Fixing #5559 --- .../MSFT_AADAdministrativeUnit.psm1 | 3 +- .../Modules/M365DSCDRGUtil.psm1 | 446 ++++++++++++------ .../Microsoft365DSC/Modules/M365DSCUtil.psm1 | 2 +- 3 files changed, 294 insertions(+), 157 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 index 104f0d3693..6287779158 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADAdministrativeUnit/MSFT_AADAdministrativeUnit.psm1 @@ -1149,9 +1149,8 @@ function Export-TargetResource $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Members' -IsCIMArray $true $currentDSCBlock = $currentDSCBlock.Replace("`",`"`r`n", '') $currentDSCBlock = $currentDSCBlock.Replace(",`r`n", '').Replace("`");`r`n", ");`r`n") - $currentDSCBlock = $currentDSCBlock.Replace("Members = @(`"", 'Members = @(') - $currentDSCBlock = $currentDSCBlock.Replace("`$OrganizationName'", "' + `$OrganizationName") } + $dscContent += $currentDSCBlock Save-M365DSCPartialExport -Content $currentDSCBlock ` -FileName $Global:PartialExportFileName diff --git a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 index 9054d8b3fa..c260db44eb 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 @@ -8,7 +8,7 @@ function Get-StringFirstCharacterToUpper $Value ) - return $Value.Substring(0,1).ToUpper() + $Value.Substring(1,$Value.length-1) + return $Value.Substring(0, 1).ToUpper() + $Value.Substring(1, $Value.length - 1) } function Get-StringFirstCharacterToLower @@ -21,7 +21,7 @@ function Get-StringFirstCharacterToLower $Value ) - return $Value.Substring(0,1).ToLower() + $Value.Substring(1,$Value.length-1) + return $Value.Substring(0, 1).ToLower() + $Value.Substring(1, $Value.length - 1) } function Remove-M365DSCCimInstanceTrailingCharacterFromExport @@ -50,7 +50,7 @@ function Rename-M365DSCCimInstanceParameter [Parameter(Mandatory = $false)] [System.Collections.Hashtable] - $KeyMapping = @{'odataType' = '@odata.type'} + $KeyMapping = @{'odataType' = '@odata.type' } ) $result = $Properties @@ -429,7 +429,7 @@ function Get-M365DSCDRGComplexTypeToString $currentValue = $ComplexObject[$key] if ($currentValue.GetType().Name -eq 'String') { - $currentValue = $ComplexObject[$key].Replace("'", "''").Replace("�", "''") + $currentValue = $ComplexObject[$key].Replace("'", "''").Replace('�', "''") } $currentProperty += Get-M365DSCDRGSimpleObjectTypeToString -Key $key -Value $currentValue -Space ($indent) } @@ -452,7 +452,7 @@ function Get-M365DSCDRGComplexTypeToString } } $indent = '' - $indent = ' ' * ($IndentLevel -1) + $indent = ' ' * ($IndentLevel - 1) if ($key -in $ComplexTypeMapping.Name) { $currentProperty += "`r`n" @@ -467,7 +467,7 @@ function Get-M365DSCDRGComplexTypeToString #Indenting last parenthesis when the cim instance is an array if ($IndentLevel -eq 5) { - $indent = ' ' * ($IndentLevel -2) + $indent = ' ' * ($IndentLevel - 2) $currentProperty += $indent } @@ -479,8 +479,8 @@ function Get-M365DSCDRGComplexTypeToString if ($null -ne $currentProperty) { - $fancySingleQuotes = "[\u2019\u2018]" - $fancyDoubleQuotes = "[\u201C\u201D]" + $fancySingleQuotes = '[\u2019\u2018]' + $fancyDoubleQuotes = '[\u201C\u201D]' $currentProperty = [regex]::Replace($currentProperty, $fancySingleQuotes, "''") $currentProperty = [regex]::Replace($currentProperty, $fancyDoubleQuotes, '"') } @@ -517,11 +517,11 @@ function Get-M365DSCDRGSimpleObjectTypeToString { $key = 'odataType' } - $returnValue = $Space + $Key + " = '" + $Value + "'`r`n" + $returnValue = $Space + $Key + ' = "' + $Value + """`r`n" } '*.DateTime' { - $returnValue = $Space + $Key + " = '" + $Value + "'`r`n" + $returnValue = $Space + $Key + ' = "' + $Value + """`r`n" } '*[[\]]' { @@ -540,11 +540,11 @@ function Get-M365DSCDRGSimpleObjectTypeToString { '*.String' { - $returnValue += "$whitespace'$item'$newline" + $returnValue += "$whitespace""$item""$newline" } '*.DateTime' { - $returnValue += "$whitespace'$item'$newline" + $returnValue += "$whitespace""$item""$newline" } Default { @@ -574,9 +574,11 @@ function Compare-M365DSCComplexObject { [CmdletBinding()] [OutputType([System.Boolean])] - param( + param + ( [Parameter()] $Source, + [Parameter()] $Target ) @@ -660,12 +662,12 @@ function Compare-M365DSCComplexObject return $true } - if ($Source.GetType().FullName -like "*CimInstance") + if ($Source.GetType().FullName -like '*CimInstance') { $keys = @() - $Source.CimInstanceProperties | Foreach-Object { + $Source.CimInstanceProperties | ForEach-Object { if ($_.Name -notin @('PSComputerName', 'CimClass', 'CimInstanceProperties', 'CimSystemProperties') ` - -and $_.IsValueModified) + -and $_.IsValueModified) { $keys += $_.Name } @@ -676,18 +678,18 @@ function Compare-M365DSCComplexObject $keys = $Source.Keys | Where-Object -FilterScript { $_ -ne 'PSComputerName' } } - if ($Target.GetType().FullName -like "*CimInstance") + if ($Target.GetType().FullName -like '*CimInstance') { $targetKeys = @() - $Target.CimInstanceProperties | Foreach-Object { + $Target.CimInstanceProperties | ForEach-Object { if ($_.Name -notin @('PSComputerName', 'CimClass', 'CimInstanceProperties', 'CimSystemProperties') ` - -and $_.IsValueModified) + -and $_.IsValueModified) { $targetKeys += $_.Name } } } - elseif ($Target.GetType().FullName -like "*Hashtable") + elseif ($Target.GetType().FullName -like '*Hashtable') { $targetKeys = $Target.Keys | Where-Object -FilterScript { $_ -ne 'PSComputerName' } } @@ -824,7 +826,8 @@ function Convert-M365DSCDRGComplexTypeToHashtable { [CmdletBinding()] [OutputType([hashtable], [hashtable[]])] - param( + param + ( [Parameter(Mandatory = $true)] [AllowNull()] $ComplexObject, @@ -910,10 +913,12 @@ function ConvertFrom-IntunePolicyAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [Array] $Assignments, + [Parameter()] [System.Boolean] $IncludeDeviceFilter = $true @@ -950,7 +955,7 @@ function ConvertFrom-IntunePolicyAssignment $collectionId = $assignment.Target.AdditionalProperties.collectionId } - $hashAssignment.Add('dataType',$dataType) + $hashAssignment.Add('dataType', $dataType) if (-not [string]::IsNullOrEmpty($groupId)) { $hashAssignment.Add('groupId', $groupId) @@ -992,14 +997,15 @@ function ConvertFrom-IntunePolicyAssignment $assignmentResult += $hashAssignment } - return ,$assignmentResult + return , $assignmentResult } function ConvertTo-IntunePolicyAssignment { [CmdletBinding()] [OutputType([Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [AllowNull()] $Assignments, @@ -1011,13 +1017,13 @@ function ConvertTo-IntunePolicyAssignment if ($null -eq $Assignments) { - return ,@() + return , @() } $assignmentResult = @() foreach ($assignment in $Assignments) { - $target = @{"@odata.type" = $assignment.dataType} + $target = @{'@odata.type' = $assignment.dataType } if ($IncludeDeviceFilter) { if ($null -ne $assignment.DeviceAndAppManagementAssignmentFilterType) @@ -1045,14 +1051,14 @@ function ConvertTo-IntunePolicyAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.Count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1061,7 +1067,7 @@ function ConvertTo-IntunePolicyAssignment else { $message = "Skipping assignment for the group with Id {$($assignment.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } @@ -1075,21 +1081,23 @@ function ConvertTo-IntunePolicyAssignment if ($target) { - $assignmentResult += @{target = $target} + $assignmentResult += @{target = $target } } } - return ,$assignmentResult + return , $assignmentResult } function ConvertFrom-IntuneMobileAppAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [Array] $Assignments, + [Parameter()] [System.Boolean] $IncludeDeviceFilter = $true @@ -1169,14 +1177,15 @@ function ConvertFrom-IntuneMobileAppAssignment $assignmentResult += $hashAssignment } - return ,$assignmentResult + return , $assignmentResult } function ConvertTo-IntuneMobileAppAssignment { [CmdletBinding()] [OutputType([Hashtable[]])] - param ( + param + ( [Parameter(Mandatory = $true)] [AllowNull()] $Assignments, @@ -1188,14 +1197,14 @@ function ConvertTo-IntuneMobileAppAssignment if ($null -eq $Assignments) { - return ,@() + return , @() } $assignmentResult = @() foreach ($assignment in $Assignments) { $formattedAssignment = @{} - $target = @{"@odata.type" = $assignment.dataType} + $target = @{'@odata.type' = $assignment.dataType } if ($IncludeDeviceFilter) { if ($null -ne $assignment.DeviceAndAppManagementAssignmentFilterType) @@ -1218,14 +1227,14 @@ function ConvertTo-IntuneMobileAppAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.Count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($assignment.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1234,12 +1243,13 @@ function ConvertTo-IntuneMobileAppAssignment else { $message = "Skipping assignment for the group with Id {$($assignment.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } } - else { + else + { #Skipping assignment if group not found from either groupId or groupDisplayName $target.Add('groupId', $group.Id) } @@ -1252,18 +1262,22 @@ function ConvertTo-IntuneMobileAppAssignment $assignmentResult += $formattedAssignment } - return ,$assignmentResult + return , $assignmentResult } function Compare-M365DSCIntunePolicyAssignment { [CmdletBinding()] [OutputType([System.Boolean])] - param ( + param + ( [Parameter()] - [array]$Source, + [array] + $Source, + [Parameter()] - [array]$Target + [array] + $Target ) $testResult = $Source.Count -eq $Target.Count @@ -1282,7 +1296,7 @@ function Compare-M365DSCIntunePolicyAssignment if (-not $testResult) { Write-Verbose 'Group not found by groupId, checking if group exists by id' - $groupNotFound = $null -eq (Get-MgGroup -GroupId ($assignment.groupId) -ErrorAction SilentlyContinue) + $groupNotFound = $null -eq (Get-MgGroup -GroupId ($assignment.groupId) -ErrorAction SilentlyContinue) } if (-not $testResult -and $groupNotFound) { @@ -1295,9 +1309,9 @@ function Compare-M365DSCIntunePolicyAssignment { Write-Verbose 'Group found by groupId or groupDisplayName, checking filters' $isFilterTypeSpecified = ($null -ne $assignment.deviceAndAppManagementAssignmentFilterType -and $assignment.deviceAndAppManagementAssignmentFilterType -ne 'none') -or ` - ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterType -and $assignmentTarget.deviceAndAppManagementAssignmentFilterType -ne 'none') + ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterType -and $assignmentTarget.deviceAndAppManagementAssignmentFilterType -ne 'none') $isFilterIdSpecified = ($null -ne $assignment.deviceAndAppManagementAssignmentFilterId -and $assignment.deviceAndAppManagementAssignmentFilterId -ne '00000000-0000-0000-0000-000000000000') -or ` - ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterId -and $assignmentTarget.deviceAndAppManagementAssignmentFilterId -ne '00000000-0000-0000-0000-000000000000') + ($null -ne $assignmentTarget.deviceAndAppManagementAssignmentFilterId -and $assignmentTarget.deviceAndAppManagementAssignmentFilterId -ne '00000000-0000-0000-0000-000000000000') if ($isFilterTypeSpecified) { Write-Verbose 'FilterType specified, checking filterType' @@ -1320,7 +1334,10 @@ function Compare-M365DSCIntunePolicyAssignment { $testResult = $null -ne ($Target | Where-Object -FilterScript { $_.dataType -eq $assignment.DataType }) } - if (-not $testResult) { break } + if (-not $testResult) + { + break + } } } @@ -1331,7 +1348,8 @@ function Update-DeviceConfigurationPolicyAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param ( + param + ( [Parameter(Mandatory = $true)] [System.String] $DeviceConfigurationPolicyId, @@ -1345,7 +1363,7 @@ function Update-DeviceConfigurationPolicyAssignment $Repository = 'deviceManagement/configurationPolicies', [Parameter()] - [ValidateSet('v1.0','beta')] + [ValidateSet('v1.0', 'beta')] [System.String] $APIVersion = 'beta', @@ -1366,10 +1384,10 @@ function Update-DeviceConfigurationPolicyAssignment $target = $target.target } - $formattedTarget = @{"@odata.type" = $target.dataType} - if(-not $formattedTarget."@odata.type" -and $target."@odata.type") + $formattedTarget = @{'@odata.type' = $target.dataType } + if (-not $formattedTarget.'@odata.type' -and $target.'@odata.type') { - $formattedTarget."@odata.type" = $target."@odata.type" + $formattedTarget.'@odata.type' = $target.'@odata.type' } if ($target.groupId) { @@ -1382,14 +1400,14 @@ function Update-DeviceConfigurationPolicyAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1398,7 +1416,7 @@ function Update-DeviceConfigurationPolicyAssignment else { $message = "Skipping assignment for the group with Id {$($target.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } @@ -1406,25 +1424,25 @@ function Update-DeviceConfigurationPolicyAssignment #Skipping assignment if group not found from either groupId or groupDisplayName if ($null -ne $group) { - $formattedTarget.Add('groupId',$group.Id) + $formattedTarget.Add('groupId', $group.Id) } } if ($target.collectionId) { - $formattedTarget.Add('collectionId',$target.collectionId) + $formattedTarget.Add('collectionId', $target.collectionId) } if ($target.deviceAndAppManagementAssignmentFilterType) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType',$target.deviceAndAppManagementAssignmentFilterType) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType', $target.deviceAndAppManagementAssignmentFilterType) } if ($target.deviceAndAppManagementAssignmentFilterId) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId',$target.deviceAndAppManagementAssignmentFilterId) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId', $target.deviceAndAppManagementAssignmentFilterId) } - $deviceManagementPolicyAssignments += @{'target' = $formattedTarget} + $deviceManagementPolicyAssignments += @{'target' = $formattedTarget } } - $body = @{$RootIdentifier = $deviceManagementPolicyAssignments} | ConvertTo-Json -Depth 20 + $body = @{$RootIdentifier = $deviceManagementPolicyAssignments } | ConvertTo-Json -Depth 20 Write-Verbose -Message $body Invoke-MgGraphRequest -Method POST -Uri $Uri -Body $body -ErrorAction Stop @@ -1445,7 +1463,8 @@ function Update-DeviceAppManagementPolicyAssignment { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param ( + param + ( [Parameter(Mandatory = $true)] [System.String] $AppManagementPolicyId, @@ -1459,7 +1478,7 @@ function Update-DeviceAppManagementPolicyAssignment $Repository = 'deviceAppManagement/mobileApps', [Parameter()] - [ValidateSet('v1.0','beta')] + [ValidateSet('v1.0', 'beta')] [System.String] $APIVersion = 'beta', @@ -1477,7 +1496,7 @@ function Update-DeviceAppManagementPolicyAssignment { $formattedAssignment = @{ '@odata.type' = '#microsoft.graph.mobileAppAssignment' - intent = $assignment.intent + intent = $assignment.intent } if ($assigment.settings) { @@ -1489,10 +1508,10 @@ function Update-DeviceAppManagementPolicyAssignment $target = $assignment.target } - $formattedTarget = @{"@odata.type" = $target.dataType} - if(-not $formattedTarget."@odata.type" -and $target."@odata.type") + $formattedTarget = @{'@odata.type' = $target.dataType } + if (-not $formattedTarget.'@odata.type' -and $target.'@odata.type') { - $formattedTarget."@odata.type" = $target."@odata.type" + $formattedTarget.'@odata.type' = $target.'@odata.type' } if ($target.groupId) { @@ -1505,14 +1524,14 @@ function Update-DeviceAppManagementPolicyAssignment if ($null -eq $group) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or groupDisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or groupDisplayName.' Write-Warning -Message $message $target = $null } if ($group -and $group.count -gt 1) { $message = "Skipping assignment for the group with DisplayName {$($target.groupDisplayName)} as it is not unique in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $group = $null $target = $null @@ -1521,7 +1540,7 @@ function Update-DeviceAppManagementPolicyAssignment else { $message = "Skipping assignment for the group with Id {$($target.groupId)} as it could not be found in the directory.`r`n" - $message += "Please update your DSC resource extract with the correct groupId or a unique group DisplayName." + $message += 'Please update your DSC resource extract with the correct groupId or a unique group DisplayName.' Write-Warning -Message $message $target = $null } @@ -1529,22 +1548,22 @@ function Update-DeviceAppManagementPolicyAssignment #Skipping assignment if group not found from either groupId or groupDisplayName if ($null -ne $group) { - $formattedTarget.Add('groupId',$group.Id) + $formattedTarget.Add('groupId', $group.Id) } } if ($target.deviceAndAppManagementAssignmentFilterType) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType',$target.deviceAndAppManagementAssignmentFilterType) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterType', $target.deviceAndAppManagementAssignmentFilterType) } if ($target.deviceAndAppManagementAssignmentFilterId) { - $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId',$target.deviceAndAppManagementAssignmentFilterId) + $formattedTarget.Add('deviceAndAppManagementAssignmentFilterId', $target.deviceAndAppManagementAssignmentFilterId) } $formattedAssignment.Add('target', $formattedTarget) $appManagementPolicyAssignments += $formattedAssignment } - $body = @{$RootIdentifier = $appManagementPolicyAssignments} | ConvertTo-Json -Depth 20 + $body = @{$RootIdentifier = $appManagementPolicyAssignments } | ConvertTo-Json -Depth 20 Write-Verbose -Message $body Invoke-MgGraphRequest -Method POST -Uri $Uri -Body $body -ErrorAction Stop @@ -1565,7 +1584,8 @@ function Get-OmaSettingPlainTextValue { [CmdletBinding()] [OutputType([System.String])] - Param( + param + ( [Parameter(Mandatory = $true)] [System.String] $SecretReferenceValueId, @@ -1582,7 +1602,7 @@ function Get-OmaSettingPlainTextValue e.g. PolicyId for SecretReferenceValueId '35ea58ec-2a79-471d-8eea-7e28e6cd2722_bdf6c690-05fb-4d02-835d-5a7406c35d58_abe32712-2255-445f-a35e-0c6f143d82ca' is 'bdf6c690-05fb-4d02-835d-5a7406c35d58' #> - $SplitSecretReferenceValueId = $SecretReferenceValueId.Split("_") + $SplitSecretReferenceValueId = $SecretReferenceValueId.Split('_') if ($SplitSecretReferenceValueId.Count -eq 3) { $PolicyId = $SplitSecretReferenceValueId[1] @@ -1606,7 +1626,7 @@ function Get-OmaSettingPlainTextValue } catch { - $Message = "Error decrypting OmaSetting with SecretReferenceValueId {0}:" -f $SecretReferenceValueId + $Message = 'Error decrypting OmaSetting with SecretReferenceValueId {0}:' -f $SecretReferenceValueId New-M365DSCLogEntry -Message $Message ` -Exception $_ ` -Source $($MyInvocation.MyCommand.Source) ` @@ -1619,7 +1639,9 @@ function Get-OmaSettingPlainTextValue if (![String]::IsNullOrEmpty($Result.Value)) { return $Result.Value - } else { + } + else + { return $null } } @@ -1628,7 +1650,8 @@ function Get-IntuneSettingCatalogPolicySetting { [CmdletBinding()] [OutputType([System.Array])] - param ( + param + ( [Parameter(Mandatory = $true)] [System.Collections.Hashtable] $DSCParams, @@ -1672,11 +1695,11 @@ function Get-IntuneSettingCatalogPolicySetting if ($ContainsDeviceAndUserSettings) { - $deviceSettingTemplates = $SettingTemplates | Where-object -FilterScript { - $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith("device_") + $deviceSettingTemplates = $SettingTemplates | Where-Object -FilterScript { + $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith('device_') } - $userSettingTemplates = $SettingTemplates | Where-object -FilterScript { - $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith("user_") + $userSettingTemplates = $SettingTemplates | Where-Object -FilterScript { + $_.SettingInstanceTemplate.SettingDefinitionId.StartsWith('user_') } $deviceDscParams = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $DSCParams.DeviceSettings -SingleLevel -ExcludeUnchangedProperties $userDscParams = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $DSCParams.UserSettings -SingleLevel -ExcludeUnchangedProperties @@ -1684,7 +1707,7 @@ function Get-IntuneSettingCatalogPolicySetting $combinedSettingInstances += Get-IntuneSettingCatalogPolicySetting -DSCParams $deviceDscParams -SettingTemplates $deviceSettingTemplates $combinedSettingInstances += Get-IntuneSettingCatalogPolicySetting -DSCParams $userDscParams -SettingTemplates $userSettingTemplates - return ,$combinedSettingInstances + return , $combinedSettingInstances } } @@ -1760,14 +1783,15 @@ function Get-IntuneSettingCatalogPolicySetting } } - return ,$settingInstances + return , $settingInstances } function Get-IntuneSettingCatalogPolicySettingInstanceValue { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param( + param + ( [Parameter(Mandatory = 'true')] [System.Collections.Hashtable] $DSCParams, @@ -1829,12 +1853,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $instanceCount = 1 if (($Level -gt 1 -and $groupSettingCollectionDefinitionChildren.Count -gt 1) -or - ($Level -eq 1 -and $SettingDefinition.AdditionalProperties.maximumCount -gt 1 -and $groupSettingCollectionDefinitionChildren.Count -ge 1 -and $groupSettingCollectionDefinitionChildren.AdditionalProperties.'@odata.type' -notcontains "#microsoft.graph.deviceManagementConfigurationSettingGroupCollectionDefinition")) + ($Level -eq 1 -and $SettingDefinition.AdditionalProperties.maximumCount -gt 1 -and $groupSettingCollectionDefinitionChildren.Count -ge 1 -and $groupSettingCollectionDefinitionChildren.AdditionalProperties.'@odata.type' -notcontains '#microsoft.graph.deviceManagementConfigurationSettingGroupCollectionDefinition')) { $SettingInstanceName += Get-SettingsCatalogSettingName -SettingDefinition $SettingDefinition -AllSettingDefinitions $AllSettingDefinitions - $settingInstanceNameAlternate = $SettingInstanceName + "_Intune" + $settingInstanceNameAlternate = $SettingInstanceName + '_Intune' $cimDSCParams = @() - $cimDSCParamsName = "" + $cimDSCParamsName = '' $DSCParams.GetEnumerator() | ForEach-Object { if ($_.Value.CimClass.CimClassName -eq $SettingInstanceName -or $_.Value.CimClass.CimClassName -like "$settingInstanceNameAlternate*") { @@ -1845,10 +1869,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $newDSCParams = @{ $cimDSCParamsName = @() } - foreach ($instance in $cimDSCParams) { + foreach ($instance in $cimDSCParams) + { $newInstanceDSCParams = @{} # Preserve CIM instances when converting to hashtable - foreach ($property in $instance.CimInstanceProperties) { + foreach ($property in $instance.CimInstanceProperties) + { if ($property.IsValueModified) { $newInstanceDSCParams.Add($property.Name, $property.Value) @@ -1858,7 +1884,14 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } $instanceCount = $newDSCParams.$cimDSCParamsName.Count $DSCParams = @{ - $cimDSCParamsName = if ($instanceCount -eq 1) { $newDSCParams.$cimDSCParamsName[0] } else { $newDSCParams.$cimDSCParamsName } + $cimDSCParamsName = if ($instanceCount -eq 1) + { + $newDSCParams.$cimDSCParamsName[0] + } + else + { + $newDSCParams.$cimDSCParamsName + } } $AllSettingDefinitions = $groupSettingCollectionDefinitionChildren + $SettingDefinition } @@ -1866,16 +1899,25 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue for ($i = 0; $i -lt $instanceCount; $i++) { $groupSettingCollectionValueChildren = @() - $currentDSCParams = if ($instanceCount -eq 1) { - if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) { + $currentDSCParams = if ($instanceCount -eq 1) + { + if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) + { $DSCParams.$cimDSCParamsName - } else { + } + else + { $DSCParams } - } else { - if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) { + } + else + { + if (-not [System.String]::IsNullOrEmpty($cimDSCParamsName)) + { $DSCParams.$cimDSCParamsName[$i] - } else { + } + else + { $DSCParams[$i] } } @@ -1891,9 +1933,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $childSettingValueName = $childSettingType.Replace('#microsoft.graph.deviceManagementConfiguration', '').Replace('Instance', 'Value') $childSettingValueType = "#microsoft.graph.deviceManagementConfiguration$($childSettingValueName)" $childSettingValueName = $childSettingValueName.Substring(0, 1).ToLower() + $childSettingValueName.Substring(1, $childSettingValueName.length - 1 ) - $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) { + $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) + { $SettingInstanceTemplate.AdditionalProperties.groupSettingCollectionValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } | Select-Object -First 1 - } else { + } + else + { $SettingInstanceTemplate.groupSettingCollectionValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } | Select-Object -First 1 } @@ -1929,13 +1974,13 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } $childSettingValueItem.Add('@odata.type', $childSettingType) $childSettingValueInner.children += @{ - '@odata.type' = '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance' + '@odata.type' = '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance' groupSettingCollectionValue = @( @{ children = $childSettingValueItem.children } ) - settingDefinitionId = $childDefinition.Id + settingDefinitionId = $childDefinition.Id } <# GroupSettingCollection do not have a setting instance template reference if (-not [string]::IsNullOrEmpty($childSettingInstanceTemplate.settingInstanceTemplateId)) @@ -1976,7 +2021,8 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } } - if ($groupSettingCollectionDefinitionChildren.Count -gt 0 -and $groupSettingCollectionValue.Count -gt 0) { + if ($groupSettingCollectionDefinitionChildren.Count -gt 0 -and $groupSettingCollectionValue.Count -gt 0) + { $settingValuesToReturn.Add('groupSettingCollectionValue', @($groupSettingCollectionValue)) } } @@ -2002,9 +2048,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue $childSettingValueName = $childSettingType.Replace('#microsoft.graph.deviceManagementConfiguration', '').Replace('Instance', 'Value') $childSettingValueType = "#microsoft.graph.deviceManagementConfiguration$($childSettingValueName)" $childSettingValueName = $childSettingValueName.Substring(0, 1).ToLower() + $childSettingValueName.Substring(1, $childSettingValueName.Length - 1 ) - $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) { + $childSettingInstanceTemplate = if ($null -ne $SettingInstanceTemplate.AdditionalProperties) + { $SettingInstanceTemplate.AdditionalProperties.choiceSettingValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } - } else { + } + else + { $SettingInstanceTemplate.choiceSettingValueTemplate.children | Where-Object { $_.settingDefinitionId -eq $childDefinition.Id } } $childSettingValueTemplateId = $childSettingInstanceTemplate."$($childSettingValueName)Template" | Where-Object { @@ -2042,9 +2091,12 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue } # Depending on the children count, we add the children to the choice setting or an empty array since the children property is required - if ($choiceSettingDefinitionChildren.Count -gt 0) { + if ($choiceSettingDefinitionChildren.Count -gt 0) + { $choiceSettingValue.Add('children', $choiceSettingValueChildren) - } else { + } + else + { $choiceSettingValue.Add('children', @()) } @@ -2093,8 +2145,8 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue foreach ($value in $values) { $choiceSettingValueCollection += @{ - value = $value - children = @() + value = $value + children = @() '@odata.type' = '#microsoft.graph.deviceManagementConfigurationChoiceSettingValue' } } @@ -2127,7 +2179,8 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue '@odata.type' = $SettingValueType } } - if ($settingValueCollection.Count -gt 0) { + if ($settingValueCollection.Count -gt 0) + { $settingValuesToReturn.Add($SettingValueName, $settingValueCollection) } } @@ -2154,7 +2207,7 @@ function Get-IntuneSettingCatalogPolicySettingInstanceValue { if ($SettingDefinition.AdditionalProperties.valueDefinition.isSecret) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationSecretSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationSecretSettingValue' $settingValue.Add('valueState', 'NotEncrypted') } $settingValue.Add('@odata.type', $SettingValueType) @@ -2178,7 +2231,7 @@ function Get-IntuneSettingCatalogPolicySettingDSCValue ( [Parameter()] [System.String] - $SettingValueType = "", + $SettingValueType = '', [Parameter()] $SettingDefinition, @@ -2200,37 +2253,44 @@ function Get-IntuneSettingCatalogPolicySettingDSCValue } $isArray = $false - if ($SettingValueType -like "*Simple*") + if ($SettingValueType -like '*Simple*') { if ($DSCParams[$key] -is [System.String]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationStringSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationStringSettingValue' } elseif ($DSCParams[$key] -is [System.Int32]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationIntegerSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue' } elseif ($DSCParams[$key] -is [System.String[]]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationStringSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationStringSettingValue' $isArray = $true } elseif ($DSCParams[$key] -is [System.Int32[]]) { - $SettingValueType = "#microsoft.graph.deviceManagementConfigurationIntegerSettingValue" + $SettingValueType = '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue' $isArray = $true } } - if ($SettingValueType -like "*Simple*" -or $SettingValueType -in @("#microsoft.graph.deviceManagementConfigurationIntegerSettingValue", "#microsoft.graph.deviceManagementConfigurationStringSettingValue")) + if ($SettingValueType -like '*Simple*' -or $SettingValueType -in @('#microsoft.graph.deviceManagementConfigurationIntegerSettingValue', '#microsoft.graph.deviceManagementConfigurationStringSettingValue')) { return @{ SettingDefinition = $SettingDefinition - SettingValueType = $SettingValueType - Value = if ($isArray) { ,$DSCParams[$key] } else { $DSCParams[$key] } + SettingValueType = $SettingValueType + Value = if ($isArray) + { + , $DSCParams[$key] + } + else + { + $DSCParams[$key] + } } } - elseif ($SettingValueType -like "*ChoiceSettingCollection*") + elseif ($SettingValueType -like '*ChoiceSettingCollection*') { $values = @() foreach ($value in $DSCParams[$key]) @@ -2246,8 +2306,8 @@ function Get-IntuneSettingCatalogPolicySettingDSCValue { return @{ SettingDefinition = $SettingDefinition - SettingValueType = $SettingValueType - Value = "$($SettingDefinition.Id)_$($DSCParams[$key])" + SettingValueType = $SettingValueType + Value = "$($SettingDefinition.Id)_$($DSCParams[$key])" } } } @@ -2256,7 +2316,8 @@ function Export-IntuneSettingCatalogPolicySettings { [CmdletBinding()] [OutputType([System.Collections.Hashtable])] - param( + param + ( [Parameter( Mandatory = $true, ParameterSetName = 'Start' @@ -2307,7 +2368,7 @@ function Export-IntuneSettingCatalogPolicySettings { $deviceSettingsReturnHashtable = @{} $deviceSettings = $Settings | Where-Object -FilterScript { - $_.SettingInstance.settingDefinitionId.StartsWith("device_") + $_.SettingInstance.settingDefinitionId.StartsWith('device_') } if ($AllSettingDefinitions.Count -eq 0) { @@ -2316,7 +2377,7 @@ function Export-IntuneSettingCatalogPolicySettings else { $allDeviceSettingDefinitions = $AllSettingDefinitions | Where-Object -FilterScript { - $_.Id.StartsWith("device_") + $_.Id.StartsWith('device_') } } foreach ($setting in $deviceSettings) @@ -2326,7 +2387,7 @@ function Export-IntuneSettingCatalogPolicySettings $userSettingsReturnHashtable = @{} $userSettings = $Settings | Where-Object -FilterScript { - $_.SettingInstance.settingDefinitionId.StartsWith("user_") + $_.SettingInstance.settingDefinitionId.StartsWith('user_') } if ($AllSettingDefinitions.Count -eq 0) { @@ -2335,7 +2396,7 @@ function Export-IntuneSettingCatalogPolicySettings else { $allUserSettingDefinitions = $AllSettingDefinitions | Where-Object -FilterScript { - $_.Id.StartsWith("user_") + $_.Id.StartsWith('user_') } } @@ -2370,12 +2431,26 @@ function Export-IntuneSettingCatalogPolicySettings $addToParameters = $true $settingDefinition = $SettingDefinitions | Where-Object -FilterScript { $_.Id -eq $SettingInstance.settingDefinitionId } $settingName = Get-SettingsCatalogSettingName -SettingDefinition $settingDefinition -AllSettingDefinitions $AllSettingDefinitions - $odataType = if ($IsRoot) { $SettingInstance.AdditionalProperties.'@odata.type' } else { $SettingInstance.'@odata.type' } + $odataType = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.'@odata.type' + } + else + { + $SettingInstance.'@odata.type' + } switch ($odataType) { '#microsoft.graph.deviceManagementConfigurationSimpleSettingInstance' { - $simpleSetting = if ($IsRoot) { $SettingInstance.AdditionalProperties.simpleSettingValue } else { $SettingInstance.simpleSettingValue } + $simpleSetting = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.simpleSettingValue + } + else + { + $SettingInstance.simpleSettingValue + } if ($simpleSetting.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue') { $settingValue = [int]$simpleSetting.value @@ -2387,9 +2462,23 @@ function Export-IntuneSettingCatalogPolicySettings } '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance' { - $settingValue = if ($IsRoot) { $SettingInstance.AdditionalProperties.choiceSettingValue.value } else { $SettingInstance.choiceSettingValue.value } + $settingValue = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.choiceSettingValue.value + } + else + { + $SettingInstance.choiceSettingValue.value + } $settingValue = $settingValue.Split('_') | Select-Object -Last 1 - $childSettings = if ($IsRoot) { $SettingInstance.AdditionalProperties.choiceSettingValue.children } else { $SettingInstance.choiceSettingValue.children } + $childSettings = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.choiceSettingValue.children + } + else + { + $SettingInstance.choiceSettingValue.children + } foreach ($childSetting in $childSettings) { Export-IntuneSettingCatalogPolicySettings -SettingInstance $childSetting -SettingDefinitions $SettingDefinitions -ReturnHashtable $ReturnHashtable -AllSettingDefinitions $AllSettingDefinitions @@ -2398,7 +2487,14 @@ function Export-IntuneSettingCatalogPolicySettings '#microsoft.graph.deviceManagementConfigurationChoiceSettingCollectionInstance' { $values = @() - $childValues = if ($IsRoot) { $SettingInstance.AdditionalProperties.choiceSettingCollectionValue.value } else { $SettingInstance.choiceSettingCollectionValue.value } + $childValues = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.choiceSettingCollectionValue.value + } + else + { + $SettingInstance.choiceSettingCollectionValue.value + } foreach ($value in $childValues) { $values += $value.Split('_') | Select-Object -Last 1 @@ -2407,7 +2503,14 @@ function Export-IntuneSettingCatalogPolicySettings } '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance' { - $groupSettingCollectionValue = if ($IsRoot) { $SettingInstance.AdditionalProperties.groupSettingCollectionValue } else { $SettingInstance.groupSettingCollectionValue } + $groupSettingCollectionValue = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.groupSettingCollectionValue + } + else + { + $SettingInstance.groupSettingCollectionValue + } [array]$childSettingDefinitions = $SettingDefinitions | Where-Object -FilterScript { $settingDefinition.AdditionalProperties.childIds -contains $_.Id } @@ -2457,7 +2560,14 @@ function Export-IntuneSettingCatalogPolicySettings } $childValue += $childHashtable } - $settingValue = if ($null -eq $childValue) { $childHashtable } else { ,$childValue } + $settingValue = if ($null -eq $childValue) + { + $childHashtable + } + else + { + , $childValue + } } else { @@ -2473,7 +2583,14 @@ function Export-IntuneSettingCatalogPolicySettings '#microsoft.graph.deviceManagementConfigurationSimpleSettingCollectionInstance' { $values = @() - $childValues = if ($IsRoot) { $SettingInstance.AdditionalProperties.simpleSettingCollectionValue } else { $SettingInstance.simpleSettingCollectionValue } + $childValues = if ($IsRoot) + { + $SettingInstance.AdditionalProperties.simpleSettingCollectionValue + } + else + { + $SettingInstance.simpleSettingCollectionValue + } foreach ($value in $childValues) { if ($value.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue') @@ -2577,11 +2694,15 @@ function Update-IntuneDeviceConfigurationPolicy } } -function Get-ComplexFunctionsFromFilterQuery { +function Get-ComplexFunctionsFromFilterQuery +{ [CmdletBinding()] [OutputType([System.Array])] - param ( - [string]$FilterQuery + param + ( + [Parameter()] + [System.String] + $FilterQuery ) $complexFunctionsRegex = "startswith\((.*?),\s*'(.*?)'\)|endswith\((.*?),\s*'(.*?)'\)|contains\((.*?),\s*'(.*?)'\)" @@ -2592,38 +2713,55 @@ function Get-ComplexFunctionsFromFilterQuery { return $complexFunctions } -function Remove-ComplexFunctionsFromFilterQuery { +function Remove-ComplexFunctionsFromFilterQuery +{ [CmdletBinding()] [OutputType([System.String])] - param ( - [string]$FilterQuery + param + ( + [Parameter()] + [System.String] + $FilterQuery ) $complexFunctionsRegex = "startswith\((.*?),\s*'(.*?)'\)|endswith\((.*?),\s*'(.*?)'\)|contains\((.*?),\s*'(.*?)'\)" - $basicFilterQuery = [regex]::Replace($FilterQuery, $complexFunctionsRegex, "").Trim() - $basicFilterQuery = $basicFilterQuery -replace "^and\s","" -replace "\sand$","" -replace "\sand\s+", " and " -replace "\sor\s+", " or " + $basicFilterQuery = [regex]::Replace($FilterQuery, $complexFunctionsRegex, '').Trim() + $basicFilterQuery = $basicFilterQuery -replace '^and\s', '' -replace '\sand$', '' -replace '\sand\s+', ' and ' -replace '\sor\s+', ' or ' return $basicFilterQuery } -function Find-GraphDataUsingComplexFunctions { +function Find-GraphDataUsingComplexFunctions +{ [CmdletBinding()] [OutputType([System.Array])] - param ( - [array]$Policies, - [array]$ComplexFunctions + param + ( + [Parameter()] + [array] + $Policies, + + [Parameter()] + [array] + $ComplexFunctions ) - foreach ($function in $ComplexFunctions) { - if ($function -match "startswith\((.*?),\s*'(.*?)'") { + foreach ($function in $ComplexFunctions) + { + if ($function -match "startswith\((.*?),\s*'(.*?)'") + { $property = $matches[1] $value = $matches[2] $Policies = $Policies | Where-Object { $_.$property -like "$value*" } - } elseif ($function -match "endswith\((.*?),\s*'(.*?)'") { + } + elseif ($function -match "endswith\((.*?),\s*'(.*?)'") + { $property = $matches[1] $value = $matches[2] $Policies = $Policies | Where-Object { $_.$property -like "*$value" } - } elseif ($function -match "contains\((.*?),\s*'(.*?)'") { + } + elseif ($function -match "contains\((.*?),\s*'(.*?)'") + { $property = $matches[1] $value = $matches[2] $Policies = $Policies | Where-Object { $_.$property -like "*$value*" } diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index f2ad02b566..d9c1e821d5 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -3755,7 +3755,7 @@ function Get-M365DSCExportContentForResource if ($ConnectionMode -like 'ServicePrincipal*' -or ` $ConnectionMode -eq 'ManagedIdentity') { - $OrganizationName = $Results.TenantId + $OrganizationName = $TenantId } elseif ($null -ne $Credential.UserName) { From dd44a99311ce7bb258de51cec44d4d8e042c4b5c Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Mon, 16 Dec 2024 16:29:18 +0100 Subject: [PATCH 5/6] Fixed unit test and supressed Warnings during unit tests --- CHANGELOG.md | 2 ++ Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 | 2 +- .../Microsoft365DSC.AADVerifiedIdAuthority.Tests.ps1 | 2 ++ .../Microsoft365DSC.AADVerifiedIdAuthorityContract.Tests.ps1 | 2 ++ .../Microsoft365DSC.EXODataAtRestEncryptionPolicy.Tests.ps1 | 2 ++ .../Microsoft365DSC/Microsoft365DSC.EXOMigration.Tests.ps1 | 4 ++++ .../Microsoft365DSC.EXOTransportRule.Tests.ps1 | 2 ++ ...tectionLocalAdministratorPasswordSolutionPolicy.Tests.ps1 | 2 ++ ...AccountProtectionLocalUserGroupMembershipPolicy.Tests.ps1 | 2 ++ .../Microsoft365DSC.IntuneAccountProtectionPolicy.Tests.ps1 | 2 ++ ...ft365DSC.IntuneAccountProtectionPolicyWindows10.Tests.ps1 | 2 ++ ...soft365DSC.IntuneAntivirusExclusionsPolicyLinux.Tests.ps1 | 2 ++ ...soft365DSC.IntuneAntivirusExclusionsPolicyMacOS.Tests.ps1 | 2 ++ .../Microsoft365DSC.IntuneAntivirusPolicyLinux.Tests.ps1 | 5 ++++- .../Microsoft365DSC.IntuneAntivirusPolicyMacOS.Tests.ps1 | 3 +++ ...SC.IntuneAntivirusPolicyWindows10SettingCatalog.Tests.ps1 | 3 +++ ...DSC.IntuneAppAndBrowserIsolationPolicyWindows10.Tests.ps1 | 3 +++ ...eAppAndBrowserIsolationPolicyWindows10ConfigMgr.Tests.ps1 | 3 +++ ...t365DSC.IntuneApplicationControlPolicyWindows10.Tests.ps1 | 3 +++ ...eConfigurationIdentityProtectionPolicyWindows10.Tests.ps1 | 3 +++ ...rosoft365DSC.IntuneDeviceControlPolicyWindows10.Tests.ps1 | 3 +++ .../Microsoft365DSC.IntuneDeviceRemediation.Tests.ps1 | 3 +++ ...ft365DSC.IntuneDiskEncryptionPDEPolicyWindows10.Tests.ps1 | 3 +++ .../Microsoft365DSC.IntuneDiskEncryptionWindows10.Tests.ps1 | 3 +++ ...C.IntuneEndpointDetectionAndResponsePolicyLinux.Tests.ps1 | 3 +++ ...C.IntuneEndpointDetectionAndResponsePolicyMacOS.Tests.ps1 | 3 +++ ...tuneEndpointDetectionAndResponsePolicyWindows10.Tests.ps1 | 3 +++ ...eExploitProtectionPolicyWindows10SettingCatalog.Tests.ps1 | 3 +++ .../Microsoft365DSC.IntuneFirewallPolicyWindows10.Tests.ps1 | 3 +++ ...365DSC.IntuneFirewallRulesHyperVPolicyWindows10.Tests.ps1 | 3 +++ ...rosoft365DSC.IntuneFirewallRulesPolicyWindows10.Tests.ps1 | 3 +++ ...DSC.IntuneFirewallRulesPolicyWindows10ConfigMgr.Tests.ps1 | 3 +++ .../Microsoft365DSC.IntunePolicySets.Tests.ps1 | 3 +++ ...65DSC.IntuneSecurityBaselineDefenderForEndpoint.Tests.ps1 | 3 +++ ...neSecurityBaselineMicrosoft365AppsForEnterprise.Tests.ps1 | 3 +++ ...osoft365DSC.IntuneSecurityBaselineMicrosoftEdge.Tests.ps1 | 3 +++ ...DSC.IntuneSettingCatalogASRRulesPolicyWindows10.Tests.ps1 | 3 +++ ...sUpdateForBusinessQualityUpdateProfileWindows10.Tests.ps1 | 3 +++ 38 files changed, 103 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfa0cce035..36244616b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * FIXES [#5550](https://github.com/microsoft/Microsoft365DSC/issues/5550) * MISC * Fixed the Fabric web request to use basic parsing. + * Fixed an issue where the export does not convert tenant name into + generic $OrganizationName variable correctly. * M365DSCUtil * Update `Get-M365DSCWorkloadsListFromResourceNames` function for more input types. FIXES [#5525](https://github.com/microsoft/Microsoft365DSC/issues/5525) diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index d9c1e821d5..7681c9f081 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -3935,7 +3935,7 @@ function Get-M365DSCExportContentForResource } } - if ($partialContent.ToLower().IndexOf($OrganizationName.ToLower()) -gt 0) + if ($null -ne $OrganizationName -and $partialContent.ToLower().IndexOf($OrganizationName.ToLower()) -gt 0) { $partialContent = $partialContent -ireplace [regex]::Escape($OrganizationName + ':'), "`$($OrganizationName):" $partialContent = $partialContent -ireplace [regex]::Escape($OrganizationName), "`$OrganizationName" diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthority.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthority.Tests.ps1 index 0c01f44993..3bcd89c608 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthority.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthority.Tests.ps1 @@ -46,6 +46,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthorityContract.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthorityContract.Tests.ps1 index 6e058fd01b..24c255617b 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthorityContract.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADVerifiedIdAuthorityContract.Tests.ps1 @@ -46,6 +46,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXODataAtRestEncryptionPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXODataAtRestEncryptionPolicy.Tests.ps1 index 9969ea0126..17e6ab26a5 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXODataAtRestEncryptionPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXODataAtRestEncryptionPolicy.Tests.ps1 @@ -46,6 +46,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMigration.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMigration.Tests.ps1 index 3e7e4c3adb..57d951b08d 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMigration.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOMigration.Tests.ps1 @@ -56,6 +56,10 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + + Mock -CommandName Write-Verbose -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOTransportRule.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOTransportRule.Tests.ps1 index 2e501dab08..28e4fbcc8b 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOTransportRule.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.EXOTransportRule.Tests.ps1 @@ -41,6 +41,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.Tests.ps1 index 16a96f1d0b..5a22bdb211 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.Tests.ps1 @@ -114,6 +114,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalUserGroupMembershipPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalUserGroupMembershipPolicy.Tests.ps1 index 50196c8309..10c45c4a9b 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalUserGroupMembershipPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionLocalUserGroupMembershipPolicy.Tests.ps1 @@ -143,6 +143,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicy.Tests.ps1 index 2f60f5a80c..388aa05044 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicy.Tests.ps1 @@ -105,6 +105,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicyWindows10.Tests.ps1 index 2f1b585b8f..02ccabf07d 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAccountProtectionPolicyWindows10.Tests.ps1 @@ -188,6 +188,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyLinux.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyLinux.Tests.ps1 index f29d2fd298..5e742d4a62 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyLinux.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyLinux.Tests.ps1 @@ -201,6 +201,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyMacOS.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyMacOS.Tests.ps1 index 2abd4aed6e..ce067ed413 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyMacOS.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusExclusionsPolicyMacOS.Tests.ps1 @@ -199,6 +199,8 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyLinux.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyLinux.Tests.ps1 index 48f93a3eb4..98968fa586 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyLinux.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyLinux.Tests.ps1 @@ -511,6 +511,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false @@ -737,7 +740,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Credential = $Credential } } - + It 'Should Reverse Engineer resource from the Export method' { $result = Export-TargetResource @testParams $result | Should -Not -BeNullOrEmpty diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyMacOS.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyMacOS.Tests.ps1 index e2dbb85c46..1ec550f0f3 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyMacOS.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyMacOS.Tests.ps1 @@ -498,6 +498,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyWindows10SettingCatalog.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyWindows10SettingCatalog.Tests.ps1 index 36c563e9cd..6cb3cfe8ee 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyWindows10SettingCatalog.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAntivirusPolicyWindows10SettingCatalog.Tests.ps1 @@ -117,6 +117,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10.Tests.ps1 index 081fc88e60..173fd37a33 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10.Tests.ps1 @@ -166,6 +166,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10ConfigMgr.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10ConfigMgr.Tests.ps1 index 3f91a6caf3..46b96d756d 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10ConfigMgr.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneAppAndBrowserIsolationPolicyWindows10ConfigMgr.Tests.ps1 @@ -161,6 +161,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneApplicationControlPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneApplicationControlPolicyWindows10.Tests.ps1 index 84719e3f2f..9cff89677a 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneApplicationControlPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneApplicationControlPolicyWindows10.Tests.ps1 @@ -46,6 +46,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceConfigurationIdentityProtectionPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceConfigurationIdentityProtectionPolicyWindows10.Tests.ps1 index f0f904a249..328c815bbf 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceConfigurationIdentityProtectionPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceConfigurationIdentityProtectionPolicyWindows10.Tests.ps1 @@ -53,6 +53,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceControlPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceControlPolicyWindows10.Tests.ps1 index b15984720e..55b7956cb2 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceControlPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceControlPolicyWindows10.Tests.ps1 @@ -514,6 +514,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceRemediation.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceRemediation.Tests.ps1 index d354e20c66..60870cc47e 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceRemediation.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDeviceRemediation.Tests.ps1 @@ -52,6 +52,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionPDEPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionPDEPolicyWindows10.Tests.ps1 index 0d4905e4bf..a24882a4d3 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionPDEPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionPDEPolicyWindows10.Tests.ps1 @@ -195,6 +195,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionWindows10.Tests.ps1 index 78a4588d0e..7a538c508c 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneDiskEncryptionWindows10.Tests.ps1 @@ -155,6 +155,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyLinux.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyLinux.Tests.ps1 index fcd8f5ebf6..079389cd7b 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyLinux.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyLinux.Tests.ps1 @@ -145,6 +145,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyMacOS.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyMacOS.Tests.ps1 index 8f490b9735..aa8cda720e 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyMacOS.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyMacOS.Tests.ps1 @@ -145,6 +145,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyWindows10.Tests.ps1 index 85bdc2b60a..c5ea260240 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneEndpointDetectionAndResponsePolicyWindows10.Tests.ps1 @@ -165,6 +165,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneExploitProtectionPolicyWindows10SettingCatalog.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneExploitProtectionPolicyWindows10SettingCatalog.Tests.ps1 index a5dbf07f70..8f70de56da 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneExploitProtectionPolicyWindows10SettingCatalog.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneExploitProtectionPolicyWindows10SettingCatalog.Tests.ps1 @@ -117,6 +117,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallPolicyWindows10.Tests.ps1 index f4455f536b..742803d4b0 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallPolicyWindows10.Tests.ps1 @@ -433,6 +433,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesHyperVPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesHyperVPolicyWindows10.Tests.ps1 index 42368fc025..20d88f3775 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesHyperVPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesHyperVPolicyWindows10.Tests.ps1 @@ -285,6 +285,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10.Tests.ps1 index 03224a580e..219b0765fe 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10.Tests.ps1 @@ -364,6 +364,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10ConfigMgr.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10ConfigMgr.Tests.ps1 index 14506a6da8..106d42bda6 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10ConfigMgr.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneFirewallRulesPolicyWindows10ConfigMgr.Tests.ps1 @@ -364,6 +364,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntunePolicySets.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntunePolicySets.Tests.ps1 index 4ceff9776a..0b30c17e42 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntunePolicySets.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntunePolicySets.Tests.ps1 @@ -52,6 +52,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineDefenderForEndpoint.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineDefenderForEndpoint.Tests.ps1 index 101a834113..aa7da1a9b5 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineDefenderForEndpoint.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineDefenderForEndpoint.Tests.ps1 @@ -234,6 +234,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoft365AppsForEnterprise.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoft365AppsForEnterprise.Tests.ps1 index 9da29d6d2c..b236c0e6ed 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoft365AppsForEnterprise.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoft365AppsForEnterprise.Tests.ps1 @@ -280,6 +280,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoftEdge.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoftEdge.Tests.ps1 index b69a4786ab..a24d998890 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoftEdge.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSecurityBaselineMicrosoftEdge.Tests.ps1 @@ -182,6 +182,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSettingCatalogASRRulesPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSettingCatalogASRRulesPolicyWindows10.Tests.ps1 index 62fc74e810..ca035ed297 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSettingCatalogASRRulesPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneSettingCatalogASRRulesPolicyWindows10.Tests.ps1 @@ -248,6 +248,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWindowsUpdateForBusinessQualityUpdateProfileWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWindowsUpdateForBusinessQualityUpdateProfileWindows10.Tests.ps1 index e6538a3cc9..0046c3af04 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWindowsUpdateForBusinessQualityUpdateProfileWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWindowsUpdateForBusinessQualityUpdateProfileWindows10.Tests.ps1 @@ -49,6 +49,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { # Mock Write-Host to hide output during the tests Mock -CommandName Write-Host -MockWith { } + Mock -CommandName Write-Warning -MockWith { + } + $Script:exportedInstances =$null $Script:ExportMode = $false From 25766c64d3197dae266be3f68daf0d32824b2dab Mon Sep 17 00:00:00 2001 From: Yorick Kuijs Date: Mon, 16 Dec 2024 16:32:34 +0100 Subject: [PATCH 6/6] Corrected formatting --- .../MSFT_IntuneSecurityBaselineWindows10.psm1 | 1527 +++++++++++------ ...IntuneSecurityBaselineWindows10.schema.mof | 4 +- .../settings.json | 76 +- 3 files changed, 1045 insertions(+), 562 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/MSFT_IntuneSecurityBaselineWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/MSFT_IntuneSecurityBaselineWindows10.psm1 index 3a60698d16..7a15e4a535 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/MSFT_IntuneSecurityBaselineWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/MSFT_IntuneSecurityBaselineWindows10.psm1 @@ -11,7 +11,7 @@ function Get-TargetResource [Parameter(Mandatory = $true)] [System.String] - $DisplayName, + $DisplayName, [Parameter()] [System.String[]] @@ -92,7 +92,7 @@ function Get-TargetResource $getValue = $null #region resource generator code - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue if ($null -eq $getValue) { @@ -102,7 +102,7 @@ function Get-TargetResource { $getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` -Filter "Name eq '$DisplayName'" ` - -ErrorAction SilentlyContinue + -ErrorAction SilentlyContinue } } #endregion @@ -126,1428 +126,1899 @@ function Get-TargetResource #region resource generator code $complexDeviceSettings = @{} - if ($null -ne $policySettings.DeviceSettings.blockExecutionOfPotentiallyObfuscatedScripts) { + if ($null -ne $policySettings.DeviceSettings.blockExecutionOfPotentiallyObfuscatedScripts) + { $complexDeviceSettings.Add('BlockExecutionOfPotentiallyObfuscatedScripts', $policySettings.DeviceSettings.blockExecutionOfPotentiallyObfuscatedScripts) } - if ($null -ne $policySettings.DeviceSettings.blockExecutionOfPotentiallyObfuscatedScripts_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockExecutionOfPotentiallyObfuscatedScripts_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockExecutionOfPotentiallyObfuscatedScripts_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockExecutionOfPotentiallyObfuscatedScripts_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockWin32APICallsFromOfficeMacros) { + if ($null -ne $policySettings.DeviceSettings.blockWin32APICallsFromOfficeMacros) + { $complexDeviceSettings.Add('BlockWin32APICallsFromOfficeMacros', $policySettings.DeviceSettings.blockWin32APICallsFromOfficeMacros) } - if ($null -ne $policySettings.DeviceSettings.blockWin32APICallsFromOfficeMacros_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockWin32APICallsFromOfficeMacros_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockWin32APICallsFromOfficeMacros_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockWin32APICallsFromOfficeMacros_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockExecutableFilesRunningUnlessTheyMeetPrevalenceAgeTrustedListCriterion) { + if ($null -ne $policySettings.DeviceSettings.blockExecutableFilesRunningUnlessTheyMeetPrevalenceAgeTrustedListCriterion) + { $complexDeviceSettings.Add('BlockExecutableFilesRunningUnlessTheyMeetPrevalenceAgeTrustedListCriterion', $policySettings.DeviceSettings.blockExecutableFilesRunningUnlessTheyMeetPrevalenceAgeTrustedListCriterion) } - if ($null -ne $policySettings.DeviceSettings.blockExecutableFilesRunningUnlessTheyMeetPrevalenceAgeTrustedListCriterion_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockExecutableFilesRunningUnlessTheyMeetPrevalenceAgeTrustedListCriterion_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockExecutableFilesRunningUnlessTheyMeetPrevalenceAgeTrustedListCriterion_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockExecutableFilesRunningUnlessTheyMeetPrevalenceAgeTrustedListCriterion_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockOfficeCommunicationAppFromCreatingChildProcesses) { + if ($null -ne $policySettings.DeviceSettings.blockOfficeCommunicationAppFromCreatingChildProcesses) + { $complexDeviceSettings.Add('BlockOfficeCommunicationAppFromCreatingChildProcesses', $policySettings.DeviceSettings.blockOfficeCommunicationAppFromCreatingChildProcesses) } - if ($null -ne $policySettings.DeviceSettings.blockOfficeCommunicationAppFromCreatingChildProcesses_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockOfficeCommunicationAppFromCreatingChildProcesses_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockOfficeCommunicationAppFromCreatingChildProcesses_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockOfficeCommunicationAppFromCreatingChildProcesses_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockAllOfficeApplicationsFromCreatingChildProcesses) { + if ($null -ne $policySettings.DeviceSettings.blockAllOfficeApplicationsFromCreatingChildProcesses) + { $complexDeviceSettings.Add('BlockAllOfficeApplicationsFromCreatingChildProcesses', $policySettings.DeviceSettings.blockAllOfficeApplicationsFromCreatingChildProcesses) } - if ($null -ne $policySettings.DeviceSettings.blockAllOfficeApplicationsFromCreatingChildProcesses_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockAllOfficeApplicationsFromCreatingChildProcesses_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockAllOfficeApplicationsFromCreatingChildProcesses_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockAllOfficeApplicationsFromCreatingChildProcesses_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockAdobeReaderFromCreatingChildProcesses) { + if ($null -ne $policySettings.DeviceSettings.blockAdobeReaderFromCreatingChildProcesses) + { $complexDeviceSettings.Add('BlockAdobeReaderFromCreatingChildProcesses', $policySettings.DeviceSettings.blockAdobeReaderFromCreatingChildProcesses) } - if ($null -ne $policySettings.DeviceSettings.blockAdobeReaderFromCreatingChildProcesses_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockAdobeReaderFromCreatingChildProcesses_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockAdobeReaderFromCreatingChildProcesses_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockAdobeReaderFromCreatingChildProcesses_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockCredentialStealingFromWindowsLocalSecurityAuthoritySubsystem) { + if ($null -ne $policySettings.DeviceSettings.blockCredentialStealingFromWindowsLocalSecurityAuthoritySubsystem) + { $complexDeviceSettings.Add('BlockCredentialStealingFromWindowsLocalSecurityAuthoritySubsystem', $policySettings.DeviceSettings.blockCredentialStealingFromWindowsLocalSecurityAuthoritySubsystem) } - if ($null -ne $policySettings.DeviceSettings.blockCredentialStealingFromWindowsLocalSecurityAuthoritySubsystem_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockCredentialStealingFromWindowsLocalSecurityAuthoritySubsystem_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockCredentialStealingFromWindowsLocalSecurityAuthoritySubsystem_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockCredentialStealingFromWindowsLocalSecurityAuthoritySubsystem_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockJavaScriptOrVBScriptFromLaunchingDownloadedExecutableContent) { + if ($null -ne $policySettings.DeviceSettings.blockJavaScriptOrVBScriptFromLaunchingDownloadedExecutableContent) + { $complexDeviceSettings.Add('BlockJavaScriptOrVBScriptFromLaunchingDownloadedExecutableContent', $policySettings.DeviceSettings.blockJavaScriptOrVBScriptFromLaunchingDownloadedExecutableContent) } - if ($null -ne $policySettings.DeviceSettings.blockJavaScriptOrVBScriptFromLaunchingDownloadedExecutableContent_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockJavaScriptOrVBScriptFromLaunchingDownloadedExecutableContent_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockJavaScriptOrVBScriptFromLaunchingDownloadedExecutableContent_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockJavaScriptOrVBScriptFromLaunchingDownloadedExecutableContent_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockWebshellCreationForServers) { + if ($null -ne $policySettings.DeviceSettings.blockWebshellCreationForServers) + { $complexDeviceSettings.Add('BlockWebshellCreationForServers', $policySettings.DeviceSettings.blockWebshellCreationForServers) } - if ($null -ne $policySettings.DeviceSettings.blockWebshellCreationForServers_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockWebshellCreationForServers_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockWebshellCreationForServers_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockWebshellCreationForServers_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockUntrustedUnsignedProcessesThatRunFromUSB) { + if ($null -ne $policySettings.DeviceSettings.blockUntrustedUnsignedProcessesThatRunFromUSB) + { $complexDeviceSettings.Add('BlockUntrustedUnsignedProcessesThatRunFromUSB', $policySettings.DeviceSettings.blockUntrustedUnsignedProcessesThatRunFromUSB) } - if ($null -ne $policySettings.DeviceSettings.blockUntrustedUnsignedProcessesThatRunFromUSB_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockUntrustedUnsignedProcessesThatRunFromUSB_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockUntrustedUnsignedProcessesThatRunFromUSB_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockUntrustedUnsignedProcessesThatRunFromUSB_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockPersistenceThroughWMIEventSubscription) { + if ($null -ne $policySettings.DeviceSettings.blockPersistenceThroughWMIEventSubscription) + { $complexDeviceSettings.Add('BlockPersistenceThroughWMIEventSubscription', $policySettings.DeviceSettings.blockPersistenceThroughWMIEventSubscription) } - if ($null -ne $policySettings.DeviceSettings.blockUseOfCopiedOrImpersonatedSystemTools) { + if ($null -ne $policySettings.DeviceSettings.blockUseOfCopiedOrImpersonatedSystemTools) + { $complexDeviceSettings.Add('BlockUseOfCopiedOrImpersonatedSystemTools', $policySettings.DeviceSettings.blockUseOfCopiedOrImpersonatedSystemTools) } - if ($null -ne $policySettings.DeviceSettings.blockUseOfCopiedOrImpersonatedSystemTools_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockUseOfCopiedOrImpersonatedSystemTools_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockUseOfCopiedOrImpersonatedSystemTools_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockUseOfCopiedOrImpersonatedSystemTools_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockAbuseOfExploitedVulnerableSignedDrivers) { + if ($null -ne $policySettings.DeviceSettings.blockAbuseOfExploitedVulnerableSignedDrivers) + { $complexDeviceSettings.Add('BlockAbuseOfExploitedVulnerableSignedDrivers', $policySettings.DeviceSettings.blockAbuseOfExploitedVulnerableSignedDrivers) } - if ($null -ne $policySettings.DeviceSettings.blockAbuseOfExploitedVulnerableSignedDrivers_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockAbuseOfExploitedVulnerableSignedDrivers_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockAbuseOfExploitedVulnerableSignedDrivers_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockAbuseOfExploitedVulnerableSignedDrivers_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockProcessCreationsFromPSExecAndWMICommands) { + if ($null -ne $policySettings.DeviceSettings.blockProcessCreationsFromPSExecAndWMICommands) + { $complexDeviceSettings.Add('BlockProcessCreationsFromPSExecAndWMICommands', $policySettings.DeviceSettings.blockProcessCreationsFromPSExecAndWMICommands) } - if ($null -ne $policySettings.DeviceSettings.blockProcessCreationsFromPSExecAndWMICommands_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockProcessCreationsFromPSExecAndWMICommands_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockProcessCreationsFromPSExecAndWMICommands_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockProcessCreationsFromPSExecAndWMICommands_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockOfficeApplicationsFromCreatingExecutableContent) { + if ($null -ne $policySettings.DeviceSettings.blockOfficeApplicationsFromCreatingExecutableContent) + { $complexDeviceSettings.Add('BlockOfficeApplicationsFromCreatingExecutableContent', $policySettings.DeviceSettings.blockOfficeApplicationsFromCreatingExecutableContent) } - if ($null -ne $policySettings.DeviceSettings.blockOfficeApplicationsFromCreatingExecutableContent_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockOfficeApplicationsFromCreatingExecutableContent_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockOfficeApplicationsFromCreatingExecutableContent_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockOfficeApplicationsFromCreatingExecutableContent_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockOfficeApplicationsFromInjectingCodeIntoOtherProcesses) { + if ($null -ne $policySettings.DeviceSettings.blockOfficeApplicationsFromInjectingCodeIntoOtherProcesses) + { $complexDeviceSettings.Add('BlockOfficeApplicationsFromInjectingCodeIntoOtherProcesses', $policySettings.DeviceSettings.blockOfficeApplicationsFromInjectingCodeIntoOtherProcesses) } - if ($null -ne $policySettings.DeviceSettings.blockOfficeApplicationsFromInjectingCodeIntoOtherProcesses_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockOfficeApplicationsFromInjectingCodeIntoOtherProcesses_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockOfficeApplicationsFromInjectingCodeIntoOtherProcesses_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockOfficeApplicationsFromInjectingCodeIntoOtherProcesses_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockRebootingMachineInSafeMode) { + if ($null -ne $policySettings.DeviceSettings.blockRebootingMachineInSafeMode) + { $complexDeviceSettings.Add('BlockRebootingMachineInSafeMode', $policySettings.DeviceSettings.blockRebootingMachineInSafeMode) } - if ($null -ne $policySettings.DeviceSettings.blockRebootingMachineInSafeMode_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockRebootingMachineInSafeMode_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockRebootingMachineInSafeMode_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockRebootingMachineInSafeMode_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.useAdvancedProtectionAgainstRansomware) { + if ($null -ne $policySettings.DeviceSettings.useAdvancedProtectionAgainstRansomware) + { $complexDeviceSettings.Add('UseAdvancedProtectionAgainstRansomware', $policySettings.DeviceSettings.useAdvancedProtectionAgainstRansomware) } - if ($null -ne $policySettings.DeviceSettings.useAdvancedProtectionAgainstRansomware_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.useAdvancedProtectionAgainstRansomware_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('UseAdvancedProtectionAgainstRansomware_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.useAdvancedProtectionAgainstRansomware_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.blockExecutableContentFromEmailClientAndWebmail) { + if ($null -ne $policySettings.DeviceSettings.blockExecutableContentFromEmailClientAndWebmail) + { $complexDeviceSettings.Add('BlockExecutableContentFromEmailClientAndWebmail', $policySettings.DeviceSettings.blockExecutableContentFromEmailClientAndWebmail) } - if ($null -ne $policySettings.DeviceSettings.blockExecutableContentFromEmailClientAndWebmail_ASROnlyPerRuleExclusions) { + if ($null -ne $policySettings.DeviceSettings.blockExecutableContentFromEmailClientAndWebmail_ASROnlyPerRuleExclusions) + { $complexDeviceSettings.Add('BlockExecutableContentFromEmailClientAndWebmail_ASROnlyPerRuleExclusions', $policySettings.DeviceSettings.blockExecutableContentFromEmailClientAndWebmail_ASROnlyPerRuleExclusions) } - if ($null -ne $policySettings.DeviceSettings.cPL_Personalization_NoLockScreenCamera) { + if ($null -ne $policySettings.DeviceSettings.cPL_Personalization_NoLockScreenCamera) + { $complexDeviceSettings.Add('CPL_Personalization_NoLockScreenCamera', $policySettings.DeviceSettings.cPL_Personalization_NoLockScreenCamera) } - if ($null -ne $policySettings.DeviceSettings.cPL_Personalization_NoLockScreenSlideshow) { + if ($null -ne $policySettings.DeviceSettings.cPL_Personalization_NoLockScreenSlideshow) + { $complexDeviceSettings.Add('CPL_Personalization_NoLockScreenSlideshow', $policySettings.DeviceSettings.cPL_Personalization_NoLockScreenSlideshow) } - if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_0201_LATFP) { + if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_0201_LATFP) + { $complexDeviceSettings.Add('Pol_SecGuide_0201_LATFP', $policySettings.DeviceSettings.pol_SecGuide_0201_LATFP) } - if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_0002_SMBv1_ClientDriver) { + if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_0002_SMBv1_ClientDriver) + { $complexDeviceSettings.Add('Pol_SecGuide_0002_SMBv1_ClientDriver', $policySettings.DeviceSettings.pol_SecGuide_0002_SMBv1_ClientDriver) } - if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_SMB1ClientDriver) { + if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_SMB1ClientDriver) + { $complexDeviceSettings.Add('Pol_SecGuide_SMB1ClientDriver', $policySettings.DeviceSettings.pol_SecGuide_SMB1ClientDriver) } - if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_0001_SMBv1_Server) { + if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_0001_SMBv1_Server) + { $complexDeviceSettings.Add('Pol_SecGuide_0001_SMBv1_Server', $policySettings.DeviceSettings.pol_SecGuide_0001_SMBv1_Server) } - if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_0102_SEHOP) { + if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_0102_SEHOP) + { $complexDeviceSettings.Add('Pol_SecGuide_0102_SEHOP', $policySettings.DeviceSettings.pol_SecGuide_0102_SEHOP) } - if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_0202_WDigestAuthn) { + if ($null -ne $policySettings.DeviceSettings.pol_SecGuide_0202_WDigestAuthn) + { $complexDeviceSettings.Add('Pol_SecGuide_0202_WDigestAuthn', $policySettings.DeviceSettings.pol_SecGuide_0202_WDigestAuthn) } - if ($null -ne $policySettings.DeviceSettings.pol_MSS_DisableIPSourceRoutingIPv6) { + if ($null -ne $policySettings.DeviceSettings.pol_MSS_DisableIPSourceRoutingIPv6) + { $complexDeviceSettings.Add('Pol_MSS_DisableIPSourceRoutingIPv6', $policySettings.DeviceSettings.pol_MSS_DisableIPSourceRoutingIPv6) } - if ($null -ne $policySettings.DeviceSettings.disableIPSourceRoutingIPv6) { + if ($null -ne $policySettings.DeviceSettings.disableIPSourceRoutingIPv6) + { $complexDeviceSettings.Add('DisableIPSourceRoutingIPv6', $policySettings.DeviceSettings.disableIPSourceRoutingIPv6) } - if ($null -ne $policySettings.DeviceSettings.pol_MSS_DisableIPSourceRouting) { + if ($null -ne $policySettings.DeviceSettings.pol_MSS_DisableIPSourceRouting) + { $complexDeviceSettings.Add('Pol_MSS_DisableIPSourceRouting', $policySettings.DeviceSettings.pol_MSS_DisableIPSourceRouting) } - if ($null -ne $policySettings.DeviceSettings.disableIPSourceRouting) { + if ($null -ne $policySettings.DeviceSettings.disableIPSourceRouting) + { $complexDeviceSettings.Add('DisableIPSourceRouting', $policySettings.DeviceSettings.disableIPSourceRouting) } - if ($null -ne $policySettings.DeviceSettings.pol_MSS_EnableICMPRedirect) { + if ($null -ne $policySettings.DeviceSettings.pol_MSS_EnableICMPRedirect) + { $complexDeviceSettings.Add('Pol_MSS_EnableICMPRedirect', $policySettings.DeviceSettings.pol_MSS_EnableICMPRedirect) } - if ($null -ne $policySettings.DeviceSettings.pol_MSS_NoNameReleaseOnDemand) { + if ($null -ne $policySettings.DeviceSettings.pol_MSS_NoNameReleaseOnDemand) + { $complexDeviceSettings.Add('Pol_MSS_NoNameReleaseOnDemand', $policySettings.DeviceSettings.pol_MSS_NoNameReleaseOnDemand) } - if ($null -ne $policySettings.DeviceSettings.turn_Off_Multicast) { + if ($null -ne $policySettings.DeviceSettings.turn_Off_Multicast) + { $complexDeviceSettings.Add('Turn_Off_Multicast', $policySettings.DeviceSettings.turn_Off_Multicast) } - if ($null -ne $policySettings.DeviceSettings.nC_ShowSharedAccessUI) { + if ($null -ne $policySettings.DeviceSettings.nC_ShowSharedAccessUI) + { $complexDeviceSettings.Add('NC_ShowSharedAccessUI', $policySettings.DeviceSettings.nC_ShowSharedAccessUI) } - if ($null -ne $policySettings.DeviceSettings.hardeneduncpaths_Pol_HardenedPaths) { + if ($null -ne $policySettings.DeviceSettings.hardeneduncpaths_Pol_HardenedPaths) + { $complexDeviceSettings.Add('hardeneduncpaths_Pol_HardenedPaths', $policySettings.DeviceSettings.hardeneduncpaths_Pol_HardenedPaths) } - if ($null -ne $policySettings.DeviceSettings.pol_hardenedPaths) { - $complexPol_hardenedpaths = @() - foreach ($currentPol_hardenedpaths in $policySettings.DeviceSettings.pol_hardenedPaths) + if ($null -ne $policySettings.DeviceSettings.pol_hardenedPaths) { - $myPol_hardenedpaths = @{} - if ($null -ne $currentPol_hardenedpaths.value) { - $myPol_hardenedpaths.Add('Value', $currentPol_hardenedpaths.value) - } - if ($null -ne $currentPol_hardenedpaths.Key) { - $myPol_hardenedpaths.Add('Key', $currentPol_hardenedpaths.key) - } - if ($myPol_hardenedpaths.values.Where({$null -ne $_}).Count -gt 0) + $complexPol_hardenedpaths = @() + foreach ($currentPol_hardenedpaths in $policySettings.DeviceSettings.pol_hardenedPaths) { - $complexPol_hardenedpaths += $myPol_hardenedpaths + $myPol_hardenedpaths = @{} + if ($null -ne $currentPol_hardenedpaths.value) + { + $myPol_hardenedpaths.Add('Value', $currentPol_hardenedpaths.value) + } + if ($null -ne $currentPol_hardenedpaths.Key) + { + $myPol_hardenedpaths.Add('Key', $currentPol_hardenedpaths.key) + } + if ($myPol_hardenedpaths.values.Where({ $null -ne $_ }).Count -gt 0) + { + $complexPol_hardenedpaths += $myPol_hardenedpaths + } } - } $complexDeviceSettings.Add('pol_hardenedPaths', $complexPol_hardenedpaths) - } - if ($null -ne $policySettings.DeviceSettings.wCM_BlockNonDomain) { + } + if ($null -ne $policySettings.DeviceSettings.wCM_BlockNonDomain) + { $complexDeviceSettings.Add('WCM_BlockNonDomain', $policySettings.DeviceSettings.wCM_BlockNonDomain) } - if ($null -ne $policySettings.DeviceSettings.configureRedirectionGuardPolicy) { + if ($null -ne $policySettings.DeviceSettings.configureRedirectionGuardPolicy) + { $complexDeviceSettings.Add('ConfigureRedirectionGuardPolicy', $policySettings.DeviceSettings.configureRedirectionGuardPolicy) } - if ($null -ne $policySettings.DeviceSettings.redirectionGuardPolicy_Enum) { + if ($null -ne $policySettings.DeviceSettings.redirectionGuardPolicy_Enum) + { $complexDeviceSettings.Add('RedirectionGuardPolicy_Enum', $policySettings.DeviceSettings.redirectionGuardPolicy_Enum) } - if ($null -ne $policySettings.DeviceSettings.configureRpcConnectionPolicy) { + if ($null -ne $policySettings.DeviceSettings.configureRpcConnectionPolicy) + { $complexDeviceSettings.Add('ConfigureRpcConnectionPolicy', $policySettings.DeviceSettings.configureRpcConnectionPolicy) } - if ($null -ne $policySettings.DeviceSettings.rpcConnectionAuthentication_Enum) { + if ($null -ne $policySettings.DeviceSettings.rpcConnectionAuthentication_Enum) + { $complexDeviceSettings.Add('RpcConnectionAuthentication_Enum', $policySettings.DeviceSettings.rpcConnectionAuthentication_Enum) } - if ($null -ne $policySettings.DeviceSettings.rpcConnectionProtocol_Enum) { + if ($null -ne $policySettings.DeviceSettings.rpcConnectionProtocol_Enum) + { $complexDeviceSettings.Add('RpcConnectionProtocol_Enum', $policySettings.DeviceSettings.rpcConnectionProtocol_Enum) } - if ($null -ne $policySettings.DeviceSettings.configureRpcListenerPolicy) { + if ($null -ne $policySettings.DeviceSettings.configureRpcListenerPolicy) + { $complexDeviceSettings.Add('ConfigureRpcListenerPolicy', $policySettings.DeviceSettings.configureRpcListenerPolicy) } - if ($null -ne $policySettings.DeviceSettings.rpcAuthenticationProtocol_Enum) { + if ($null -ne $policySettings.DeviceSettings.rpcAuthenticationProtocol_Enum) + { $complexDeviceSettings.Add('RpcAuthenticationProtocol_Enum', $policySettings.DeviceSettings.rpcAuthenticationProtocol_Enum) } - if ($null -ne $policySettings.DeviceSettings.rpcListenerProtocols_Enum) { + if ($null -ne $policySettings.DeviceSettings.rpcListenerProtocols_Enum) + { $complexDeviceSettings.Add('RpcListenerProtocols_Enum', $policySettings.DeviceSettings.rpcListenerProtocols_Enum) } - if ($null -ne $policySettings.DeviceSettings.configureRpcTcpPort) { + if ($null -ne $policySettings.DeviceSettings.configureRpcTcpPort) + { $complexDeviceSettings.Add('ConfigureRpcTcpPort', $policySettings.DeviceSettings.configureRpcTcpPort) } - if ($null -ne $policySettings.DeviceSettings.rpcTcpPort) { + if ($null -ne $policySettings.DeviceSettings.rpcTcpPort) + { $complexDeviceSettings.Add('RpcTcpPort', $policySettings.DeviceSettings.rpcTcpPort) } - if ($null -ne $policySettings.DeviceSettings.restrictDriverInstallationToAdministrators) { + if ($null -ne $policySettings.DeviceSettings.restrictDriverInstallationToAdministrators) + { $complexDeviceSettings.Add('RestrictDriverInstallationToAdministrators', $policySettings.DeviceSettings.restrictDriverInstallationToAdministrators) } - if ($null -ne $policySettings.DeviceSettings.configureCopyFilesPolicy) { + if ($null -ne $policySettings.DeviceSettings.configureCopyFilesPolicy) + { $complexDeviceSettings.Add('ConfigureCopyFilesPolicy', $policySettings.DeviceSettings.configureCopyFilesPolicy) } - if ($null -ne $policySettings.DeviceSettings.copyFilesPolicy_Enum) { + if ($null -ne $policySettings.DeviceSettings.copyFilesPolicy_Enum) + { $complexDeviceSettings.Add('CopyFilesPolicy_Enum', $policySettings.DeviceSettings.copyFilesPolicy_Enum) } - if ($null -ne $policySettings.DeviceSettings.allowEncryptionOracle) { + if ($null -ne $policySettings.DeviceSettings.allowEncryptionOracle) + { $complexDeviceSettings.Add('AllowEncryptionOracle', $policySettings.DeviceSettings.allowEncryptionOracle) } - if ($null -ne $policySettings.DeviceSettings.allowEncryptionOracleDrop) { + if ($null -ne $policySettings.DeviceSettings.allowEncryptionOracleDrop) + { $complexDeviceSettings.Add('AllowEncryptionOracleDrop', $policySettings.DeviceSettings.allowEncryptionOracleDrop) } - if ($null -ne $policySettings.DeviceSettings.allowProtectedCreds) { + if ($null -ne $policySettings.DeviceSettings.allowProtectedCreds) + { $complexDeviceSettings.Add('AllowProtectedCreds', $policySettings.DeviceSettings.allowProtectedCreds) } - if ($null -ne $policySettings.DeviceSettings.deviceInstall_Classes_Deny) { + if ($null -ne $policySettings.DeviceSettings.deviceInstall_Classes_Deny) + { $complexDeviceSettings.Add('DeviceInstall_Classes_Deny', $policySettings.DeviceSettings.deviceInstall_Classes_Deny) } - if ($null -ne $policySettings.DeviceSettings.deviceInstall_Classes_Deny_List) { + if ($null -ne $policySettings.DeviceSettings.deviceInstall_Classes_Deny_List) + { $complexDeviceSettings.Add('DeviceInstall_Classes_Deny_List', $policySettings.DeviceSettings.deviceInstall_Classes_Deny_List) } - if ($null -ne $policySettings.DeviceSettings.deviceInstall_Classes_Deny_Retroactive) { + if ($null -ne $policySettings.DeviceSettings.deviceInstall_Classes_Deny_Retroactive) + { $complexDeviceSettings.Add('DeviceInstall_Classes_Deny_Retroactive', $policySettings.DeviceSettings.deviceInstall_Classes_Deny_Retroactive) } - if ($null -ne $policySettings.DeviceSettings.pOL_DriverLoadPolicy_Name) { + if ($null -ne $policySettings.DeviceSettings.pOL_DriverLoadPolicy_Name) + { $complexDeviceSettings.Add('POL_DriverLoadPolicy_Name', $policySettings.DeviceSettings.pOL_DriverLoadPolicy_Name) } - if ($null -ne $policySettings.DeviceSettings.selectDriverLoadPolicy) { + if ($null -ne $policySettings.DeviceSettings.selectDriverLoadPolicy) + { $complexDeviceSettings.Add('SelectDriverLoadPolicy', $policySettings.DeviceSettings.selectDriverLoadPolicy) } - if ($null -ne $policySettings.DeviceSettings.cSE_Registry) { + if ($null -ne $policySettings.DeviceSettings.cSE_Registry) + { $complexDeviceSettings.Add('CSE_Registry', $policySettings.DeviceSettings.cSE_Registry) } - if ($null -ne $policySettings.DeviceSettings.cSE_NOBACKGROUND10) { + if ($null -ne $policySettings.DeviceSettings.cSE_NOBACKGROUND10) + { $complexDeviceSettings.Add('CSE_NOBACKGROUND10', $policySettings.DeviceSettings.cSE_NOBACKGROUND10) } - if ($null -ne $policySettings.DeviceSettings.cSE_NOCHANGES10) { + if ($null -ne $policySettings.DeviceSettings.cSE_NOCHANGES10) + { $complexDeviceSettings.Add('CSE_NOCHANGES10', $policySettings.DeviceSettings.cSE_NOCHANGES10) } - if ($null -ne $policySettings.DeviceSettings.disableWebPnPDownload_2) { + if ($null -ne $policySettings.DeviceSettings.disableWebPnPDownload_2) + { $complexDeviceSettings.Add('DisableWebPnPDownload_2', $policySettings.DeviceSettings.disableWebPnPDownload_2) } - if ($null -ne $policySettings.DeviceSettings.shellPreventWPWDownload_2) { + if ($null -ne $policySettings.DeviceSettings.shellPreventWPWDownload_2) + { $complexDeviceSettings.Add('ShellPreventWPWDownload_2', $policySettings.DeviceSettings.shellPreventWPWDownload_2) } - if ($null -ne $policySettings.DeviceSettings.allowCustomSSPsAPs) { + if ($null -ne $policySettings.DeviceSettings.allowCustomSSPsAPs) + { $complexDeviceSettings.Add('AllowCustomSSPsAPs', $policySettings.DeviceSettings.allowCustomSSPsAPs) } - if ($null -ne $policySettings.DeviceSettings.allowStandbyStatesDC_2) { + if ($null -ne $policySettings.DeviceSettings.allowStandbyStatesDC_2) + { $complexDeviceSettings.Add('AllowStandbyStatesDC_2', $policySettings.DeviceSettings.allowStandbyStatesDC_2) } - if ($null -ne $policySettings.DeviceSettings.allowStandbyStatesAC_2) { + if ($null -ne $policySettings.DeviceSettings.allowStandbyStatesAC_2) + { $complexDeviceSettings.Add('AllowStandbyStatesAC_2', $policySettings.DeviceSettings.allowStandbyStatesAC_2) } - if ($null -ne $policySettings.DeviceSettings.dCPromptForPasswordOnResume_2) { + if ($null -ne $policySettings.DeviceSettings.dCPromptForPasswordOnResume_2) + { $complexDeviceSettings.Add('DCPromptForPasswordOnResume_2', $policySettings.DeviceSettings.dCPromptForPasswordOnResume_2) } - if ($null -ne $policySettings.DeviceSettings.aCPromptForPasswordOnResume_2) { + if ($null -ne $policySettings.DeviceSettings.aCPromptForPasswordOnResume_2) + { $complexDeviceSettings.Add('ACPromptForPasswordOnResume_2', $policySettings.DeviceSettings.aCPromptForPasswordOnResume_2) } - if ($null -ne $policySettings.DeviceSettings.rA_Solicit) { + if ($null -ne $policySettings.DeviceSettings.rA_Solicit) + { $complexDeviceSettings.Add('RA_Solicit', $policySettings.DeviceSettings.rA_Solicit) } - if ($null -ne $policySettings.DeviceSettings.rA_Solicit_ExpireUnits_List) { + if ($null -ne $policySettings.DeviceSettings.rA_Solicit_ExpireUnits_List) + { $complexDeviceSettings.Add('RA_Solicit_ExpireUnits_List', $policySettings.DeviceSettings.rA_Solicit_ExpireUnits_List) } - if ($null -ne $policySettings.DeviceSettings.rA_Solicit_ExpireValue_Edt) { + if ($null -ne $policySettings.DeviceSettings.rA_Solicit_ExpireValue_Edt) + { $complexDeviceSettings.Add('RA_Solicit_ExpireValue_Edt', $policySettings.DeviceSettings.rA_Solicit_ExpireValue_Edt) } - if ($null -ne $policySettings.DeviceSettings.rA_Solicit_Control_List) { + if ($null -ne $policySettings.DeviceSettings.rA_Solicit_Control_List) + { $complexDeviceSettings.Add('RA_Solicit_Control_List', $policySettings.DeviceSettings.rA_Solicit_Control_List) } - if ($null -ne $policySettings.DeviceSettings.rA_Solicit_Mailto_List) { + if ($null -ne $policySettings.DeviceSettings.rA_Solicit_Mailto_List) + { $complexDeviceSettings.Add('RA_Solicit_Mailto_List', $policySettings.DeviceSettings.rA_Solicit_Mailto_List) } - if ($null -ne $policySettings.DeviceSettings.rpcRestrictRemoteClients) { + if ($null -ne $policySettings.DeviceSettings.rpcRestrictRemoteClients) + { $complexDeviceSettings.Add('RpcRestrictRemoteClients', $policySettings.DeviceSettings.rpcRestrictRemoteClients) } - if ($null -ne $policySettings.DeviceSettings.rpcRestrictRemoteClientsList) { + if ($null -ne $policySettings.DeviceSettings.rpcRestrictRemoteClientsList) + { $complexDeviceSettings.Add('RpcRestrictRemoteClientsList', $policySettings.DeviceSettings.rpcRestrictRemoteClientsList) } - if ($null -ne $policySettings.DeviceSettings.appxRuntimeMicrosoftAccountsOptional) { + if ($null -ne $policySettings.DeviceSettings.appxRuntimeMicrosoftAccountsOptional) + { $complexDeviceSettings.Add('AppxRuntimeMicrosoftAccountsOptional', $policySettings.DeviceSettings.appxRuntimeMicrosoftAccountsOptional) } - if ($null -ne $policySettings.DeviceSettings.noAutoplayfornonVolume) { + if ($null -ne $policySettings.DeviceSettings.noAutoplayfornonVolume) + { $complexDeviceSettings.Add('NoAutoplayfornonVolume', $policySettings.DeviceSettings.noAutoplayfornonVolume) } - if ($null -ne $policySettings.DeviceSettings.noAutorun) { + if ($null -ne $policySettings.DeviceSettings.noAutorun) + { $complexDeviceSettings.Add('NoAutorun', $policySettings.DeviceSettings.noAutorun) } - if ($null -ne $policySettings.DeviceSettings.noAutorun_Dropdown) { + if ($null -ne $policySettings.DeviceSettings.noAutorun_Dropdown) + { $complexDeviceSettings.Add('NoAutorun_Dropdown', $policySettings.DeviceSettings.noAutorun_Dropdown) } - if ($null -ne $policySettings.DeviceSettings.autorun) { + if ($null -ne $policySettings.DeviceSettings.autorun) + { $complexDeviceSettings.Add('Autorun', $policySettings.DeviceSettings.autorun) } - if ($null -ne $policySettings.DeviceSettings.autorun_Box) { + if ($null -ne $policySettings.DeviceSettings.autorun_Box) + { $complexDeviceSettings.Add('Autorun_Box', $policySettings.DeviceSettings.autorun_Box) } - if ($null -ne $policySettings.DeviceSettings.fDVDenyWriteAccess_Name) { + if ($null -ne $policySettings.DeviceSettings.fDVDenyWriteAccess_Name) + { $complexDeviceSettings.Add('FDVDenyWriteAccess_Name', $policySettings.DeviceSettings.fDVDenyWriteAccess_Name) } - if ($null -ne $policySettings.DeviceSettings.rDVDenyWriteAccess_Name) { + if ($null -ne $policySettings.DeviceSettings.rDVDenyWriteAccess_Name) + { $complexDeviceSettings.Add('RDVDenyWriteAccess_Name', $policySettings.DeviceSettings.rDVDenyWriteAccess_Name) } - if ($null -ne $policySettings.DeviceSettings.rDVCrossOrg) { + if ($null -ne $policySettings.DeviceSettings.rDVCrossOrg) + { $complexDeviceSettings.Add('RDVCrossOrg', $policySettings.DeviceSettings.rDVCrossOrg) } - if ($null -ne $policySettings.DeviceSettings.enumerateAdministrators) { + if ($null -ne $policySettings.DeviceSettings.enumerateAdministrators) + { $complexDeviceSettings.Add('EnumerateAdministrators', $policySettings.DeviceSettings.enumerateAdministrators) } - if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_1) { + if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_1) + { $complexDeviceSettings.Add('Channel_LogMaxSize_1', $policySettings.DeviceSettings.channel_LogMaxSize_1) } - if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_1_Channel_LogMaxSize) { + if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_1_Channel_LogMaxSize) + { $complexDeviceSettings.Add('Channel_LogMaxSize_1_Channel_LogMaxSize', $policySettings.DeviceSettings.channel_LogMaxSize_1_Channel_LogMaxSize) } - if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_2) { + if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_2) + { $complexDeviceSettings.Add('Channel_LogMaxSize_2', $policySettings.DeviceSettings.channel_LogMaxSize_2) } - if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_2_Channel_LogMaxSize) { + if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_2_Channel_LogMaxSize) + { $complexDeviceSettings.Add('Channel_LogMaxSize_2_Channel_LogMaxSize', $policySettings.DeviceSettings.channel_LogMaxSize_2_Channel_LogMaxSize) } - if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_4) { + if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_4) + { $complexDeviceSettings.Add('Channel_LogMaxSize_4', $policySettings.DeviceSettings.channel_LogMaxSize_4) } - if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_4_Channel_LogMaxSize) { + if ($null -ne $policySettings.DeviceSettings.channel_LogMaxSize_4_Channel_LogMaxSize) + { $complexDeviceSettings.Add('Channel_LogMaxSize_4_Channel_LogMaxSize', $policySettings.DeviceSettings.channel_LogMaxSize_4_Channel_LogMaxSize) } - if ($null -ne $policySettings.DeviceSettings.enableSmartScreen) { + if ($null -ne $policySettings.DeviceSettings.enableSmartScreen) + { $complexDeviceSettings.Add('EnableSmartScreen', $policySettings.DeviceSettings.enableSmartScreen) } - if ($null -ne $policySettings.DeviceSettings.enableSmartScreenDropdown) { + if ($null -ne $policySettings.DeviceSettings.enableSmartScreenDropdown) + { $complexDeviceSettings.Add('EnableSmartScreenDropdown', $policySettings.DeviceSettings.enableSmartScreenDropdown) } - if ($null -ne $policySettings.DeviceSettings.noDataExecutionPrevention) { + if ($null -ne $policySettings.DeviceSettings.noDataExecutionPrevention) + { $complexDeviceSettings.Add('NoDataExecutionPrevention', $policySettings.DeviceSettings.noDataExecutionPrevention) } - if ($null -ne $policySettings.DeviceSettings.noHeapTerminationOnCorruption) { + if ($null -ne $policySettings.DeviceSettings.noHeapTerminationOnCorruption) + { $complexDeviceSettings.Add('NoHeapTerminationOnCorruption', $policySettings.DeviceSettings.noHeapTerminationOnCorruption) } - if ($null -ne $policySettings.DeviceSettings.advanced_InvalidSignatureBlock) { + if ($null -ne $policySettings.DeviceSettings.advanced_InvalidSignatureBlock) + { $complexDeviceSettings.Add('Advanced_InvalidSignatureBlock', $policySettings.DeviceSettings.advanced_InvalidSignatureBlock) } - if ($null -ne $policySettings.DeviceSettings.advanced_CertificateRevocation) { + if ($null -ne $policySettings.DeviceSettings.advanced_CertificateRevocation) + { $complexDeviceSettings.Add('Advanced_CertificateRevocation', $policySettings.DeviceSettings.advanced_CertificateRevocation) } - if ($null -ne $policySettings.DeviceSettings.advanced_DownloadSignatures) { + if ($null -ne $policySettings.DeviceSettings.advanced_DownloadSignatures) + { $complexDeviceSettings.Add('Advanced_DownloadSignatures', $policySettings.DeviceSettings.advanced_DownloadSignatures) } - if ($null -ne $policySettings.DeviceSettings.advanced_DisableEPMCompat) { + if ($null -ne $policySettings.DeviceSettings.advanced_DisableEPMCompat) + { $complexDeviceSettings.Add('Advanced_DisableEPMCompat', $policySettings.DeviceSettings.advanced_DisableEPMCompat) } - if ($null -ne $policySettings.DeviceSettings.advanced_SetWinInetProtocols) { + if ($null -ne $policySettings.DeviceSettings.advanced_SetWinInetProtocols) + { $complexDeviceSettings.Add('Advanced_SetWinInetProtocols', $policySettings.DeviceSettings.advanced_SetWinInetProtocols) } - if ($null -ne $policySettings.DeviceSettings.advanced_WinInetProtocolOptions) { + if ($null -ne $policySettings.DeviceSettings.advanced_WinInetProtocolOptions) + { $complexDeviceSettings.Add('Advanced_WinInetProtocolOptions', $policySettings.DeviceSettings.advanced_WinInetProtocolOptions) } - if ($null -ne $policySettings.DeviceSettings.advanced_EnableEnhancedProtectedMode64Bit) { + if ($null -ne $policySettings.DeviceSettings.advanced_EnableEnhancedProtectedMode64Bit) + { $complexDeviceSettings.Add('Advanced_EnableEnhancedProtectedMode64Bit', $policySettings.DeviceSettings.advanced_EnableEnhancedProtectedMode64Bit) } - if ($null -ne $policySettings.DeviceSettings.advanced_EnableEnhancedProtectedMode) { + if ($null -ne $policySettings.DeviceSettings.advanced_EnableEnhancedProtectedMode) + { $complexDeviceSettings.Add('Advanced_EnableEnhancedProtectedMode', $policySettings.DeviceSettings.advanced_EnableEnhancedProtectedMode) } - if ($null -ne $policySettings.DeviceSettings.noCertError) { + if ($null -ne $policySettings.DeviceSettings.noCertError) + { $complexDeviceSettings.Add('NoCertError', $policySettings.DeviceSettings.noCertError) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_1) + { $complexDeviceSettings.Add('IZ_PolicyAccessDataSourcesAcrossDomains_1', $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_1_IZ_Partname1406) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_1_IZ_Partname1406) + { $complexDeviceSettings.Add('IZ_PolicyAccessDataSourcesAcrossDomains_1_IZ_Partname1406', $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_1_IZ_Partname1406) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_1) + { $complexDeviceSettings.Add('IZ_PolicyAllowPasteViaScript_1', $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_1_IZ_Partname1407) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_1_IZ_Partname1407) + { $complexDeviceSettings.Add('IZ_PolicyAllowPasteViaScript_1_IZ_Partname1407', $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_1_IZ_Partname1407) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_1) + { $complexDeviceSettings.Add('IZ_PolicyDropOrPasteFiles_1', $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_1_IZ_Partname1802) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_1_IZ_Partname1802) + { $complexDeviceSettings.Add('IZ_PolicyDropOrPasteFiles_1_IZ_Partname1802', $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_1_IZ_Partname1802) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_XAML_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_XAML_1) + { $complexDeviceSettings.Add('IZ_Policy_XAML_1', $policySettings.DeviceSettings.iZ_Policy_XAML_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_XAML_1_IZ_Partname2402) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_XAML_1_IZ_Partname2402) + { $complexDeviceSettings.Add('IZ_Policy_XAML_1_IZ_Partname2402', $policySettings.DeviceSettings.iZ_Policy_XAML_1_IZ_Partname2402) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Internet) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Internet) + { $complexDeviceSettings.Add('IZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Internet', $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Internet) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Internet_IZ_Partname120b) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Internet_IZ_Partname120b) + { $complexDeviceSettings.Add('IZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Internet_IZ_Partname120b', $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Internet_IZ_Partname120b) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Internet) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Internet) + { $complexDeviceSettings.Add('IZ_PolicyAllowTDCControl_Both_Internet', $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Internet) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Internet_IZ_Partname120c) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Internet_IZ_Partname120c) + { $complexDeviceSettings.Add('IZ_PolicyAllowTDCControl_Both_Internet_IZ_Partname120c', $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Internet_IZ_Partname120c) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_1) + { $complexDeviceSettings.Add('IZ_PolicyWindowsRestrictionsURLaction_1', $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_1_IZ_Partname2102) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_1_IZ_Partname2102) + { $complexDeviceSettings.Add('IZ_PolicyWindowsRestrictionsURLaction_1_IZ_Partname2102', $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_1_IZ_Partname2102) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_1) + { $complexDeviceSettings.Add('IZ_Policy_WebBrowserControl_1', $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_1_IZ_Partname1206) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_1_IZ_Partname1206) + { $complexDeviceSettings.Add('IZ_Policy_WebBrowserControl_1_IZ_Partname1206', $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_1_IZ_Partname1206) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_1) + { $complexDeviceSettings.Add('IZ_Policy_AllowScriptlets_1', $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_1_IZ_Partname1209) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_1_IZ_Partname1209) + { $complexDeviceSettings.Add('IZ_Policy_AllowScriptlets_1_IZ_Partname1209', $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_1_IZ_Partname1209) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_1) + { $complexDeviceSettings.Add('IZ_Policy_ScriptStatusBar_1', $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_1_IZ_Partname2103) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_1_IZ_Partname2103) + { $complexDeviceSettings.Add('IZ_Policy_ScriptStatusBar_1_IZ_Partname2103', $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_1_IZ_Partname2103) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_1) + { $complexDeviceSettings.Add('IZ_PolicyAllowVBScript_1', $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_1_IZ_Partname140C) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_1_IZ_Partname140C) + { $complexDeviceSettings.Add('IZ_PolicyAllowVBScript_1_IZ_Partname140C', $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_1_IZ_Partname140C) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_1) + { $complexDeviceSettings.Add('IZ_PolicyNotificationBarDownloadURLaction_1', $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_1_IZ_Partname2200) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_1_IZ_Partname2200) + { $complexDeviceSettings.Add('IZ_PolicyNotificationBarDownloadURLaction_1_IZ_Partname2200', $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_1_IZ_Partname2200) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_1) + { $complexDeviceSettings.Add('IZ_PolicyAntiMalwareCheckingOfActiveXControls_1', $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_1_IZ_Partname270C) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_1_IZ_Partname270C) + { $complexDeviceSettings.Add('IZ_PolicyAntiMalwareCheckingOfActiveXControls_1_IZ_Partname270C', $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_1_IZ_Partname270C) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_1) + { $complexDeviceSettings.Add('IZ_PolicyDownloadSignedActiveX_1', $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_1_IZ_Partname1001) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_1_IZ_Partname1001) + { $complexDeviceSettings.Add('IZ_PolicyDownloadSignedActiveX_1_IZ_Partname1001', $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_1_IZ_Partname1001) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_1) + { $complexDeviceSettings.Add('IZ_PolicyDownloadUnsignedActiveX_1', $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_1_IZ_Partname1004) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_1_IZ_Partname1004) + { $complexDeviceSettings.Add('IZ_PolicyDownloadUnsignedActiveX_1_IZ_Partname1004', $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_1_IZ_Partname1004) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Internet) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Internet) + { $complexDeviceSettings.Add('IZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Internet', $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Internet) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Internet_IZ_Partname2709) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Internet_IZ_Partname2709) + { $complexDeviceSettings.Add('IZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Internet_IZ_Partname2709', $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Internet_IZ_Partname2709) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Internet) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Internet) + { $complexDeviceSettings.Add('IZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Internet', $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Internet) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Internet_IZ_Partname2708) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Internet_IZ_Partname2708) + { $complexDeviceSettings.Add('IZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Internet_IZ_Partname2708', $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Internet_IZ_Partname2708) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_1) + { $complexDeviceSettings.Add('IZ_Policy_LocalPathForUpload_1', $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_1_IZ_Partname160A) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_1_IZ_Partname160A) + { $complexDeviceSettings.Add('IZ_Policy_LocalPathForUpload_1_IZ_Partname160A', $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_1_IZ_Partname160A) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_1) + { $complexDeviceSettings.Add('IZ_PolicyScriptActiveXNotMarkedSafe_1', $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_1_IZ_Partname1201) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_1_IZ_Partname1201) + { $complexDeviceSettings.Add('IZ_PolicyScriptActiveXNotMarkedSafe_1_IZ_Partname1201', $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_1_IZ_Partname1201) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_1) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_1', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_1_IZ_Partname1C00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_1_IZ_Partname1C00) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_1_IZ_Partname1C00', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_1_IZ_Partname1C00) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_1) + { $complexDeviceSettings.Add('IZ_PolicyLaunchAppsAndFilesInIFRAME_1', $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_1_IZ_Partname1804) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_1_IZ_Partname1804) + { $complexDeviceSettings.Add('IZ_PolicyLaunchAppsAndFilesInIFRAME_1_IZ_Partname1804', $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_1_IZ_Partname1804) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLogon_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLogon_1) + { $complexDeviceSettings.Add('IZ_PolicyLogon_1', $policySettings.DeviceSettings.iZ_PolicyLogon_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLogon_1_IZ_Partname1A00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLogon_1_IZ_Partname1A00) + { $complexDeviceSettings.Add('IZ_PolicyLogon_1_IZ_Partname1A00', $policySettings.DeviceSettings.iZ_PolicyLogon_1_IZ_Partname1A00) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_1) + { $complexDeviceSettings.Add('IZ_PolicyNavigateSubframesAcrossDomains_1', $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_1_IZ_Partname1607) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_1_IZ_Partname1607) + { $complexDeviceSettings.Add('IZ_PolicyNavigateSubframesAcrossDomains_1_IZ_Partname1607', $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_1_IZ_Partname1607) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_1) + { $complexDeviceSettings.Add('IZ_PolicyUnsignedFrameworkComponentsURLaction_1', $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_1_IZ_Partname2004) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_1_IZ_Partname2004) + { $complexDeviceSettings.Add('IZ_PolicyUnsignedFrameworkComponentsURLaction_1_IZ_Partname2004', $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_1_IZ_Partname2004) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_1) + { $complexDeviceSettings.Add('IZ_PolicySignedFrameworkComponentsURLaction_1', $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_1_IZ_Partname2001) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_1_IZ_Partname2001) + { $complexDeviceSettings.Add('IZ_PolicySignedFrameworkComponentsURLaction_1_IZ_Partname2001', $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_1_IZ_Partname2001) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_1) + { $complexDeviceSettings.Add('IZ_Policy_UnsafeFiles_1', $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_1_IZ_Partname1806) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_1_IZ_Partname1806) + { $complexDeviceSettings.Add('IZ_Policy_UnsafeFiles_1_IZ_Partname1806', $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_1_IZ_Partname1806) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Internet) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Internet) + { $complexDeviceSettings.Add('IZ_PolicyTurnOnXSSFilter_Both_Internet', $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Internet) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Internet_IZ_Partname1409) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Internet_IZ_Partname1409) + { $complexDeviceSettings.Add('IZ_PolicyTurnOnXSSFilter_Both_Internet_IZ_Partname1409', $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Internet_IZ_Partname1409) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_1) + { $complexDeviceSettings.Add('IZ_Policy_TurnOnProtectedMode_1', $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_1_IZ_Partname2500) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_1_IZ_Partname2500) + { $complexDeviceSettings.Add('IZ_Policy_TurnOnProtectedMode_1_IZ_Partname2500', $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_1_IZ_Partname2500) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_1) + { $complexDeviceSettings.Add('IZ_Policy_Phishing_1', $policySettings.DeviceSettings.iZ_Policy_Phishing_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_1_IZ_Partname2301) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_1_IZ_Partname2301) + { $complexDeviceSettings.Add('IZ_Policy_Phishing_1_IZ_Partname2301', $policySettings.DeviceSettings.iZ_Policy_Phishing_1_IZ_Partname2301) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_1) + { $complexDeviceSettings.Add('IZ_PolicyBlockPopupWindows_1', $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_1_IZ_Partname1809) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_1_IZ_Partname1809) + { $complexDeviceSettings.Add('IZ_PolicyBlockPopupWindows_1_IZ_Partname1809', $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_1_IZ_Partname1809) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_1) + { $complexDeviceSettings.Add('IZ_PolicyUserdataPersistence_1', $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_1_IZ_Partname1606) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_1_IZ_Partname1606) + { $complexDeviceSettings.Add('IZ_PolicyUserdataPersistence_1_IZ_Partname1606', $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_1_IZ_Partname1606) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_1) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_1) + { $complexDeviceSettings.Add('IZ_PolicyZoneElevationURLaction_1', $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_1) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_1_IZ_Partname2101) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_1_IZ_Partname2101) + { $complexDeviceSettings.Add('IZ_PolicyZoneElevationURLaction_1_IZ_Partname2101', $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_1_IZ_Partname2101) } - if ($null -ne $policySettings.DeviceSettings.iZ_UNCAsIntranet) { + if ($null -ne $policySettings.DeviceSettings.iZ_UNCAsIntranet) + { $complexDeviceSettings.Add('IZ_UNCAsIntranet', $policySettings.DeviceSettings.iZ_UNCAsIntranet) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_3) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_3) + { $complexDeviceSettings.Add('IZ_PolicyAntiMalwareCheckingOfActiveXControls_3', $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_3) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_3_IZ_Partname270C) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_3_IZ_Partname270C) + { $complexDeviceSettings.Add('IZ_PolicyAntiMalwareCheckingOfActiveXControls_3_IZ_Partname270C', $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_3_IZ_Partname270C) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_3) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_3) + { $complexDeviceSettings.Add('IZ_PolicyScriptActiveXNotMarkedSafe_3', $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_3) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_3_IZ_Partname1201) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_3_IZ_Partname1201) + { $complexDeviceSettings.Add('IZ_PolicyScriptActiveXNotMarkedSafe_3_IZ_Partname1201', $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_3_IZ_Partname1201) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_3) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_3) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_3', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_3) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_3_IZ_Partname1C00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_3_IZ_Partname1C00) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_3_IZ_Partname1C00', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_3_IZ_Partname1C00) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_9) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_9) + { $complexDeviceSettings.Add('IZ_PolicyAntiMalwareCheckingOfActiveXControls_9', $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_9) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_9_IZ_Partname270C) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_9_IZ_Partname270C) + { $complexDeviceSettings.Add('IZ_PolicyAntiMalwareCheckingOfActiveXControls_9_IZ_Partname270C', $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_9_IZ_Partname270C) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_9) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_9) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_9', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_9) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_9_IZ_Partname1C00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_9_IZ_Partname1C00) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_9_IZ_Partname1C00', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_9_IZ_Partname1C00) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_2) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_2) + { $complexDeviceSettings.Add('IZ_Policy_Phishing_2', $policySettings.DeviceSettings.iZ_Policy_Phishing_2) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_2_IZ_Partname2301) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_2_IZ_Partname2301) + { $complexDeviceSettings.Add('IZ_Policy_Phishing_2_IZ_Partname2301', $policySettings.DeviceSettings.iZ_Policy_Phishing_2_IZ_Partname2301) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_4) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_4) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_4', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_4) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_4_IZ_Partname1C00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_4_IZ_Partname1C00) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_4_IZ_Partname1C00', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_4_IZ_Partname1C00) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_10) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_10) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_10', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_10) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_10_IZ_Partname1C00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_10_IZ_Partname1C00) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_10_IZ_Partname1C00', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_10_IZ_Partname1C00) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_8) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_8) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_8', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_8) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_8_IZ_Partname1C00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_8_IZ_Partname1C00) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_8_IZ_Partname1C00', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_8_IZ_Partname1C00) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_8) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_8) + { $complexDeviceSettings.Add('IZ_Policy_Phishing_8', $policySettings.DeviceSettings.iZ_Policy_Phishing_8) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_8_IZ_Partname2301) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_8_IZ_Partname2301) + { $complexDeviceSettings.Add('IZ_Policy_Phishing_8_IZ_Partname2301', $policySettings.DeviceSettings.iZ_Policy_Phishing_8_IZ_Partname2301) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_6) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_6) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_6', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_6) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_6_IZ_Partname1C00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_6_IZ_Partname1C00) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_6_IZ_Partname1C00', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_6_IZ_Partname1C00) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_7) + { $complexDeviceSettings.Add('IZ_PolicyAccessDataSourcesAcrossDomains_7', $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_7_IZ_Partname1406) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_7_IZ_Partname1406) + { $complexDeviceSettings.Add('IZ_PolicyAccessDataSourcesAcrossDomains_7_IZ_Partname1406', $policySettings.DeviceSettings.iZ_PolicyAccessDataSourcesAcrossDomains_7_IZ_Partname1406) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyActiveScripting_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyActiveScripting_7) + { $complexDeviceSettings.Add('IZ_PolicyActiveScripting_7', $policySettings.DeviceSettings.iZ_PolicyActiveScripting_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Partname1400) { + if ($null -ne $policySettings.DeviceSettings.iZ_Partname1400) + { $complexDeviceSettings.Add('IZ_Partname1400', $policySettings.DeviceSettings.iZ_Partname1400) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyBinaryBehaviors_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyBinaryBehaviors_7) + { $complexDeviceSettings.Add('IZ_PolicyBinaryBehaviors_7', $policySettings.DeviceSettings.iZ_PolicyBinaryBehaviors_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Partname2000) { + if ($null -ne $policySettings.DeviceSettings.iZ_Partname2000) + { $complexDeviceSettings.Add('IZ_Partname2000', $policySettings.DeviceSettings.iZ_Partname2000) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_7) + { $complexDeviceSettings.Add('IZ_PolicyAllowPasteViaScript_7', $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_7_IZ_Partname1407) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_7_IZ_Partname1407) + { $complexDeviceSettings.Add('IZ_PolicyAllowPasteViaScript_7_IZ_Partname1407', $policySettings.DeviceSettings.iZ_PolicyAllowPasteViaScript_7_IZ_Partname1407) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_7) + { $complexDeviceSettings.Add('IZ_PolicyDropOrPasteFiles_7', $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_7_IZ_Partname1802) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_7_IZ_Partname1802) + { $complexDeviceSettings.Add('IZ_PolicyDropOrPasteFiles_7_IZ_Partname1802', $policySettings.DeviceSettings.iZ_PolicyDropOrPasteFiles_7_IZ_Partname1802) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyFileDownload_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyFileDownload_7) + { $complexDeviceSettings.Add('IZ_PolicyFileDownload_7', $policySettings.DeviceSettings.iZ_PolicyFileDownload_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Partname1803) { + if ($null -ne $policySettings.DeviceSettings.iZ_Partname1803) + { $complexDeviceSettings.Add('IZ_Partname1803', $policySettings.DeviceSettings.iZ_Partname1803) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_XAML_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_XAML_7) + { $complexDeviceSettings.Add('IZ_Policy_XAML_7', $policySettings.DeviceSettings.iZ_Policy_XAML_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_XAML_7_IZ_Partname2402) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_XAML_7_IZ_Partname2402) + { $complexDeviceSettings.Add('IZ_Policy_XAML_7_IZ_Partname2402', $policySettings.DeviceSettings.iZ_Policy_XAML_7_IZ_Partname2402) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowMETAREFRESH_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowMETAREFRESH_7) + { $complexDeviceSettings.Add('IZ_PolicyAllowMETAREFRESH_7', $policySettings.DeviceSettings.iZ_PolicyAllowMETAREFRESH_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Partname1608) { + if ($null -ne $policySettings.DeviceSettings.iZ_Partname1608) + { $complexDeviceSettings.Add('IZ_Partname1608', $policySettings.DeviceSettings.iZ_Partname1608) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Restricted) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Restricted) + { $complexDeviceSettings.Add('IZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Restricted', $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Restricted) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Restricted_IZ_Partname120b) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Restricted_IZ_Partname120b) + { $complexDeviceSettings.Add('IZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Restricted_IZ_Partname120b', $policySettings.DeviceSettings.iZ_PolicyOnlyAllowApprovedDomainsToUseActiveXWithoutPrompt_Both_Restricted_IZ_Partname120b) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Restricted) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Restricted) + { $complexDeviceSettings.Add('IZ_PolicyAllowTDCControl_Both_Restricted', $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Restricted) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Restricted_IZ_Partname120c) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Restricted_IZ_Partname120c) + { $complexDeviceSettings.Add('IZ_PolicyAllowTDCControl_Both_Restricted_IZ_Partname120c', $policySettings.DeviceSettings.iZ_PolicyAllowTDCControl_Both_Restricted_IZ_Partname120c) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_7) + { $complexDeviceSettings.Add('IZ_PolicyWindowsRestrictionsURLaction_7', $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_7_IZ_Partname2102) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_7_IZ_Partname2102) + { $complexDeviceSettings.Add('IZ_PolicyWindowsRestrictionsURLaction_7_IZ_Partname2102', $policySettings.DeviceSettings.iZ_PolicyWindowsRestrictionsURLaction_7_IZ_Partname2102) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_7) + { $complexDeviceSettings.Add('IZ_Policy_WebBrowserControl_7', $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_7_IZ_Partname1206) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_7_IZ_Partname1206) + { $complexDeviceSettings.Add('IZ_Policy_WebBrowserControl_7_IZ_Partname1206', $policySettings.DeviceSettings.iZ_Policy_WebBrowserControl_7_IZ_Partname1206) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_7) + { $complexDeviceSettings.Add('IZ_Policy_AllowScriptlets_7', $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_7_IZ_Partname1209) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_7_IZ_Partname1209) + { $complexDeviceSettings.Add('IZ_Policy_AllowScriptlets_7_IZ_Partname1209', $policySettings.DeviceSettings.iZ_Policy_AllowScriptlets_7_IZ_Partname1209) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_7) + { $complexDeviceSettings.Add('IZ_Policy_ScriptStatusBar_7', $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_7_IZ_Partname2103) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_7_IZ_Partname2103) + { $complexDeviceSettings.Add('IZ_Policy_ScriptStatusBar_7_IZ_Partname2103', $policySettings.DeviceSettings.iZ_Policy_ScriptStatusBar_7_IZ_Partname2103) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_7) + { $complexDeviceSettings.Add('IZ_PolicyAllowVBScript_7', $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_7_IZ_Partname140C) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_7_IZ_Partname140C) + { $complexDeviceSettings.Add('IZ_PolicyAllowVBScript_7_IZ_Partname140C', $policySettings.DeviceSettings.iZ_PolicyAllowVBScript_7_IZ_Partname140C) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_7) + { $complexDeviceSettings.Add('IZ_PolicyNotificationBarDownloadURLaction_7', $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_7_IZ_Partname2200) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_7_IZ_Partname2200) + { $complexDeviceSettings.Add('IZ_PolicyNotificationBarDownloadURLaction_7_IZ_Partname2200', $policySettings.DeviceSettings.iZ_PolicyNotificationBarDownloadURLaction_7_IZ_Partname2200) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_7) + { $complexDeviceSettings.Add('IZ_PolicyAntiMalwareCheckingOfActiveXControls_7', $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_7_IZ_Partname270C) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_7_IZ_Partname270C) + { $complexDeviceSettings.Add('IZ_PolicyAntiMalwareCheckingOfActiveXControls_7_IZ_Partname270C', $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_7_IZ_Partname270C) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_7) + { $complexDeviceSettings.Add('IZ_PolicyDownloadSignedActiveX_7', $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_7_IZ_Partname1001) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_7_IZ_Partname1001) + { $complexDeviceSettings.Add('IZ_PolicyDownloadSignedActiveX_7_IZ_Partname1001', $policySettings.DeviceSettings.iZ_PolicyDownloadSignedActiveX_7_IZ_Partname1001) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_7) + { $complexDeviceSettings.Add('IZ_PolicyDownloadUnsignedActiveX_7', $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_7_IZ_Partname1004) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_7_IZ_Partname1004) + { $complexDeviceSettings.Add('IZ_PolicyDownloadUnsignedActiveX_7_IZ_Partname1004', $policySettings.DeviceSettings.iZ_PolicyDownloadUnsignedActiveX_7_IZ_Partname1004) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Restricted) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Restricted) + { $complexDeviceSettings.Add('IZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Restricted', $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Restricted) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Restricted_IZ_Partname2709) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Restricted_IZ_Partname2709) + { $complexDeviceSettings.Add('IZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Restricted_IZ_Partname2709', $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsAcrossWindows_Both_Restricted_IZ_Partname2709) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Restricted) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Restricted) + { $complexDeviceSettings.Add('IZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Restricted', $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Restricted) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Restricted_IZ_Partname2708) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Restricted_IZ_Partname2708) + { $complexDeviceSettings.Add('IZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Restricted_IZ_Partname2708', $policySettings.DeviceSettings.iZ_PolicyDragDropAcrossDomainsWithinWindow_Both_Restricted_IZ_Partname2708) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_7) + { $complexDeviceSettings.Add('IZ_Policy_LocalPathForUpload_7', $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_7_IZ_Partname160A) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_7_IZ_Partname160A) + { $complexDeviceSettings.Add('IZ_Policy_LocalPathForUpload_7_IZ_Partname160A', $policySettings.DeviceSettings.iZ_Policy_LocalPathForUpload_7_IZ_Partname160A) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_7) + { $complexDeviceSettings.Add('IZ_PolicyScriptActiveXNotMarkedSafe_7', $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_7_IZ_Partname1201) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_7_IZ_Partname1201) + { $complexDeviceSettings.Add('IZ_PolicyScriptActiveXNotMarkedSafe_7_IZ_Partname1201', $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_7_IZ_Partname1201) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_7) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_7', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_7_IZ_Partname1C00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_7_IZ_Partname1C00) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_7_IZ_Partname1C00', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_7_IZ_Partname1C00) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_7) + { $complexDeviceSettings.Add('IZ_PolicyLaunchAppsAndFilesInIFRAME_7', $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_7_IZ_Partname1804) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_7_IZ_Partname1804) + { $complexDeviceSettings.Add('IZ_PolicyLaunchAppsAndFilesInIFRAME_7_IZ_Partname1804', $policySettings.DeviceSettings.iZ_PolicyLaunchAppsAndFilesInIFRAME_7_IZ_Partname1804) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLogon_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLogon_7) + { $complexDeviceSettings.Add('IZ_PolicyLogon_7', $policySettings.DeviceSettings.iZ_PolicyLogon_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLogon_7_IZ_Partname1A00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyLogon_7_IZ_Partname1A00) + { $complexDeviceSettings.Add('IZ_PolicyLogon_7_IZ_Partname1A00', $policySettings.DeviceSettings.iZ_PolicyLogon_7_IZ_Partname1A00) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_7) + { $complexDeviceSettings.Add('IZ_PolicyNavigateSubframesAcrossDomains_7', $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_7_IZ_Partname1607) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_7_IZ_Partname1607) + { $complexDeviceSettings.Add('IZ_PolicyNavigateSubframesAcrossDomains_7_IZ_Partname1607', $policySettings.DeviceSettings.iZ_PolicyNavigateSubframesAcrossDomains_7_IZ_Partname1607) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_7) + { $complexDeviceSettings.Add('IZ_PolicyUnsignedFrameworkComponentsURLaction_7', $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_7_IZ_Partname2004) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_7_IZ_Partname2004) + { $complexDeviceSettings.Add('IZ_PolicyUnsignedFrameworkComponentsURLaction_7_IZ_Partname2004', $policySettings.DeviceSettings.iZ_PolicyUnsignedFrameworkComponentsURLaction_7_IZ_Partname2004) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_7) + { $complexDeviceSettings.Add('IZ_PolicySignedFrameworkComponentsURLaction_7', $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_7_IZ_Partname2001) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_7_IZ_Partname2001) + { $complexDeviceSettings.Add('IZ_PolicySignedFrameworkComponentsURLaction_7_IZ_Partname2001', $policySettings.DeviceSettings.iZ_PolicySignedFrameworkComponentsURLaction_7_IZ_Partname2001) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyRunActiveXControls_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyRunActiveXControls_7) + { $complexDeviceSettings.Add('IZ_PolicyRunActiveXControls_7', $policySettings.DeviceSettings.iZ_PolicyRunActiveXControls_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Partname1200) { + if ($null -ne $policySettings.DeviceSettings.iZ_Partname1200) + { $complexDeviceSettings.Add('IZ_Partname1200', $policySettings.DeviceSettings.iZ_Partname1200) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXMarkedSafe_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXMarkedSafe_7) + { $complexDeviceSettings.Add('IZ_PolicyScriptActiveXMarkedSafe_7', $policySettings.DeviceSettings.iZ_PolicyScriptActiveXMarkedSafe_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Partname1405) { + if ($null -ne $policySettings.DeviceSettings.iZ_Partname1405) + { $complexDeviceSettings.Add('IZ_Partname1405', $policySettings.DeviceSettings.iZ_Partname1405) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptingOfJavaApplets_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptingOfJavaApplets_7) + { $complexDeviceSettings.Add('IZ_PolicyScriptingOfJavaApplets_7', $policySettings.DeviceSettings.iZ_PolicyScriptingOfJavaApplets_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Partname1402) { + if ($null -ne $policySettings.DeviceSettings.iZ_Partname1402) + { $complexDeviceSettings.Add('IZ_Partname1402', $policySettings.DeviceSettings.iZ_Partname1402) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_7) + { $complexDeviceSettings.Add('IZ_Policy_UnsafeFiles_7', $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_7_IZ_Partname1806) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_7_IZ_Partname1806) + { $complexDeviceSettings.Add('IZ_Policy_UnsafeFiles_7_IZ_Partname1806', $policySettings.DeviceSettings.iZ_Policy_UnsafeFiles_7_IZ_Partname1806) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Restricted) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Restricted) + { $complexDeviceSettings.Add('IZ_PolicyTurnOnXSSFilter_Both_Restricted', $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Restricted) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Restricted_IZ_Partname1409) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Restricted_IZ_Partname1409) + { $complexDeviceSettings.Add('IZ_PolicyTurnOnXSSFilter_Both_Restricted_IZ_Partname1409', $policySettings.DeviceSettings.iZ_PolicyTurnOnXSSFilter_Both_Restricted_IZ_Partname1409) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_7) + { $complexDeviceSettings.Add('IZ_Policy_TurnOnProtectedMode_7', $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_7_IZ_Partname2500) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_7_IZ_Partname2500) + { $complexDeviceSettings.Add('IZ_Policy_TurnOnProtectedMode_7_IZ_Partname2500', $policySettings.DeviceSettings.iZ_Policy_TurnOnProtectedMode_7_IZ_Partname2500) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_7) + { $complexDeviceSettings.Add('IZ_Policy_Phishing_7', $policySettings.DeviceSettings.iZ_Policy_Phishing_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_7_IZ_Partname2301) { + if ($null -ne $policySettings.DeviceSettings.iZ_Policy_Phishing_7_IZ_Partname2301) + { $complexDeviceSettings.Add('IZ_Policy_Phishing_7_IZ_Partname2301', $policySettings.DeviceSettings.iZ_Policy_Phishing_7_IZ_Partname2301) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_7) + { $complexDeviceSettings.Add('IZ_PolicyBlockPopupWindows_7', $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_7_IZ_Partname1809) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_7_IZ_Partname1809) + { $complexDeviceSettings.Add('IZ_PolicyBlockPopupWindows_7_IZ_Partname1809', $policySettings.DeviceSettings.iZ_PolicyBlockPopupWindows_7_IZ_Partname1809) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_7) + { $complexDeviceSettings.Add('IZ_PolicyUserdataPersistence_7', $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_7_IZ_Partname1606) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_7_IZ_Partname1606) + { $complexDeviceSettings.Add('IZ_PolicyUserdataPersistence_7_IZ_Partname1606', $policySettings.DeviceSettings.iZ_PolicyUserdataPersistence_7_IZ_Partname1606) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_7) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_7) + { $complexDeviceSettings.Add('IZ_PolicyZoneElevationURLaction_7', $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_7) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_7_IZ_Partname2101) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_7_IZ_Partname2101) + { $complexDeviceSettings.Add('IZ_PolicyZoneElevationURLaction_7_IZ_Partname2101', $policySettings.DeviceSettings.iZ_PolicyZoneElevationURLaction_7_IZ_Partname2101) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_5) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_5) + { $complexDeviceSettings.Add('IZ_PolicyAntiMalwareCheckingOfActiveXControls_5', $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_5) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_5_IZ_Partname270C) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_5_IZ_Partname270C) + { $complexDeviceSettings.Add('IZ_PolicyAntiMalwareCheckingOfActiveXControls_5_IZ_Partname270C', $policySettings.DeviceSettings.iZ_PolicyAntiMalwareCheckingOfActiveXControls_5_IZ_Partname270C) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_5) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_5) + { $complexDeviceSettings.Add('IZ_PolicyScriptActiveXNotMarkedSafe_5', $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_5) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_5_IZ_Partname1201) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_5_IZ_Partname1201) + { $complexDeviceSettings.Add('IZ_PolicyScriptActiveXNotMarkedSafe_5_IZ_Partname1201', $policySettings.DeviceSettings.iZ_PolicyScriptActiveXNotMarkedSafe_5_IZ_Partname1201) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_5) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_5) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_5', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_5) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_5_IZ_Partname1C00) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_5_IZ_Partname1C00) + { $complexDeviceSettings.Add('IZ_PolicyJavaPermissions_5_IZ_Partname1C00', $policySettings.DeviceSettings.iZ_PolicyJavaPermissions_5_IZ_Partname1C00) } - if ($null -ne $policySettings.DeviceSettings.iZ_PolicyWarnCertMismatch) { + if ($null -ne $policySettings.DeviceSettings.iZ_PolicyWarnCertMismatch) + { $complexDeviceSettings.Add('IZ_PolicyWarnCertMismatch', $policySettings.DeviceSettings.iZ_PolicyWarnCertMismatch) } - if ($null -ne $policySettings.DeviceSettings.disableSafetyFilterOverride) { + if ($null -ne $policySettings.DeviceSettings.disableSafetyFilterOverride) + { $complexDeviceSettings.Add('DisableSafetyFilterOverride', $policySettings.DeviceSettings.disableSafetyFilterOverride) } - if ($null -ne $policySettings.DeviceSettings.disableSafetyFilterOverrideForAppRepUnknown) { + if ($null -ne $policySettings.DeviceSettings.disableSafetyFilterOverrideForAppRepUnknown) + { $complexDeviceSettings.Add('DisableSafetyFilterOverrideForAppRepUnknown', $policySettings.DeviceSettings.disableSafetyFilterOverrideForAppRepUnknown) } - if ($null -ne $policySettings.DeviceSettings.disable_Managing_Safety_Filter_IE9) { + if ($null -ne $policySettings.DeviceSettings.disable_Managing_Safety_Filter_IE9) + { $complexDeviceSettings.Add('Disable_Managing_Safety_Filter_IE9', $policySettings.DeviceSettings.disable_Managing_Safety_Filter_IE9) } - if ($null -ne $policySettings.DeviceSettings.iE9SafetyFilterOptions) { + if ($null -ne $policySettings.DeviceSettings.iE9SafetyFilterOptions) + { $complexDeviceSettings.Add('IE9SafetyFilterOptions', $policySettings.DeviceSettings.iE9SafetyFilterOptions) } - if ($null -ne $policySettings.DeviceSettings.disablePerUserActiveXInstall) { + if ($null -ne $policySettings.DeviceSettings.disablePerUserActiveXInstall) + { $complexDeviceSettings.Add('DisablePerUserActiveXInstall', $policySettings.DeviceSettings.disablePerUserActiveXInstall) } - if ($null -ne $policySettings.DeviceSettings.verMgmtDisableRunThisTime) { + if ($null -ne $policySettings.DeviceSettings.verMgmtDisableRunThisTime) + { $complexDeviceSettings.Add('VerMgmtDisableRunThisTime', $policySettings.DeviceSettings.verMgmtDisableRunThisTime) } - if ($null -ne $policySettings.DeviceSettings.verMgmtDisable) { + if ($null -ne $policySettings.DeviceSettings.verMgmtDisable) + { $complexDeviceSettings.Add('VerMgmtDisable', $policySettings.DeviceSettings.verMgmtDisable) } - if ($null -ne $policySettings.DeviceSettings.advanced_EnableSSL3Fallback) { + if ($null -ne $policySettings.DeviceSettings.advanced_EnableSSL3Fallback) + { $complexDeviceSettings.Add('Advanced_EnableSSL3Fallback', $policySettings.DeviceSettings.advanced_EnableSSL3Fallback) } - if ($null -ne $policySettings.DeviceSettings.advanced_EnableSSL3FallbackOptions) { + if ($null -ne $policySettings.DeviceSettings.advanced_EnableSSL3FallbackOptions) + { $complexDeviceSettings.Add('Advanced_EnableSSL3FallbackOptions', $policySettings.DeviceSettings.advanced_EnableSSL3FallbackOptions) } - if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_5) { + if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_5) + { $complexDeviceSettings.Add('IESF_PolicyExplorerProcesses_5', $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_5) } - if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_6) { + if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_6) + { $complexDeviceSettings.Add('IESF_PolicyExplorerProcesses_6', $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_6) } - if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_3) { + if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_3) + { $complexDeviceSettings.Add('IESF_PolicyExplorerProcesses_3', $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_3) } - if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_10) { + if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_10) + { $complexDeviceSettings.Add('IESF_PolicyExplorerProcesses_10', $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_10) } - if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_9) { + if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_9) + { $complexDeviceSettings.Add('IESF_PolicyExplorerProcesses_9', $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_9) } - if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_11) { + if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_11) + { $complexDeviceSettings.Add('IESF_PolicyExplorerProcesses_11', $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_11) } - if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_12) { + if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_12) + { $complexDeviceSettings.Add('IESF_PolicyExplorerProcesses_12', $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_12) } - if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_8) { + if ($null -ne $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_8) + { $complexDeviceSettings.Add('IESF_PolicyExplorerProcesses_8', $policySettings.DeviceSettings.iESF_PolicyExplorerProcesses_8) } - if ($null -ne $policySettings.DeviceSettings.security_zones_map_edit) { + if ($null -ne $policySettings.DeviceSettings.security_zones_map_edit) + { $complexDeviceSettings.Add('Security_zones_map_edit', $policySettings.DeviceSettings.security_zones_map_edit) } - if ($null -ne $policySettings.DeviceSettings.security_options_edit) { + if ($null -ne $policySettings.DeviceSettings.security_options_edit) + { $complexDeviceSettings.Add('Security_options_edit', $policySettings.DeviceSettings.security_options_edit) } - if ($null -ne $policySettings.DeviceSettings.security_HKLM_only) { + if ($null -ne $policySettings.DeviceSettings.security_HKLM_only) + { $complexDeviceSettings.Add('Security_HKLM_only', $policySettings.DeviceSettings.security_HKLM_only) } - if ($null -ne $policySettings.DeviceSettings.onlyUseAXISForActiveXInstall) { + if ($null -ne $policySettings.DeviceSettings.onlyUseAXISForActiveXInstall) + { $complexDeviceSettings.Add('OnlyUseAXISForActiveXInstall', $policySettings.DeviceSettings.onlyUseAXISForActiveXInstall) } - if ($null -ne $policySettings.DeviceSettings.addonManagement_RestrictCrashDetection) { + if ($null -ne $policySettings.DeviceSettings.addonManagement_RestrictCrashDetection) + { $complexDeviceSettings.Add('AddonManagement_RestrictCrashDetection', $policySettings.DeviceSettings.addonManagement_RestrictCrashDetection) } - if ($null -ne $policySettings.DeviceSettings.disable_Security_Settings_Check) { + if ($null -ne $policySettings.DeviceSettings.disable_Security_Settings_Check) + { $complexDeviceSettings.Add('Disable_Security_Settings_Check', $policySettings.DeviceSettings.disable_Security_Settings_Check) } - if ($null -ne $policySettings.DeviceSettings.disableBlockAtFirstSeen) { + if ($null -ne $policySettings.DeviceSettings.disableBlockAtFirstSeen) + { $complexDeviceSettings.Add('DisableBlockAtFirstSeen', $policySettings.DeviceSettings.disableBlockAtFirstSeen) } - if ($null -ne $policySettings.DeviceSettings.realtimeProtection_DisableScanOnRealtimeEnable) { + if ($null -ne $policySettings.DeviceSettings.realtimeProtection_DisableScanOnRealtimeEnable) + { $complexDeviceSettings.Add('RealtimeProtection_DisableScanOnRealtimeEnable', $policySettings.DeviceSettings.realtimeProtection_DisableScanOnRealtimeEnable) } - if ($null -ne $policySettings.DeviceSettings.scan_DisablePackedExeScanning) { + if ($null -ne $policySettings.DeviceSettings.scan_DisablePackedExeScanning) + { $complexDeviceSettings.Add('Scan_DisablePackedExeScanning', $policySettings.DeviceSettings.scan_DisablePackedExeScanning) } - if ($null -ne $policySettings.DeviceSettings.disableRoutinelyTakingAction) { + if ($null -ne $policySettings.DeviceSettings.disableRoutinelyTakingAction) + { $complexDeviceSettings.Add('DisableRoutinelyTakingAction', $policySettings.DeviceSettings.disableRoutinelyTakingAction) } - if ($null -ne $policySettings.DeviceSettings.tS_CLIENT_DISABLE_PASSWORD_SAVING_2) { + if ($null -ne $policySettings.DeviceSettings.tS_CLIENT_DISABLE_PASSWORD_SAVING_2) + { $complexDeviceSettings.Add('TS_CLIENT_DISABLE_PASSWORD_SAVING_2', $policySettings.DeviceSettings.tS_CLIENT_DISABLE_PASSWORD_SAVING_2) } - if ($null -ne $policySettings.DeviceSettings.tS_CLIENT_DRIVE_M) { + if ($null -ne $policySettings.DeviceSettings.tS_CLIENT_DRIVE_M) + { $complexDeviceSettings.Add('TS_CLIENT_DRIVE_M', $policySettings.DeviceSettings.tS_CLIENT_DRIVE_M) } - if ($null -ne $policySettings.DeviceSettings.tS_PASSWORD) { + if ($null -ne $policySettings.DeviceSettings.tS_PASSWORD) + { $complexDeviceSettings.Add('TS_PASSWORD', $policySettings.DeviceSettings.tS_PASSWORD) } - if ($null -ne $policySettings.DeviceSettings.tS_RPC_ENCRYPTION) { + if ($null -ne $policySettings.DeviceSettings.tS_RPC_ENCRYPTION) + { $complexDeviceSettings.Add('TS_RPC_ENCRYPTION', $policySettings.DeviceSettings.tS_RPC_ENCRYPTION) } - if ($null -ne $policySettings.DeviceSettings.tS_ENCRYPTION_POLICY) { + if ($null -ne $policySettings.DeviceSettings.tS_ENCRYPTION_POLICY) + { $complexDeviceSettings.Add('TS_ENCRYPTION_POLICY', $policySettings.DeviceSettings.tS_ENCRYPTION_POLICY) } - if ($null -ne $policySettings.DeviceSettings.tS_ENCRYPTION_LEVEL) { + if ($null -ne $policySettings.DeviceSettings.tS_ENCRYPTION_LEVEL) + { $complexDeviceSettings.Add('TS_ENCRYPTION_LEVEL', $policySettings.DeviceSettings.tS_ENCRYPTION_LEVEL) } - if ($null -ne $policySettings.DeviceSettings.disable_Downloading_of_Enclosures) { + if ($null -ne $policySettings.DeviceSettings.disable_Downloading_of_Enclosures) + { $complexDeviceSettings.Add('Disable_Downloading_of_Enclosures', $policySettings.DeviceSettings.disable_Downloading_of_Enclosures) } - if ($null -ne $policySettings.DeviceSettings.enableMPRNotifications) { + if ($null -ne $policySettings.DeviceSettings.enableMPRNotifications) + { $complexDeviceSettings.Add('EnableMPRNotifications', $policySettings.DeviceSettings.enableMPRNotifications) } - if ($null -ne $policySettings.DeviceSettings.automaticRestartSignOn) { + if ($null -ne $policySettings.DeviceSettings.automaticRestartSignOn) + { $complexDeviceSettings.Add('AutomaticRestartSignOn', $policySettings.DeviceSettings.automaticRestartSignOn) } - if ($null -ne $policySettings.DeviceSettings.enableScriptBlockLogging) { + if ($null -ne $policySettings.DeviceSettings.enableScriptBlockLogging) + { $complexDeviceSettings.Add('EnableScriptBlockLogging', $policySettings.DeviceSettings.enableScriptBlockLogging) } - if ($null -ne $policySettings.DeviceSettings.enableScriptBlockInvocationLogging) { + if ($null -ne $policySettings.DeviceSettings.enableScriptBlockInvocationLogging) + { $complexDeviceSettings.Add('EnableScriptBlockInvocationLogging', $policySettings.DeviceSettings.enableScriptBlockInvocationLogging) } - if ($null -ne $policySettings.DeviceSettings.allowBasic_2) { + if ($null -ne $policySettings.DeviceSettings.allowBasic_2) + { $complexDeviceSettings.Add('AllowBasic_2', $policySettings.DeviceSettings.allowBasic_2) } - if ($null -ne $policySettings.DeviceSettings.allowUnencrypted_2) { + if ($null -ne $policySettings.DeviceSettings.allowUnencrypted_2) + { $complexDeviceSettings.Add('AllowUnencrypted_2', $policySettings.DeviceSettings.allowUnencrypted_2) } - if ($null -ne $policySettings.DeviceSettings.disallowDigest) { + if ($null -ne $policySettings.DeviceSettings.disallowDigest) + { $complexDeviceSettings.Add('DisallowDigest', $policySettings.DeviceSettings.disallowDigest) } - if ($null -ne $policySettings.DeviceSettings.allowBasic_1) { + if ($null -ne $policySettings.DeviceSettings.allowBasic_1) + { $complexDeviceSettings.Add('AllowBasic_1', $policySettings.DeviceSettings.allowBasic_1) } - if ($null -ne $policySettings.DeviceSettings.allowUnencrypted_1) { + if ($null -ne $policySettings.DeviceSettings.allowUnencrypted_1) + { $complexDeviceSettings.Add('AllowUnencrypted_1', $policySettings.DeviceSettings.allowUnencrypted_1) } - if ($null -ne $policySettings.DeviceSettings.disableRunAs) { + if ($null -ne $policySettings.DeviceSettings.disableRunAs) + { $complexDeviceSettings.Add('DisableRunAs', $policySettings.DeviceSettings.disableRunAs) } - if ($null -ne $policySettings.DeviceSettings.accountLogon_AuditCredentialValidation) { + if ($null -ne $policySettings.DeviceSettings.accountLogon_AuditCredentialValidation) + { $complexDeviceSettings.Add('AccountLogon_AuditCredentialValidation', $policySettings.DeviceSettings.accountLogon_AuditCredentialValidation) } - if ($null -ne $policySettings.DeviceSettings.accountLogonLogoff_AuditAccountLockout) { + if ($null -ne $policySettings.DeviceSettings.accountLogonLogoff_AuditAccountLockout) + { $complexDeviceSettings.Add('AccountLogonLogoff_AuditAccountLockout', $policySettings.DeviceSettings.accountLogonLogoff_AuditAccountLockout) } - if ($null -ne $policySettings.DeviceSettings.accountLogonLogoff_AuditGroupMembership) { + if ($null -ne $policySettings.DeviceSettings.accountLogonLogoff_AuditGroupMembership) + { $complexDeviceSettings.Add('AccountLogonLogoff_AuditGroupMembership', $policySettings.DeviceSettings.accountLogonLogoff_AuditGroupMembership) } - if ($null -ne $policySettings.DeviceSettings.accountLogonLogoff_AuditLogon) { + if ($null -ne $policySettings.DeviceSettings.accountLogonLogoff_AuditLogon) + { $complexDeviceSettings.Add('AccountLogonLogoff_AuditLogon', $policySettings.DeviceSettings.accountLogonLogoff_AuditLogon) } - if ($null -ne $policySettings.DeviceSettings.policyChange_AuditAuthenticationPolicyChange) { + if ($null -ne $policySettings.DeviceSettings.policyChange_AuditAuthenticationPolicyChange) + { $complexDeviceSettings.Add('PolicyChange_AuditAuthenticationPolicyChange', $policySettings.DeviceSettings.policyChange_AuditAuthenticationPolicyChange) } - if ($null -ne $policySettings.DeviceSettings.policyChange_AuditPolicyChange) { + if ($null -ne $policySettings.DeviceSettings.policyChange_AuditPolicyChange) + { $complexDeviceSettings.Add('PolicyChange_AuditPolicyChange', $policySettings.DeviceSettings.policyChange_AuditPolicyChange) } - if ($null -ne $policySettings.DeviceSettings.objectAccess_AuditFileShare) { + if ($null -ne $policySettings.DeviceSettings.objectAccess_AuditFileShare) + { $complexDeviceSettings.Add('ObjectAccess_AuditFileShare', $policySettings.DeviceSettings.objectAccess_AuditFileShare) } - if ($null -ne $policySettings.DeviceSettings.accountLogonLogoff_AuditOtherLogonLogoffEvents) { + if ($null -ne $policySettings.DeviceSettings.accountLogonLogoff_AuditOtherLogonLogoffEvents) + { $complexDeviceSettings.Add('AccountLogonLogoff_AuditOtherLogonLogoffEvents', $policySettings.DeviceSettings.accountLogonLogoff_AuditOtherLogonLogoffEvents) } - if ($null -ne $policySettings.DeviceSettings.accountManagement_AuditSecurityGroupManagement) { + if ($null -ne $policySettings.DeviceSettings.accountManagement_AuditSecurityGroupManagement) + { $complexDeviceSettings.Add('AccountManagement_AuditSecurityGroupManagement', $policySettings.DeviceSettings.accountManagement_AuditSecurityGroupManagement) } - if ($null -ne $policySettings.DeviceSettings.system_AuditSecuritySystemExtension) { + if ($null -ne $policySettings.DeviceSettings.system_AuditSecuritySystemExtension) + { $complexDeviceSettings.Add('System_AuditSecuritySystemExtension', $policySettings.DeviceSettings.system_AuditSecuritySystemExtension) } - if ($null -ne $policySettings.DeviceSettings.accountLogonLogoff_AuditSpecialLogon) { + if ($null -ne $policySettings.DeviceSettings.accountLogonLogoff_AuditSpecialLogon) + { $complexDeviceSettings.Add('AccountLogonLogoff_AuditSpecialLogon', $policySettings.DeviceSettings.accountLogonLogoff_AuditSpecialLogon) } - if ($null -ne $policySettings.DeviceSettings.accountManagement_AuditUserAccountManagement) { + if ($null -ne $policySettings.DeviceSettings.accountManagement_AuditUserAccountManagement) + { $complexDeviceSettings.Add('AccountManagement_AuditUserAccountManagement', $policySettings.DeviceSettings.accountManagement_AuditUserAccountManagement) } - if ($null -ne $policySettings.DeviceSettings.detailedTracking_AuditPNPActivity) { + if ($null -ne $policySettings.DeviceSettings.detailedTracking_AuditPNPActivity) + { $complexDeviceSettings.Add('DetailedTracking_AuditPNPActivity', $policySettings.DeviceSettings.detailedTracking_AuditPNPActivity) } - if ($null -ne $policySettings.DeviceSettings.detailedTracking_AuditProcessCreation) { + if ($null -ne $policySettings.DeviceSettings.detailedTracking_AuditProcessCreation) + { $complexDeviceSettings.Add('DetailedTracking_AuditProcessCreation', $policySettings.DeviceSettings.detailedTracking_AuditProcessCreation) } - if ($null -ne $policySettings.DeviceSettings.objectAccess_AuditDetailedFileShare) { + if ($null -ne $policySettings.DeviceSettings.objectAccess_AuditDetailedFileShare) + { $complexDeviceSettings.Add('ObjectAccess_AuditDetailedFileShare', $policySettings.DeviceSettings.objectAccess_AuditDetailedFileShare) } - if ($null -ne $policySettings.DeviceSettings.objectAccess_AuditOtherObjectAccessEvents) { + if ($null -ne $policySettings.DeviceSettings.objectAccess_AuditOtherObjectAccessEvents) + { $complexDeviceSettings.Add('ObjectAccess_AuditOtherObjectAccessEvents', $policySettings.DeviceSettings.objectAccess_AuditOtherObjectAccessEvents) } - if ($null -ne $policySettings.DeviceSettings.objectAccess_AuditRemovableStorage) { + if ($null -ne $policySettings.DeviceSettings.objectAccess_AuditRemovableStorage) + { $complexDeviceSettings.Add('ObjectAccess_AuditRemovableStorage', $policySettings.DeviceSettings.objectAccess_AuditRemovableStorage) } - if ($null -ne $policySettings.DeviceSettings.policyChange_AuditMPSSVCRuleLevelPolicyChange) { + if ($null -ne $policySettings.DeviceSettings.policyChange_AuditMPSSVCRuleLevelPolicyChange) + { $complexDeviceSettings.Add('PolicyChange_AuditMPSSVCRuleLevelPolicyChange', $policySettings.DeviceSettings.policyChange_AuditMPSSVCRuleLevelPolicyChange) } - if ($null -ne $policySettings.DeviceSettings.policyChange_AuditOtherPolicyChangeEvents) { + if ($null -ne $policySettings.DeviceSettings.policyChange_AuditOtherPolicyChangeEvents) + { $complexDeviceSettings.Add('PolicyChange_AuditOtherPolicyChangeEvents', $policySettings.DeviceSettings.policyChange_AuditOtherPolicyChangeEvents) } - if ($null -ne $policySettings.DeviceSettings.privilegeUse_AuditSensitivePrivilegeUse) { + if ($null -ne $policySettings.DeviceSettings.privilegeUse_AuditSensitivePrivilegeUse) + { $complexDeviceSettings.Add('PrivilegeUse_AuditSensitivePrivilegeUse', $policySettings.DeviceSettings.privilegeUse_AuditSensitivePrivilegeUse) } - if ($null -ne $policySettings.DeviceSettings.system_AuditOtherSystemEvents) { + if ($null -ne $policySettings.DeviceSettings.system_AuditOtherSystemEvents) + { $complexDeviceSettings.Add('System_AuditOtherSystemEvents', $policySettings.DeviceSettings.system_AuditOtherSystemEvents) } - if ($null -ne $policySettings.DeviceSettings.system_AuditSecurityStateChange) { + if ($null -ne $policySettings.DeviceSettings.system_AuditSecurityStateChange) + { $complexDeviceSettings.Add('System_AuditSecurityStateChange', $policySettings.DeviceSettings.system_AuditSecurityStateChange) } - if ($null -ne $policySettings.DeviceSettings.system_AuditSystemIntegrity) { + if ($null -ne $policySettings.DeviceSettings.system_AuditSystemIntegrity) + { $complexDeviceSettings.Add('System_AuditSystemIntegrity', $policySettings.DeviceSettings.system_AuditSystemIntegrity) } - if ($null -ne $policySettings.DeviceSettings.allowPasswordManager) { + if ($null -ne $policySettings.DeviceSettings.allowPasswordManager) + { $complexDeviceSettings.Add('AllowPasswordManager', $policySettings.DeviceSettings.allowPasswordManager) } - if ($null -ne $policySettings.DeviceSettings.allowSmartScreen) { + if ($null -ne $policySettings.DeviceSettings.allowSmartScreen) + { $complexDeviceSettings.Add('AllowSmartScreen', $policySettings.DeviceSettings.allowSmartScreen) } - if ($null -ne $policySettings.DeviceSettings.preventCertErrorOverrides) { + if ($null -ne $policySettings.DeviceSettings.preventCertErrorOverrides) + { $complexDeviceSettings.Add('PreventCertErrorOverrides', $policySettings.DeviceSettings.preventCertErrorOverrides) } - if ($null -ne $policySettings.DeviceSettings.browser_PreventSmartScreenPromptOverride) { + if ($null -ne $policySettings.DeviceSettings.browser_PreventSmartScreenPromptOverride) + { $complexDeviceSettings.Add('Browser_PreventSmartScreenPromptOverride', $policySettings.DeviceSettings.browser_PreventSmartScreenPromptOverride) } - if ($null -ne $policySettings.DeviceSettings.preventSmartScreenPromptOverrideForFiles) { + if ($null -ne $policySettings.DeviceSettings.preventSmartScreenPromptOverrideForFiles) + { $complexDeviceSettings.Add('PreventSmartScreenPromptOverrideForFiles', $policySettings.DeviceSettings.preventSmartScreenPromptOverrideForFiles) } - if ($null -ne $policySettings.DeviceSettings.allowDirectMemoryAccess) { + if ($null -ne $policySettings.DeviceSettings.allowDirectMemoryAccess) + { $complexDeviceSettings.Add('AllowDirectMemoryAccess', $policySettings.DeviceSettings.allowDirectMemoryAccess) } - if ($null -ne $policySettings.DeviceSettings.allowArchiveScanning) { + if ($null -ne $policySettings.DeviceSettings.allowArchiveScanning) + { $complexDeviceSettings.Add('AllowArchiveScanning', $policySettings.DeviceSettings.allowArchiveScanning) } - if ($null -ne $policySettings.DeviceSettings.allowBehaviorMonitoring) { + if ($null -ne $policySettings.DeviceSettings.allowBehaviorMonitoring) + { $complexDeviceSettings.Add('AllowBehaviorMonitoring', $policySettings.DeviceSettings.allowBehaviorMonitoring) } - if ($null -ne $policySettings.DeviceSettings.allowCloudProtection) { + if ($null -ne $policySettings.DeviceSettings.allowCloudProtection) + { $complexDeviceSettings.Add('AllowCloudProtection', $policySettings.DeviceSettings.allowCloudProtection) } - if ($null -ne $policySettings.DeviceSettings.allowFullScanRemovableDriveScanning) { + if ($null -ne $policySettings.DeviceSettings.allowFullScanRemovableDriveScanning) + { $complexDeviceSettings.Add('AllowFullScanRemovableDriveScanning', $policySettings.DeviceSettings.allowFullScanRemovableDriveScanning) } - if ($null -ne $policySettings.DeviceSettings.allowOnAccessProtection) { + if ($null -ne $policySettings.DeviceSettings.allowOnAccessProtection) + { $complexDeviceSettings.Add('AllowOnAccessProtection', $policySettings.DeviceSettings.allowOnAccessProtection) } - if ($null -ne $policySettings.DeviceSettings.allowRealtimeMonitoring) { + if ($null -ne $policySettings.DeviceSettings.allowRealtimeMonitoring) + { $complexDeviceSettings.Add('AllowRealtimeMonitoring', $policySettings.DeviceSettings.allowRealtimeMonitoring) } - if ($null -ne $policySettings.DeviceSettings.allowIOAVProtection) { + if ($null -ne $policySettings.DeviceSettings.allowIOAVProtection) + { $complexDeviceSettings.Add('AllowIOAVProtection', $policySettings.DeviceSettings.allowIOAVProtection) } - if ($null -ne $policySettings.DeviceSettings.allowScriptScanning) { + if ($null -ne $policySettings.DeviceSettings.allowScriptScanning) + { $complexDeviceSettings.Add('AllowScriptScanning', $policySettings.DeviceSettings.allowScriptScanning) - } - if ($null -ne $policySettings.DeviceSettings.cloudBlockLevel) { + } + if ($null -ne $policySettings.DeviceSettings.cloudBlockLevel) + { $complexDeviceSettings.Add('CloudBlockLevel', $policySettings.DeviceSettings.cloudBlockLevel) } - if ($null -ne $policySettings.DeviceSettings.cloudExtendedTimeout) { + if ($null -ne $policySettings.DeviceSettings.cloudExtendedTimeout) + { $complexDeviceSettings.Add('CloudExtendedTimeout', $policySettings.DeviceSettings.cloudExtendedTimeout) } - if ($null -ne $policySettings.DeviceSettings.disableLocalAdminMerge) { + if ($null -ne $policySettings.DeviceSettings.disableLocalAdminMerge) + { $complexDeviceSettings.Add('DisableLocalAdminMerge', $policySettings.DeviceSettings.disableLocalAdminMerge) } - if ($null -ne $policySettings.DeviceSettings.enableFileHashComputation) { + if ($null -ne $policySettings.DeviceSettings.enableFileHashComputation) + { $complexDeviceSettings.Add('EnableFileHashComputation', $policySettings.DeviceSettings.enableFileHashComputation) } - if ($null -ne $policySettings.DeviceSettings.enableNetworkProtection) { + if ($null -ne $policySettings.DeviceSettings.enableNetworkProtection) + { $complexDeviceSettings.Add('EnableNetworkProtection', $policySettings.DeviceSettings.enableNetworkProtection) } - if ($null -ne $policySettings.DeviceSettings.hideExclusionsFromLocalAdmins) { + if ($null -ne $policySettings.DeviceSettings.hideExclusionsFromLocalAdmins) + { $complexDeviceSettings.Add('HideExclusionsFromLocalAdmins', $policySettings.DeviceSettings.hideExclusionsFromLocalAdmins) } - if ($null -ne $policySettings.DeviceSettings.pUAProtection) { + if ($null -ne $policySettings.DeviceSettings.pUAProtection) + { $complexDeviceSettings.Add('PUAProtection', $policySettings.DeviceSettings.pUAProtection) } - if ($null -ne $policySettings.DeviceSettings.realTimeScanDirection) { + if ($null -ne $policySettings.DeviceSettings.realTimeScanDirection) + { $complexDeviceSettings.Add('RealTimeScanDirection', $policySettings.DeviceSettings.realTimeScanDirection) } - if ($null -ne $policySettings.DeviceSettings.submitSamplesConsent) { + if ($null -ne $policySettings.DeviceSettings.submitSamplesConsent) + { $complexDeviceSettings.Add('SubmitSamplesConsent', $policySettings.DeviceSettings.submitSamplesConsent) } - if ($null -ne $policySettings.DeviceSettings.configureSystemGuardLaunch) { + if ($null -ne $policySettings.DeviceSettings.configureSystemGuardLaunch) + { $complexDeviceSettings.Add('ConfigureSystemGuardLaunch', $policySettings.DeviceSettings.configureSystemGuardLaunch) } - if ($null -ne $policySettings.DeviceSettings.lsaCfgFlags) { + if ($null -ne $policySettings.DeviceSettings.lsaCfgFlags) + { $complexDeviceSettings.Add('LsaCfgFlags', $policySettings.DeviceSettings.lsaCfgFlags) } - if ($null -ne $policySettings.DeviceSettings.enableVirtualizationBasedSecurity) { + if ($null -ne $policySettings.DeviceSettings.enableVirtualizationBasedSecurity) + { $complexDeviceSettings.Add('EnableVirtualizationBasedSecurity', $policySettings.DeviceSettings.enableVirtualizationBasedSecurity) } - if ($null -ne $policySettings.DeviceSettings.requirePlatformSecurityFeatures) { + if ($null -ne $policySettings.DeviceSettings.requirePlatformSecurityFeatures) + { $complexDeviceSettings.Add('RequirePlatformSecurityFeatures', $policySettings.DeviceSettings.requirePlatformSecurityFeatures) } - if ($null -ne $policySettings.DeviceSettings.devicePasswordEnabled) { + if ($null -ne $policySettings.DeviceSettings.devicePasswordEnabled) + { $complexDeviceSettings.Add('DevicePasswordEnabled', $policySettings.DeviceSettings.devicePasswordEnabled) } - if ($null -ne $policySettings.DeviceSettings.devicePasswordExpiration) { + if ($null -ne $policySettings.DeviceSettings.devicePasswordExpiration) + { $complexDeviceSettings.Add('DevicePasswordExpiration', $policySettings.DeviceSettings.devicePasswordExpiration) } - if ($null -ne $policySettings.DeviceSettings.minDevicePasswordLength) { + if ($null -ne $policySettings.DeviceSettings.minDevicePasswordLength) + { $complexDeviceSettings.Add('MinDevicePasswordLength', $policySettings.DeviceSettings.minDevicePasswordLength) } - if ($null -ne $policySettings.DeviceSettings.alphanumericDevicePasswordRequired) { + if ($null -ne $policySettings.DeviceSettings.alphanumericDevicePasswordRequired) + { $complexDeviceSettings.Add('AlphanumericDevicePasswordRequired', $policySettings.DeviceSettings.alphanumericDevicePasswordRequired) } - if ($null -ne $policySettings.DeviceSettings.maxDevicePasswordFailedAttempts) { + if ($null -ne $policySettings.DeviceSettings.maxDevicePasswordFailedAttempts) + { $complexDeviceSettings.Add('MaxDevicePasswordFailedAttempts', $policySettings.DeviceSettings.maxDevicePasswordFailedAttempts) } - if ($null -ne $policySettings.DeviceSettings.minDevicePasswordComplexCharacters) { + if ($null -ne $policySettings.DeviceSettings.minDevicePasswordComplexCharacters) + { $complexDeviceSettings.Add('MinDevicePasswordComplexCharacters', $policySettings.DeviceSettings.minDevicePasswordComplexCharacters) } - if ($null -ne $policySettings.DeviceSettings.maxInactivityTimeDeviceLock) { + if ($null -ne $policySettings.DeviceSettings.maxInactivityTimeDeviceLock) + { $complexDeviceSettings.Add('MaxInactivityTimeDeviceLock', $policySettings.DeviceSettings.maxInactivityTimeDeviceLock) } - if ($null -ne $policySettings.DeviceSettings.devicePasswordHistory) { + if ($null -ne $policySettings.DeviceSettings.devicePasswordHistory) + { $complexDeviceSettings.Add('DevicePasswordHistory', $policySettings.DeviceSettings.devicePasswordHistory) } - if ($null -ne $policySettings.DeviceSettings.allowSimpleDevicePassword) { + if ($null -ne $policySettings.DeviceSettings.allowSimpleDevicePassword) + { $complexDeviceSettings.Add('AllowSimpleDevicePassword', $policySettings.DeviceSettings.allowSimpleDevicePassword) } - if ($null -ne $policySettings.DeviceSettings.deviceEnumerationPolicy) { + if ($null -ne $policySettings.DeviceSettings.deviceEnumerationPolicy) + { $complexDeviceSettings.Add('DeviceEnumerationPolicy', $policySettings.DeviceSettings.deviceEnumerationPolicy) } - if ($null -ne $policySettings.DeviceSettings.enableInsecureGuestLogons) { + if ($null -ne $policySettings.DeviceSettings.enableInsecureGuestLogons) + { $complexDeviceSettings.Add('EnableInsecureGuestLogons', $policySettings.DeviceSettings.enableInsecureGuestLogons) } - if ($null -ne $policySettings.DeviceSettings.accounts_LimitLocalAccountUseOfBlankPasswordsToConsoleLogonOnly) { + if ($null -ne $policySettings.DeviceSettings.accounts_LimitLocalAccountUseOfBlankPasswordsToConsoleLogonOnly) + { $complexDeviceSettings.Add('Accounts_LimitLocalAccountUseOfBlankPasswordsToConsoleLogonOnly', $policySettings.DeviceSettings.accounts_LimitLocalAccountUseOfBlankPasswordsToConsoleLogonOnly) } - if ($null -ne $policySettings.DeviceSettings.interactiveLogon_MachineInactivityLimit) { + if ($null -ne $policySettings.DeviceSettings.interactiveLogon_MachineInactivityLimit) + { $complexDeviceSettings.Add('InteractiveLogon_MachineInactivityLimit', $policySettings.DeviceSettings.interactiveLogon_MachineInactivityLimit) } - if ($null -ne $policySettings.DeviceSettings.interactiveLogon_SmartCardRemovalBehavior) { + if ($null -ne $policySettings.DeviceSettings.interactiveLogon_SmartCardRemovalBehavior) + { $complexDeviceSettings.Add('InteractiveLogon_SmartCardRemovalBehavior', $policySettings.DeviceSettings.interactiveLogon_SmartCardRemovalBehavior) } - if ($null -ne $policySettings.DeviceSettings.microsoftNetworkClient_DigitallySignCommunicationsAlways) { + if ($null -ne $policySettings.DeviceSettings.microsoftNetworkClient_DigitallySignCommunicationsAlways) + { $complexDeviceSettings.Add('MicrosoftNetworkClient_DigitallySignCommunicationsAlways', $policySettings.DeviceSettings.microsoftNetworkClient_DigitallySignCommunicationsAlways) } - if ($null -ne $policySettings.DeviceSettings.microsoftNetworkClient_SendUnencryptedPasswordToThirdPartySMBServers) { + if ($null -ne $policySettings.DeviceSettings.microsoftNetworkClient_SendUnencryptedPasswordToThirdPartySMBServers) + { $complexDeviceSettings.Add('MicrosoftNetworkClient_SendUnencryptedPasswordToThirdPartySMBServers', $policySettings.DeviceSettings.microsoftNetworkClient_SendUnencryptedPasswordToThirdPartySMBServers) } - if ($null -ne $policySettings.DeviceSettings.microsoftNetworkServer_DigitallySignCommunicationsAlways) { + if ($null -ne $policySettings.DeviceSettings.microsoftNetworkServer_DigitallySignCommunicationsAlways) + { $complexDeviceSettings.Add('MicrosoftNetworkServer_DigitallySignCommunicationsAlways', $policySettings.DeviceSettings.microsoftNetworkServer_DigitallySignCommunicationsAlways) } - if ($null -ne $policySettings.DeviceSettings.networkAccess_DoNotAllowAnonymousEnumerationOfSAMAccounts) { + if ($null -ne $policySettings.DeviceSettings.networkAccess_DoNotAllowAnonymousEnumerationOfSAMAccounts) + { $complexDeviceSettings.Add('NetworkAccess_DoNotAllowAnonymousEnumerationOfSAMAccounts', $policySettings.DeviceSettings.networkAccess_DoNotAllowAnonymousEnumerationOfSAMAccounts) } - if ($null -ne $policySettings.DeviceSettings.networkAccess_DoNotAllowAnonymousEnumerationOfSamAccountsAndShares) { + if ($null -ne $policySettings.DeviceSettings.networkAccess_DoNotAllowAnonymousEnumerationOfSamAccountsAndShares) + { $complexDeviceSettings.Add('NetworkAccess_DoNotAllowAnonymousEnumerationOfSamAccountsAndShares', $policySettings.DeviceSettings.networkAccess_DoNotAllowAnonymousEnumerationOfSamAccountsAndShares) } - if ($null -ne $policySettings.DeviceSettings.networkAccess_RestrictAnonymousAccessToNamedPipesAndShares) { + if ($null -ne $policySettings.DeviceSettings.networkAccess_RestrictAnonymousAccessToNamedPipesAndShares) + { $complexDeviceSettings.Add('NetworkAccess_RestrictAnonymousAccessToNamedPipesAndShares', $policySettings.DeviceSettings.networkAccess_RestrictAnonymousAccessToNamedPipesAndShares) } - if ($null -ne $policySettings.DeviceSettings.networkAccess_RestrictClientsAllowedToMakeRemoteCallsToSAM) { + if ($null -ne $policySettings.DeviceSettings.networkAccess_RestrictClientsAllowedToMakeRemoteCallsToSAM) + { $complexDeviceSettings.Add('NetworkAccess_RestrictClientsAllowedToMakeRemoteCallsToSAM', $policySettings.DeviceSettings.networkAccess_RestrictClientsAllowedToMakeRemoteCallsToSAM) } - if ($null -ne $policySettings.DeviceSettings.networkSecurity_DoNotStoreLANManagerHashValueOnNextPasswordChange) { + if ($null -ne $policySettings.DeviceSettings.networkSecurity_DoNotStoreLANManagerHashValueOnNextPasswordChange) + { $complexDeviceSettings.Add('NetworkSecurity_DoNotStoreLANManagerHashValueOnNextPasswordChange', $policySettings.DeviceSettings.networkSecurity_DoNotStoreLANManagerHashValueOnNextPasswordChange) } - if ($null -ne $policySettings.DeviceSettings.networkSecurity_LANManagerAuthenticationLevel) { + if ($null -ne $policySettings.DeviceSettings.networkSecurity_LANManagerAuthenticationLevel) + { $complexDeviceSettings.Add('NetworkSecurity_LANManagerAuthenticationLevel', $policySettings.DeviceSettings.networkSecurity_LANManagerAuthenticationLevel) } - if ($null -ne $policySettings.DeviceSettings.networkSecurity_MinimumSessionSecurityForNTLMSSPBasedClients) { + if ($null -ne $policySettings.DeviceSettings.networkSecurity_MinimumSessionSecurityForNTLMSSPBasedClients) + { $complexDeviceSettings.Add('NetworkSecurity_MinimumSessionSecurityForNTLMSSPBasedClients', $policySettings.DeviceSettings.networkSecurity_MinimumSessionSecurityForNTLMSSPBasedClients) } - if ($null -ne $policySettings.DeviceSettings.networkSecurity_MinimumSessionSecurityForNTLMSSPBasedServers) { + if ($null -ne $policySettings.DeviceSettings.networkSecurity_MinimumSessionSecurityForNTLMSSPBasedServers) + { $complexDeviceSettings.Add('NetworkSecurity_MinimumSessionSecurityForNTLMSSPBasedServers', $policySettings.DeviceSettings.networkSecurity_MinimumSessionSecurityForNTLMSSPBasedServers) } - if ($null -ne $policySettings.DeviceSettings.userAccountControl_BehaviorOfTheElevationPromptForAdministrators) { + if ($null -ne $policySettings.DeviceSettings.userAccountControl_BehaviorOfTheElevationPromptForAdministrators) + { $complexDeviceSettings.Add('UserAccountControl_BehaviorOfTheElevationPromptForAdministrators', $policySettings.DeviceSettings.userAccountControl_BehaviorOfTheElevationPromptForAdministrators) } - if ($null -ne $policySettings.DeviceSettings.userAccountControl_BehaviorOfTheElevationPromptForStandardUsers) { + if ($null -ne $policySettings.DeviceSettings.userAccountControl_BehaviorOfTheElevationPromptForStandardUsers) + { $complexDeviceSettings.Add('UserAccountControl_BehaviorOfTheElevationPromptForStandardUsers', $policySettings.DeviceSettings.userAccountControl_BehaviorOfTheElevationPromptForStandardUsers) } - if ($null -ne $policySettings.DeviceSettings.userAccountControl_DetectApplicationInstallationsAndPromptForElevation) { + if ($null -ne $policySettings.DeviceSettings.userAccountControl_DetectApplicationInstallationsAndPromptForElevation) + { $complexDeviceSettings.Add('UserAccountControl_DetectApplicationInstallationsAndPromptForElevation', $policySettings.DeviceSettings.userAccountControl_DetectApplicationInstallationsAndPromptForElevation) } - if ($null -ne $policySettings.DeviceSettings.userAccountControl_OnlyElevateUIAccessApplicationsThatAreInstalledInSecureLocations) { + if ($null -ne $policySettings.DeviceSettings.userAccountControl_OnlyElevateUIAccessApplicationsThatAreInstalledInSecureLocations) + { $complexDeviceSettings.Add('UserAccountControl_OnlyElevateUIAccessApplicationsThatAreInstalledInSecureLocations', $policySettings.DeviceSettings.userAccountControl_OnlyElevateUIAccessApplicationsThatAreInstalledInSecureLocations) } - if ($null -ne $policySettings.DeviceSettings.userAccountControl_RunAllAdministratorsInAdminApprovalMode) { + if ($null -ne $policySettings.DeviceSettings.userAccountControl_RunAllAdministratorsInAdminApprovalMode) + { $complexDeviceSettings.Add('UserAccountControl_RunAllAdministratorsInAdminApprovalMode', $policySettings.DeviceSettings.userAccountControl_RunAllAdministratorsInAdminApprovalMode) } - if ($null -ne $policySettings.DeviceSettings.userAccountControl_UseAdminApprovalMode) { + if ($null -ne $policySettings.DeviceSettings.userAccountControl_UseAdminApprovalMode) + { $complexDeviceSettings.Add('UserAccountControl_UseAdminApprovalMode', $policySettings.DeviceSettings.userAccountControl_UseAdminApprovalMode) } - if ($null -ne $policySettings.DeviceSettings.userAccountControl_VirtualizeFileAndRegistryWriteFailuresToPerUserLocations) { + if ($null -ne $policySettings.DeviceSettings.userAccountControl_VirtualizeFileAndRegistryWriteFailuresToPerUserLocations) + { $complexDeviceSettings.Add('UserAccountControl_VirtualizeFileAndRegistryWriteFailuresToPerUserLocations', $policySettings.DeviceSettings.userAccountControl_VirtualizeFileAndRegistryWriteFailuresToPerUserLocations) } - if ($null -ne $policySettings.DeviceSettings.configureLsaProtectedProcess) { + if ($null -ne $policySettings.DeviceSettings.configureLsaProtectedProcess) + { $complexDeviceSettings.Add('ConfigureLsaProtectedProcess', $policySettings.DeviceSettings.configureLsaProtectedProcess) } - if ($null -ne $policySettings.DeviceSettings.allowGameDVR) { + if ($null -ne $policySettings.DeviceSettings.allowGameDVR) + { $complexDeviceSettings.Add('AllowGameDVR', $policySettings.DeviceSettings.allowGameDVR) } - if ($null -ne $policySettings.DeviceSettings.mSIAllowUserControlOverInstall) { + if ($null -ne $policySettings.DeviceSettings.mSIAllowUserControlOverInstall) + { $complexDeviceSettings.Add('MSIAllowUserControlOverInstall', $policySettings.DeviceSettings.mSIAllowUserControlOverInstall) } - if ($null -ne $policySettings.DeviceSettings.mSIAlwaysInstallWithElevatedPrivileges) { + if ($null -ne $policySettings.DeviceSettings.mSIAlwaysInstallWithElevatedPrivileges) + { $complexDeviceSettings.Add('MSIAlwaysInstallWithElevatedPrivileges', $policySettings.DeviceSettings.mSIAlwaysInstallWithElevatedPrivileges) } - if ($null -ne $policySettings.DeviceSettings.smartScreenEnabled) { + if ($null -ne $policySettings.DeviceSettings.smartScreenEnabled) + { $complexDeviceSettings.Add('SmartScreenEnabled', $policySettings.DeviceSettings.smartScreenEnabled) } - if ($null -ne $policySettings.DeviceSettings.smartScreen_PreventSmartScreenPromptOverride) { + if ($null -ne $policySettings.DeviceSettings.smartScreen_PreventSmartScreenPromptOverride) + { $complexDeviceSettings.Add('SmartScreen_PreventSmartScreenPromptOverride', $policySettings.DeviceSettings.smartScreen_PreventSmartScreenPromptOverride) } - if ($null -ne $policySettings.DeviceSettings.letAppsActivateWithVoiceAboveLock) { + if ($null -ne $policySettings.DeviceSettings.letAppsActivateWithVoiceAboveLock) + { $complexDeviceSettings.Add('LetAppsActivateWithVoiceAboveLock', $policySettings.DeviceSettings.letAppsActivateWithVoiceAboveLock) } - if ($null -ne $policySettings.DeviceSettings.allowIndexingEncryptedStoresOrItems) { + if ($null -ne $policySettings.DeviceSettings.allowIndexingEncryptedStoresOrItems) + { $complexDeviceSettings.Add('AllowIndexingEncryptedStoresOrItems', $policySettings.DeviceSettings.allowIndexingEncryptedStoresOrItems) } - if ($null -ne $policySettings.DeviceSettings.enableSmartScreenInShell) { + if ($null -ne $policySettings.DeviceSettings.enableSmartScreenInShell) + { $complexDeviceSettings.Add('EnableSmartScreenInShell', $policySettings.DeviceSettings.enableSmartScreenInShell) } - if ($null -ne $policySettings.DeviceSettings.notifyMalicious) { + if ($null -ne $policySettings.DeviceSettings.notifyMalicious) + { $complexDeviceSettings.Add('NotifyMalicious', $policySettings.DeviceSettings.notifyMalicious) } - if ($null -ne $policySettings.DeviceSettings.notifyPasswordReuse) { + if ($null -ne $policySettings.DeviceSettings.notifyPasswordReuse) + { $complexDeviceSettings.Add('NotifyPasswordReuse', $policySettings.DeviceSettings.notifyPasswordReuse) } - if ($null -ne $policySettings.DeviceSettings.notifyUnsafeApp) { + if ($null -ne $policySettings.DeviceSettings.notifyUnsafeApp) + { $complexDeviceSettings.Add('NotifyUnsafeApp', $policySettings.DeviceSettings.notifyUnsafeApp) } - if ($null -ne $policySettings.DeviceSettings.serviceEnabled) { + if ($null -ne $policySettings.DeviceSettings.serviceEnabled) + { $complexDeviceSettings.Add('ServiceEnabled', $policySettings.DeviceSettings.serviceEnabled) } - if ($null -ne $policySettings.DeviceSettings.preventOverrideForFilesInShell) { + if ($null -ne $policySettings.DeviceSettings.preventOverrideForFilesInShell) + { $complexDeviceSettings.Add('PreventOverrideForFilesInShell', $policySettings.DeviceSettings.preventOverrideForFilesInShell) } - if ($null -ne $policySettings.DeviceSettings.configureXboxAccessoryManagementServiceStartupMode) { + if ($null -ne $policySettings.DeviceSettings.configureXboxAccessoryManagementServiceStartupMode) + { $complexDeviceSettings.Add('ConfigureXboxAccessoryManagementServiceStartupMode', $policySettings.DeviceSettings.configureXboxAccessoryManagementServiceStartupMode) } - if ($null -ne $policySettings.DeviceSettings.configureXboxLiveAuthManagerServiceStartupMode) { + if ($null -ne $policySettings.DeviceSettings.configureXboxLiveAuthManagerServiceStartupMode) + { $complexDeviceSettings.Add('ConfigureXboxLiveAuthManagerServiceStartupMode', $policySettings.DeviceSettings.configureXboxLiveAuthManagerServiceStartupMode) } - if ($null -ne $policySettings.DeviceSettings.configureXboxLiveGameSaveServiceStartupMode) { + if ($null -ne $policySettings.DeviceSettings.configureXboxLiveGameSaveServiceStartupMode) + { $complexDeviceSettings.Add('ConfigureXboxLiveGameSaveServiceStartupMode', $policySettings.DeviceSettings.configureXboxLiveGameSaveServiceStartupMode) } - if ($null -ne $policySettings.DeviceSettings.configureXboxLiveNetworkingServiceStartupMode) { + if ($null -ne $policySettings.DeviceSettings.configureXboxLiveNetworkingServiceStartupMode) + { $complexDeviceSettings.Add('ConfigureXboxLiveNetworkingServiceStartupMode', $policySettings.DeviceSettings.configureXboxLiveNetworkingServiceStartupMode) } - if ($null -ne $policySettings.DeviceSettings.enableXboxGameSaveTask) { + if ($null -ne $policySettings.DeviceSettings.enableXboxGameSaveTask) + { $complexDeviceSettings.Add('EnableXboxGameSaveTask', $policySettings.DeviceSettings.enableXboxGameSaveTask) } - if ($null -ne $policySettings.DeviceSettings.accessFromNetwork) { + if ($null -ne $policySettings.DeviceSettings.accessFromNetwork) + { $complexDeviceSettings.Add('AccessFromNetwork', $policySettings.DeviceSettings.accessFromNetwork) } - if ($null -ne $policySettings.DeviceSettings.allowLocalLogOn) { + if ($null -ne $policySettings.DeviceSettings.allowLocalLogOn) + { $complexDeviceSettings.Add('AllowLocalLogOn', $policySettings.DeviceSettings.allowLocalLogOn) } - if ($null -ne $policySettings.DeviceSettings.backupFilesAndDirectories) { + if ($null -ne $policySettings.DeviceSettings.backupFilesAndDirectories) + { $complexDeviceSettings.Add('BackupFilesAndDirectories', $policySettings.DeviceSettings.backupFilesAndDirectories) } - if ($null -ne $policySettings.DeviceSettings.createGlobalObjects) { + if ($null -ne $policySettings.DeviceSettings.createGlobalObjects) + { $complexDeviceSettings.Add('CreateGlobalObjects', $policySettings.DeviceSettings.createGlobalObjects) } - if ($null -ne $policySettings.DeviceSettings.createPageFile) { + if ($null -ne $policySettings.DeviceSettings.createPageFile) + { $complexDeviceSettings.Add('CreatePageFile', $policySettings.DeviceSettings.createPageFile) } - if ($null -ne $policySettings.DeviceSettings.debugPrograms) { + if ($null -ne $policySettings.DeviceSettings.debugPrograms) + { $complexDeviceSettings.Add('DebugPrograms', $policySettings.DeviceSettings.debugPrograms) } - if ($null -ne $policySettings.DeviceSettings.denyAccessFromNetwork) { + if ($null -ne $policySettings.DeviceSettings.denyAccessFromNetwork) + { $complexDeviceSettings.Add('DenyAccessFromNetwork', $policySettings.DeviceSettings.denyAccessFromNetwork) } - if ($null -ne $policySettings.DeviceSettings.denyRemoteDesktopServicesLogOn) { + if ($null -ne $policySettings.DeviceSettings.denyRemoteDesktopServicesLogOn) + { $complexDeviceSettings.Add('DenyRemoteDesktopServicesLogOn', $policySettings.DeviceSettings.denyRemoteDesktopServicesLogOn) } - if ($null -ne $policySettings.DeviceSettings.impersonateClient) { + if ($null -ne $policySettings.DeviceSettings.impersonateClient) + { $complexDeviceSettings.Add('ImpersonateClient', $policySettings.DeviceSettings.impersonateClient) } - if ($null -ne $policySettings.DeviceSettings.loadUnloadDeviceDrivers) { + if ($null -ne $policySettings.DeviceSettings.loadUnloadDeviceDrivers) + { $complexDeviceSettings.Add('LoadUnloadDeviceDrivers', $policySettings.DeviceSettings.loadUnloadDeviceDrivers) } - if ($null -ne $policySettings.DeviceSettings.manageAuditingAndSecurityLog) { + if ($null -ne $policySettings.DeviceSettings.manageAuditingAndSecurityLog) + { $complexDeviceSettings.Add('ManageAuditingAndSecurityLog', $policySettings.DeviceSettings.manageAuditingAndSecurityLog) } - if ($null -ne $policySettings.DeviceSettings.manageVolume) { + if ($null -ne $policySettings.DeviceSettings.manageVolume) + { $complexDeviceSettings.Add('ManageVolume', $policySettings.DeviceSettings.manageVolume) } - if ($null -ne $policySettings.DeviceSettings.modifyFirmwareEnvironment) { + if ($null -ne $policySettings.DeviceSettings.modifyFirmwareEnvironment) + { $complexDeviceSettings.Add('ModifyFirmwareEnvironment', $policySettings.DeviceSettings.modifyFirmwareEnvironment) } - if ($null -ne $policySettings.DeviceSettings.profileSingleProcess) { + if ($null -ne $policySettings.DeviceSettings.profileSingleProcess) + { $complexDeviceSettings.Add('ProfileSingleProcess', $policySettings.DeviceSettings.profileSingleProcess) } - if ($null -ne $policySettings.DeviceSettings.remoteShutdown) { + if ($null -ne $policySettings.DeviceSettings.remoteShutdown) + { $complexDeviceSettings.Add('RemoteShutdown', $policySettings.DeviceSettings.remoteShutdown) } - if ($null -ne $policySettings.DeviceSettings.restoreFilesAndDirectories) { + if ($null -ne $policySettings.DeviceSettings.restoreFilesAndDirectories) + { $complexDeviceSettings.Add('RestoreFilesAndDirectories', $policySettings.DeviceSettings.restoreFilesAndDirectories) } - if ($null -ne $policySettings.DeviceSettings.takeOwnership) { + if ($null -ne $policySettings.DeviceSettings.takeOwnership) + { $complexDeviceSettings.Add('TakeOwnership', $policySettings.DeviceSettings.takeOwnership) } - if ($null -ne $policySettings.DeviceSettings.hypervisorEnforcedCodeIntegrity) { + if ($null -ne $policySettings.DeviceSettings.hypervisorEnforcedCodeIntegrity) + { $complexDeviceSettings.Add('HypervisorEnforcedCodeIntegrity', $policySettings.DeviceSettings.hypervisorEnforcedCodeIntegrity) } - if ($null -ne $policySettings.DeviceSettings.allowAutoConnectToWiFiSenseHotspots) { + if ($null -ne $policySettings.DeviceSettings.allowAutoConnectToWiFiSenseHotspots) + { $complexDeviceSettings.Add('AllowAutoConnectToWiFiSenseHotspots', $policySettings.DeviceSettings.allowAutoConnectToWiFiSenseHotspots) } - if ($null -ne $policySettings.DeviceSettings.allowInternetSharing) { + if ($null -ne $policySettings.DeviceSettings.allowInternetSharing) + { $complexDeviceSettings.Add('AllowInternetSharing', $policySettings.DeviceSettings.allowInternetSharing) } - if ($null -ne $policySettings.DeviceSettings.facialFeaturesUseEnhancedAntiSpoofing) { + if ($null -ne $policySettings.DeviceSettings.facialFeaturesUseEnhancedAntiSpoofing) + { $complexDeviceSettings.Add('FacialFeaturesUseEnhancedAntiSpoofing', $policySettings.DeviceSettings.facialFeaturesUseEnhancedAntiSpoofing) } - if ($null -ne $policySettings.DeviceSettings.allowWindowsInkWorkspace) { + if ($null -ne $policySettings.DeviceSettings.allowWindowsInkWorkspace) + { $complexDeviceSettings.Add('AllowWindowsInkWorkspace', $policySettings.DeviceSettings.allowWindowsInkWorkspace) } - if ($null -ne $policySettings.DeviceSettings.backupDirectory) { + if ($null -ne $policySettings.DeviceSettings.backupDirectory) + { $complexDeviceSettings.Add('BackupDirectory', $policySettings.DeviceSettings.backupDirectory) } - if ($null -ne $policySettings.DeviceSettings.aDEncryptedPasswordHistorySize) { + if ($null -ne $policySettings.DeviceSettings.aDEncryptedPasswordHistorySize) + { $complexDeviceSettings.Add('ADEncryptedPasswordHistorySize', $policySettings.DeviceSettings.aDEncryptedPasswordHistorySize) } - if ($null -ne $policySettings.DeviceSettings.passwordagedays) { + if ($null -ne $policySettings.DeviceSettings.passwordagedays) + { $complexDeviceSettings.Add('Passwordagedays', $policySettings.DeviceSettings.passwordagedays) } - if ($null -ne $policySettings.DeviceSettings.aDPasswordEncryptionEnabled) { + if ($null -ne $policySettings.DeviceSettings.aDPasswordEncryptionEnabled) + { $complexDeviceSettings.Add('ADPasswordEncryptionEnabled', $policySettings.DeviceSettings.aDPasswordEncryptionEnabled) } - if ($null -ne $policySettings.DeviceSettings.passwordagedays_aad) { + if ($null -ne $policySettings.DeviceSettings.passwordagedays_aad) + { $complexDeviceSettings.Add('Passwordagedays_aad', $policySettings.DeviceSettings.passwordagedays_aad) } - if ($null -ne $policySettings.DeviceSettings.aDPasswordEncryptionPrincipal) { + if ($null -ne $policySettings.DeviceSettings.aDPasswordEncryptionPrincipal) + { $complexDeviceSettings.Add('ADPasswordEncryptionPrincipal', $policySettings.DeviceSettings.aDPasswordEncryptionPrincipal) } - if ($null -ne $policySettings.DeviceSettings.passwordExpirationProtectionEnabled) { + if ($null -ne $policySettings.DeviceSettings.passwordExpirationProtectionEnabled) + { $complexDeviceSettings.Add('PasswordExpirationProtectionEnabled', $policySettings.DeviceSettings.passwordExpirationProtectionEnabled) - } + } if ($complexDeviceSettings.Values.Where({ $null -ne $_ }).Count -eq 0) { $complexDeviceSettings = $null @@ -1556,41 +2027,53 @@ function Get-TargetResource $complexUserSettings = @{} # Add user settings with conditional checks - if ($null -ne $policySettings.UserSettings.noLockScreenToastNotification) { + if ($null -ne $policySettings.UserSettings.noLockScreenToastNotification) + { $complexUserSettings.Add('NoLockScreenToastNotification', $policySettings.UserSettings.noLockScreenToastNotification) } - if ($null -ne $policySettings.UserSettings.restrictFormSuggestPW) { + if ($null -ne $policySettings.UserSettings.restrictFormSuggestPW) + { $complexUserSettings.Add('RestrictFormSuggestPW', $policySettings.UserSettings.restrictFormSuggestPW) } - if ($null -ne $policySettings.UserSettings.chkBox_PasswordAsk) { + if ($null -ne $policySettings.UserSettings.chkBox_PasswordAsk) + { $complexUserSettings.Add('ChkBox_PasswordAsk', $policySettings.UserSettings.chkBox_PasswordAsk) } - if ($null -ne $policySettings.UserSettings.allowWindowsSpotlight) { + if ($null -ne $policySettings.UserSettings.allowWindowsSpotlight) + { $complexUserSettings.Add('AllowWindowsSpotlight', $policySettings.UserSettings.allowWindowsSpotlight) } - if ($null -ne $policySettings.UserSettings.allowWindowsTips) { + if ($null -ne $policySettings.UserSettings.allowWindowsTips) + { $complexUserSettings.Add('AllowWindowsTips', $policySettings.UserSettings.allowWindowsTips) } - if ($null -ne $policySettings.UserSettings.allowTailoredExperiencesWithDiagnosticData) { + if ($null -ne $policySettings.UserSettings.allowTailoredExperiencesWithDiagnosticData) + { $complexUserSettings.Add('AllowTailoredExperiencesWithDiagnosticData', $policySettings.UserSettings.allowTailoredExperiencesWithDiagnosticData) } - if ($null -ne $policySettings.UserSettings.allowWindowsSpotlightOnActionCenter) { + if ($null -ne $policySettings.UserSettings.allowWindowsSpotlightOnActionCenter) + { $complexUserSettings.Add('AllowWindowsSpotlightOnActionCenter', $policySettings.UserSettings.allowWindowsSpotlightOnActionCenter) } - if ($null -ne $policySettings.UserSettings.allowWindowsConsumerFeatures) { + if ($null -ne $policySettings.UserSettings.allowWindowsConsumerFeatures) + { $complexUserSettings.Add('AllowWindowsConsumerFeatures', $policySettings.UserSettings.allowWindowsConsumerFeatures) } - if ($null -ne $policySettings.UserSettings.configureWindowsSpotlightOnLockScreen) { + if ($null -ne $policySettings.UserSettings.configureWindowsSpotlightOnLockScreen) + { $complexUserSettings.Add('ConfigureWindowsSpotlightOnLockScreen', $policySettings.UserSettings.configureWindowsSpotlightOnLockScreen) } - if ($null -ne $policySettings.UserSettings.allowWindowsSpotlightWindowsWelcomeExperience) { + if ($null -ne $policySettings.UserSettings.allowWindowsSpotlightWindowsWelcomeExperience) + { $complexUserSettings.Add('AllowWindowsSpotlightWindowsWelcomeExperience', $policySettings.UserSettings.allowWindowsSpotlightWindowsWelcomeExperience) } - if ($null -ne $policySettings.UserSettings.allowThirdPartySuggestionsInWindowsSpotlight) { + if ($null -ne $policySettings.UserSettings.allowThirdPartySuggestionsInWindowsSpotlight) + { $complexUserSettings.Add('AllowThirdPartySuggestionsInWindowsSpotlight', $policySettings.UserSettings.allowThirdPartySuggestionsInWindowsSpotlight) } # Check if $complexUserSettings is empty - if ($complexUserSettings.Values.Where({ $null -ne $_ }).Count -eq 0) { + if ($complexUserSettings.Values.Where({ $null -ne $_ }).Count -eq 0) + { $complexUserSettings = $null } $policySettings.Remove('UserSettings') | Out-Null @@ -1649,7 +2132,7 @@ function Set-TargetResource [Parameter(Mandatory = $true)] [System.String] - $DisplayName, + $DisplayName, [Parameter()] [System.String[]] @@ -1730,7 +2213,7 @@ function Set-TargetResource if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Absent') { Write-Verbose -Message "Creating an Intune Security Baseline for Windows10 with Name {$DisplayName}" - $BoundParameters.Remove("Assignments") | Out-Null + $BoundParameters.Remove('Assignments') | Out-Null $settings = Get-IntuneSettingCatalogPolicySetting ` -DSCParams ([System.Collections.Hashtable]$BoundParameters) ` @@ -1762,7 +2245,7 @@ function Set-TargetResource elseif ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Present') { Write-Verbose -Message "Updating the Intune Security Baseline for Windows10 with Id {$($currentInstance.Id)}" - $BoundParameters.Remove("Assignments") | Out-Null + $BoundParameters.Remove('Assignments') | Out-Null $settings = Get-IntuneSettingCatalogPolicySetting ` -DSCParams ([System.Collections.Hashtable]$BoundParameters) ` @@ -1808,7 +2291,7 @@ function Test-TargetResource [Parameter(Mandatory = $true)] [System.String] - $DisplayName, + $DisplayName, [Parameter()] [System.String[]] @@ -1998,14 +2481,14 @@ function Export-TargetResource try { #region resource generator code - $policyTemplateID = "66df8dce-0166-4b82-92f7-1f74e3ca17a3_1" + $policyTemplateID = '66df8dce-0166-4b82-92f7-1f74e3ca17a3_1' [array]$getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` -Filter $Filter ` -All ` -ErrorAction Stop | Where-Object ` -FilterScript { - $_.TemplateReference.TemplateId -eq $policyTemplateID - } + $_.TemplateReference.TemplateId -eq $policyTemplateID + } #endregion $i = 1 @@ -2031,16 +2514,16 @@ function Export-TargetResource } Write-Host " |---[$i/$($getValue.Count)] $displayedKey" -NoNewline $params = @{ - Id = $config.Id - DisplayName = $config.Name - Ensure = 'Present' - Credential = $Credential - ApplicationId = $ApplicationId - TenantId = $TenantId - ApplicationSecret = $ApplicationSecret + Id = $config.Id + DisplayName = $config.Name + Ensure = 'Present' + Credential = $Credential + ApplicationId = $ApplicationId + TenantId = $TenantId + ApplicationSecret = $ApplicationSecret CertificateThumbprint = $CertificateThumbprint - ManagedIdentity = $ManagedIdentity.IsPresent - AccessTokens = $AccessTokens + ManagedIdentity = $ManagedIdentity.IsPresent + AccessTokens = $AccessTokens } $Results = Get-TargetResource @Params @@ -2050,14 +2533,14 @@ function Export-TargetResource { $complexMapping = @( @{ - Name = 'DeviceSettings' + Name = 'DeviceSettings' CimInstanceName = 'MicrosoftGraphIntuneSettingsCatalogDeviceSettings_IntuneSecurityBaselineWindows10' - IsRequired = $False + IsRequired = $False } @{ - Name = 'pol_hardenedpaths' + Name = 'pol_hardenedpaths' CimInstanceName = 'MicrosoftGraphIntuneSettingsCatalogpol_hardenedpaths' - IsRequired = $False + IsRequired = $False } ) $complexTypeStringResult = Get-M365DSCDRGComplexTypeToString ` @@ -2109,16 +2592,16 @@ function Export-TargetResource -Credential $Credential if ($Results.DeviceSettings) { - $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName "DeviceSettings" -IsCIMArray:$False + $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'DeviceSettings' -IsCIMArray:$False } if ($Results.UserSettings) { - $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName "UserSettings" -IsCIMArray:$False + $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'UserSettings' -IsCIMArray:$False } if ($Results.Assignments) { - $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName "Assignments" -IsCIMArray:$true + $currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Assignments' -IsCIMArray:$true } $dscContent += $currentDSCBlock diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/MSFT_IntuneSecurityBaselineWindows10.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/MSFT_IntuneSecurityBaselineWindows10.schema.mof index ab1b31ec58..e99e01b1c3 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/MSFT_IntuneSecurityBaselineWindows10.schema.mof +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/MSFT_IntuneSecurityBaselineWindows10.schema.mof @@ -9,8 +9,6 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments [Write, Description("The collection Id that is the target of the assignment.(ConfigMgr)")] String collectionId; }; - - [ClassVersion("1.0.0.0")] class MSFT_MicrosoftGraphIntuneSettingsCatalogpol_hardenedpaths { @@ -491,6 +489,7 @@ class MSFT_MicrosoftGraphIntuneSettingsCatalogDeviceSettings_IntuneSecurityBasel [Write, Description("AD Password Encryption Principal - Depends on BackupDirectory")] String ADPasswordEncryptionPrincipal; [Write, Description("Password Expiration Protection Enabled - Depends on BackupDirectory (false: Allow configured password expiriration timestamp to exceed maximum password age, true: Do not allow configured password expiriration timestamp to exceed maximum password age)"), ValueMap{"false", "true"}, Values{"false", "true"}] String PasswordExpirationProtectionEnabled; }; + [ClassVersion("1.0.0.0")] class MSFT_MicrosoftGraphIntuneSettingsCatalogUserSettings_IntuneSecurityBaselineWindows10 { @@ -506,6 +505,7 @@ class MSFT_MicrosoftGraphIntuneSettingsCatalogUserSettings_IntuneSecurityBaselin [Write, Description("Allow Windows Spotlight Windows Welcome Experience (User) - Depends on AllowWindowsSpotlight (0: Not allowed., 1: Allowed.)"), ValueMap{"0", "1"}, Values{"0", "1"}] String AllowWindowsSpotlightWindowsWelcomeExperience; [Write, Description("Allow Third Party Suggestions In Windows Spotlight (User) - Depends on AllowWindowsSpotlight (0: Third-party suggestions not allowed., 1: Third-party suggestions allowed.)"), ValueMap{"0", "1"}, Values{"0", "1"}] String AllowThirdPartySuggestionsInWindowsSpotlight; }; + [ClassVersion("1.0.0.0"), FriendlyName("IntuneSecurityBaselineWindows10")] class MSFT_IntuneSecurityBaselineWindows10 : OMI_BaseResource { diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/settings.json b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/settings.json index bbbb105b3f..f088b15e29 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/settings.json +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSecurityBaselineWindows10/settings.json @@ -1,44 +1,44 @@ { - "resourceName":"IntuneSecurityBaselineWindows10", - "description":"This resource configures an Intune Security Baseline for Windows10.", - "permissions":{ - "graph":{ - "delegated":{ - "read":[ - { - "name":"DeviceManagementConfiguration.Read.All" - }, - { - "name":"Group.Read.All" - } - ], - "update":[ - { - "name":"Group.Read.All" + "resourceName": "IntuneSecurityBaselineWindows10", + "description": "This resource configures an Intune Security Baseline for Windows10.", + "permissions": { + "graph": { + "delegated": { + "read": [ + { + "name": "DeviceManagementConfiguration.Read.All" + }, + { + "name": "Group.Read.All" + } + ], + "update": [ + { + "name": "Group.Read.All" }, { - "name":"DeviceManagementConfiguration.ReadWrite.All" - } - ] - }, - "application":{ - "read":[ - { - "name":"DeviceManagementConfiguration.Read.All" - }, - { - "name":"Group.Read.All" - } - ], - "update":[ - { - "name":"Group.Read.All" + "name": "DeviceManagementConfiguration.ReadWrite.All" + } + ] + }, + "application": { + "read": [ + { + "name": "DeviceManagementConfiguration.Read.All" + }, + { + "name": "Group.Read.All" + } + ], + "update": [ + { + "name": "Group.Read.All" }, { - "name":"DeviceManagementConfiguration.ReadWrite.All" - } - ] - } - } + "name": "DeviceManagementConfiguration.ReadWrite.All" + } + ] + } + } + } } -} \ No newline at end of file