diff --git a/CHANGELOG.md b/CHANGELOG.md index a5bbc4a30f..94b9f6f696 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,14 @@ * Fixes the evaluation of the AgeLimitForRetention property. * IntuneWifiConfigurationPolicyAndroidEnterpriseDeviceOwner * Fixes the template type in the Get-Targetresource. +* IntuneWifiConfigurationPolicyIOS + * Fixed Test-TargetResource and available properties. + FIXES [#3973](https://github.com/microsoft/Microsoft365DSC/issues/3973) +* IntuneWifiConfigurationPolicyMacOS + * Added additional properties to the export. +* IntuneWifiConfigurationPolicyWindows10 + * Added additional properties to the export. + FIXES [#3963](https://github.com/microsoft/Microsoft365DSC/issues/3963) * TeamsAppSetupPolicy * Fixes evaluation of empty values in Test-TargetResource. * M365DSCReverse @@ -26,6 +34,7 @@ * M365DSCUtil * Removed the parameter `MaxProcesses` from the public `Export-M365DSCConfiguration` function. FIXES [#5982](https://github.com/microsoft/Microsoft365DSC/issues/5982) + * Fixed an issue where basic arrays would not be compared correctly. # 1.25.430.1 diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/MSFT_IntuneWifiConfigurationPolicyIOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/MSFT_IntuneWifiConfigurationPolicyIOS.psm1 index 5f05b2e502..c7144e09fe 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/MSFT_IntuneWifiConfigurationPolicyIOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/MSFT_IntuneWifiConfigurationPolicyIOS.psm1 @@ -29,6 +29,10 @@ function Get-TargetResource [System.Boolean] $DisableMacAddressRandomization, + [Parameter()] + [System.Boolean] + $ForcePreSharedKeyUpdate, + [Parameter()] [System.String] $NetworkName, @@ -54,6 +58,10 @@ function Get-TargetResource [System.String] $ProxySettings, + [Parameter()] + [System.String[]] + $RoleScopeTagIds, + [Parameter()] [System.String] $Ssid, @@ -152,6 +160,7 @@ function Get-TargetResource { $getValue = $Script:exportedInstance } + $Id = $getValue.Id Write-Verbose -Message "Found an Intune Wifi Configuration Policy for iOS with id {$Id}" $results = @{ @@ -168,6 +177,7 @@ function Get-TargetResource ProxyManualAddress = $getValue.AdditionalProperties.proxyManualAddress ProxyManualPort = $getValue.AdditionalProperties.proxyManualPort ProxySettings = $getValue.AdditionalProperties.proxySettings + RoleScopeTagIds = $getValue.RoleScopeTagIds Ssid = $getValue.AdditionalProperties.ssid WiFiSecurityType = $getValue.AdditionalProperties.wiFiSecurityType Ensure = 'Present' @@ -176,7 +186,7 @@ function Get-TargetResource TenantId = $TenantId ApplicationSecret = $ApplicationSecret CertificateThumbprint = $CertificateThumbprint - Managedidentity = $ManagedIdentity.IsPresent + ManagedIdentity = $ManagedIdentity.IsPresent AccessTokens = $AccessTokens } @@ -234,6 +244,10 @@ function Set-TargetResource [System.Boolean] $DisableMacAddressRandomization, + [Parameter()] + [System.Boolean] + $ForcePreSharedKeyUpdate, + [Parameter()] [System.String] $NetworkName, @@ -259,6 +273,10 @@ function Set-TargetResource [System.String] $ProxySettings, + [Parameter()] + [System.String[]] + $RoleScopeTagIds, + [Parameter()] [System.String] $Ssid, @@ -307,16 +325,17 @@ function Set-TargetResource $AccessTokens ) - try - { - $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` - -InboundParameters $PSBoundParameters + if ($ProxySettings -ne 'automatic' -and $ProxyAutomaticConfigurationUrl -ne '') { + throw 'ProxyAutomaticConfigurationUrl must be empty if ProxySettings is not "automatic"' } - catch - { - Write-Verbose -Message $_ + + if ($WiFiSecurityType -eq 'wpaPersonal' -and [string]::IsNullOrEmpty($PreSharedKey)) { + throw 'PreSharedKey is required but was not set.' } + $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` + -InboundParameters $PSBoundParameters + #Ensure the proper dependencies are installed in the current environment. Confirm-M365DSCDependencies @@ -330,40 +349,29 @@ function Set-TargetResource #endregion $currentInstance = Get-TargetResource @PSBoundParameters - - $PSBoundParameters.Remove('Ensure') | Out-Null - $PSBoundParameters.Remove('Credential') | Out-Null - $PSBoundParameters.Remove('ApplicationId') | Out-Null - $PSBoundParameters.Remove('ApplicationSecret') | Out-Null - $PSBoundParameters.Remove('TenantId') | Out-Null - $PSBoundParameters.Remove('CertificateThumbprint') | Out-Null - $PSBoundParameters.Remove('ManagedIdentity') | Out-Null - $PSBoundParameters.Remove('AccessTokens') | Out-Null + $BoundParameters = Remove-M365DSCAuthenticationParameter -BoundParameters $PSBoundParameters if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Absent') { - Write-Verbose -Message "Creating {$DisplayName}" - $PSBoundParameters.Remove('Assignments') | Out-Null - - $CreateParameters = ([Hashtable]$PSBoundParameters).clone() - $CreateParameters = Rename-M365DSCCimInstanceParameter -Properties $CreateParameters + Write-Verbose -Message "Creating an Intune Wifi Configuration Policy for iOS with DisplayName {$DisplayName}" + $CreateParameters = ([Hashtable]$BoundParameters).Clone() + $CreateParameters.Remove('Id') | Out-Null + $CreateParameters.Remove('Assignments') | Out-Null + $CreateParameters.Remove('ForcePreSharedKeyUpdate') | Out-Null $AdditionalProperties = Get-M365DSCAdditionalProperties -Properties ($CreateParameters) foreach ($key in $AdditionalProperties.keys) { if ($key -ne '@odata.type') { - $keyName = $key.substring(0, 1).ToUpper() + $key.substring(1, $key.length - 1) - $CreateParameters.remove($keyName) + $keyName = $key.Substring(0, 1).ToUpper() + $key.Substring(1, $key.Length - 1) + $CreateParameters.Remove($keyName) | Out-Null } } - $CreateParameters.Remove('Id') | Out-Null - $CreateParameters.Remove('Verbose') | Out-Null - - foreach ($key in ($CreateParameters.clone()).Keys) + foreach ($key in ($CreateParameters.Clone()).Keys) { - if ($CreateParameters[$key].getType().Fullname -like '*CimInstance*') + if ($CreateParameters[$key].GetType().Fullname -like '*CimInstance*') { $CreateParameters[$key] = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $CreateParameters[$key] } @@ -371,16 +379,19 @@ function Set-TargetResource if ($AdditionalProperties) { - $CreateParameters.add('AdditionalProperties', $AdditionalProperties) + if ($AdditionalProperties['proxyAutomaticConfigurationUrl'] -eq '') { + $AdditionalProperties['proxyAutomaticConfigurationUrl'] = $null + } + $CreateParameters.Add('AdditionalProperties', $AdditionalProperties) } #region resource generator code $policy = New-MgBetaDeviceManagementDeviceConfiguration @CreateParameters $assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments - if ($policy.id) + if ($policy.Id) { - Update-DeviceConfigurationPolicyAssignment -DeviceConfigurationPolicyId $policy.id ` + Update-DeviceConfigurationPolicyAssignment -DeviceConfigurationPolicyId $policy.Id ` -Targets $assignmentsHash ` -Repository 'deviceManagement/deviceConfigurations' } @@ -388,28 +399,26 @@ function Set-TargetResource } elseif ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Present') { - Write-Verbose -Message "Updating {$DisplayName}" - $PSBoundParameters.Remove('Assignments') | Out-Null + Write-Verbose -Message "Updating the Intune Wifi Configuration Policy for iOS with Id {$Id} and DisplayName {$DisplayName}" - $UpdateParameters = ([Hashtable]$PSBoundParameters).clone() - $UpdateParameters = Rename-M365DSCCimInstanceParameter -Properties $UpdateParameters + $UpdateParameters = ([Hashtable]$BoundParameters).Clone() + $UpdateParameters.Remove('Id') | Out-Null + $UpdateParameters.Remove('Assignments') | Out-Null + $UpdateParameters.Remove('ForcePreSharedKeyUpdate') | Out-Null $AdditionalProperties = Get-M365DSCAdditionalProperties -Properties ($UpdateParameters) foreach ($key in $AdditionalProperties.keys) { if ($key -ne '@odata.type') { - $keyName = $key.substring(0, 1).ToUpper() + $key.substring(1, $key.length - 1) - $UpdateParameters.remove($keyName) + $keyName = $key.Substring(0, 1).ToUpper() + $key.Substring(1, $key.Length - 1) + $UpdateParameters.Remove($keyName) } } - $UpdateParameters.Remove('Id') | Out-Null - $UpdateParameters.Remove('Verbose') | Out-Null - - foreach ($key in ($UpdateParameters.clone()).Keys) + foreach ($key in ($UpdateParameters.Clone()).Keys) { - if ($UpdateParameters[$key].getType().Fullname -like '*CimInstance*') + if ($UpdateParameters[$key].GetType().Fullname -like '*CimInstance*') { $UpdateParameters[$key] = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $UpdateParameters[$key] } @@ -417,7 +426,10 @@ function Set-TargetResource if ($AdditionalProperties) { - $UpdateParameters.add('AdditionalProperties', $AdditionalProperties) + if ($AdditionalProperties['proxyAutomaticConfigurationUrl'] -eq '') { + $AdditionalProperties['proxyAutomaticConfigurationUrl'] = $null + } + $UpdateParameters.Add('AdditionalProperties', $AdditionalProperties) } #region resource generator code @@ -431,7 +443,7 @@ function Set-TargetResource } elseif ($Ensure -eq 'Absent' -and $currentInstance.Ensure -eq 'Present') { - Write-Verbose -Message "Removing {$DisplayName}" + Write-Verbose -Message "Removing the Intune Wifi Configuration Policy for iOS with Id {$($currentInstance.Id)} and DisplayName {$DisplayName}" #region resource generator code Remove-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $currentInstance.Id #endregion @@ -469,6 +481,10 @@ function Test-TargetResource [System.Boolean] $DisableMacAddressRandomization, + [Parameter()] + [System.Boolean] + $ForcePreSharedKeyUpdate, + [Parameter()] [System.String] $NetworkName, @@ -494,6 +510,10 @@ function Test-TargetResource [System.String] $ProxySettings, + [Parameter()] + [System.String[]] + $RoleScopeTagIds, + [Parameter()] [System.String] $Ssid, @@ -554,43 +574,29 @@ function Test-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - Write-Verbose -Message "Testing configuration of {$Id}" + Write-Verbose -Message "Testing configuration of the Intune Wifi Configuration Policy for iOS with Id {$Id} and DisplayName {$DisplayName}" + + if ($ProxySettings -ne 'automatic' -and $ProxyAutomaticConfigurationUrl -ne '') { + throw 'ProxyAutomaticConfigurationUrl must be empty if ProxySettings is not "automatic".' + } $CurrentValues = Get-TargetResource @PSBoundParameters - $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() + $ValuesToCheck = ([Hashtable]$PSBoundParameters).Clone() $testResult = $true + #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) { - if ($PSBoundParameters[$key].getType().Name -like '*CimInstance*') + $source = $PSBoundParameters.$key + $target = $CurrentValues.$key + if ($null -ne $source -and $source.GetType().Name -like '*CimInstance*') { - $CIMArraySource = @() - $CIMArrayTarget = @() - $CIMArraySource += $PSBoundParameters[$key] - $CIMArrayTarget += $CurrentValues.$key - if ($CIMArraySource.count -ne $CIMArrayTarget.count) - { - Write-Verbose -Message "Configuration drift:Number of items does not match: Source=$($CIMArraySource.count) Target=$($CIMArrayTarget.count)" - $testResult = $false - break - } - $i = 0 - foreach ($item in $CIMArraySource ) - { - $testResult = Compare-M365DSCComplexObject ` - -Source (Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $CIMArraySource[$i]) ` - -Target ($CIMArrayTarget[$i]) + $testResult = Compare-M365DSCComplexObject ` + -Source ($source) ` + -Target ($target) - $i++ - if (-Not $testResult) - { - $testResult = $false - break - } - } - if (-Not $testResult) + if (-not $testResult) { - $testResult = $false break } @@ -598,20 +604,11 @@ function Test-TargetResource } } $ValuesToCheck.Remove('Id') | Out-Null + $ValuesToCheck.Remove('PreSharedKey') | Out-Null Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - #Convert any DateTime to String - foreach ($key in $ValuesToCheck.Keys) - { - if (($null -ne $CurrentValues[$key]) ` - -and ($CurrentValues[$key].getType().Name -eq 'DateTime')) - { - $CurrentValues[$key] = $CurrentValues[$key].toString() - } - } - if ($testResult) { $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` @@ -798,16 +795,18 @@ function Get-M365DSCAdditionalProperties 'WiFiSecurityType' ) - $results = @{'@odata.type' = '#microsoft.graph.iosWiFiConfiguration' } - $cloneProperties = $Properties.clone() + $results = @{ + '@odata.type' = '#microsoft.graph.iosWiFiConfiguration' + } + $cloneProperties = $Properties.Clone() foreach ($property in $cloneProperties.Keys) { if ($property -in ($additionalProperties) ) { $propertyName = $property[0].ToString().ToLower() + $property.Substring(1, $property.Length - 1) - if ($properties.$property -and $properties.$property.getType().FullName -like '*CIMInstance*') + if ($properties.$property -and $properties.$property.GetType().FullName -like '*CIMInstance*') { - if ($properties.$property.getType().FullName -like '*[[\]]') + if ($properties.$property.GetType().FullName -like '*[[\]]') { $array = @() foreach ($item in $properties.$property) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/MSFT_IntuneWifiConfigurationPolicyIOS.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/MSFT_IntuneWifiConfigurationPolicyIOS.schema.mof index 5a6751fc16..6fa9794b7c 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/MSFT_IntuneWifiConfigurationPolicyIOS.schema.mof +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/MSFT_IntuneWifiConfigurationPolicyIOS.schema.mof @@ -18,12 +18,14 @@ class MSFT_IntuneWifiConfigurationPolicyIOS : OMI_BaseResource [Write, Description("Connect automatically")] Boolean ConnectAutomatically; [Write, Description("Connect when network name is hidden")] Boolean ConnectWhenNetworkNameIsHidden; [Write, Description("Disable the MAC address randomization.")] Boolean DisableMacAddressRandomization; + [Write, Description("If the pre shared key should be updated, even if the policy is already equal.")] Boolean ForcePreSharedKeyUpdate; [Write, Description("Network name")] String NetworkName; [Write, Description("Pre shared key")] String PreSharedKey; [Write, Description("Proxy automatic configuration url")] String ProxyAutomaticConfigurationUrl; [Write, Description("Proxy manual address")] String ProxyManualAddress; [Write, Description("Proxy manual port")] UInt32 ProxyManualPort; [Write, Description("Proxy settings"), ValueMap{"none","manual","automatic"}, Values{"none","manual","automatic"}] String ProxySettings; + [Write, Description("List of Scope Tags for this Entity instance.")] String RoleScopeTagIds[]; [Write, Description("SSID")] String Ssid; [Write, Description("Wi-Fi security"), ValueMap{"open","wpaPersonal","wpaEnterprise","wep","wpa2Personal","wpa2Enterprise"}, Values{"open","wpaPersonal","wpaEnterprise","wep","wpa2Personal","wpa2Enterprise"}] String WiFiSecurityType; [Write, Description("Represents the assignment to the Intune policy."), EmbeddedInstance("MSFT_DeviceManagementConfigurationPolicyAssignments")] String Assignments[]; diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/readme.md b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/readme.md index 2404f28ce1..94474f8b8c 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/readme.md +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/readme.md @@ -3,4 +3,4 @@ ## Description -This resource configures an Intune Wifi Configuration Policy for iOS Device. +This resource configures an Intune Wifi Configuration Policy for iOS with Basic Wi-Fi type. diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/settings.json b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/settings.json index f4bc5e9e20..bbda58d5a0 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/settings.json +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyIOS/settings.json @@ -1,6 +1,6 @@ { "resourceName": "IntuneWifiConfigurationPolicyIOS", - "description": "This resource configures an Intune Wifi Configuration Policy for iOS Device.", + "description": "This resource configures an Intune Wifi Configuration Policy for iOS with Basic Wi-Fi type.", "permissions": { "graph": { "delegated": { diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/MSFT_IntuneWifiConfigurationPolicyMacOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/MSFT_IntuneWifiConfigurationPolicyMacOS.psm1 index 85ebc8c85f..b89fc7d5db 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/MSFT_IntuneWifiConfigurationPolicyMacOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/MSFT_IntuneWifiConfigurationPolicyMacOS.psm1 @@ -25,6 +25,15 @@ function Get-TargetResource [System.Boolean] $ConnectWhenNetworkNameIsHidden, + [Parameter()] + [System.String] + [ValidateSet('deviceChannel', 'userChannel')] + $DeploymentChannel, + + [Parameter()] + [System.Boolean] + $ForcePreSharedKeyUpdate, + [Parameter()] [System.String] $NetworkName, @@ -50,6 +59,10 @@ function Get-TargetResource [System.String] $ProxySettings, + [Parameter()] + [System.String[]] + $RoleScopeTagIds, + [Parameter()] [System.String] $Ssid, @@ -98,7 +111,7 @@ function Get-TargetResource $AccessTokens ) - Write-Verbose -Message "Getting configuration of the Intune Wifi Configuration Policy for MacOS with id {$Id} and DisplayName {$DisplayName}" + Write-Verbose -Message "Getting configuration of the Intune Wifi Configuration Policy for MacOS with Id {$Id} and DisplayName {$DisplayName}" try { @@ -132,15 +145,15 @@ function Get-TargetResource if ($null -eq $getValue) { $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -All -Filter "DisplayName eq '$DisplayName'" -ErrorAction SilentlyContinue | Where-Object ` - -FilterScript { ` - $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.macOSWiFiConfiguration' ` - } + -FilterScript { + $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.macOSWiFiConfiguration' + } } #endregion if ($null -eq $getValue) { - Write-Verbose -Message "No Intune Wifi Configuration Policy for MacOS with id {$Id} was found" + Write-Verbose -Message "No Intune Wifi Configuration Policy for MacOS with Id {$Id} was found" return $nullResult } } @@ -150,7 +163,7 @@ function Get-TargetResource } $Id = $getValue.Id - Write-Verbose -Message "Found an Intune Wifi Configuration Policy for MacOS with id {$Id}" + Write-Verbose -Message "Found an Intune Wifi Configuration Policy for MacOS with Id {$Id}" $results = @{ #region resource generator code Id = $getValue.Id @@ -158,12 +171,14 @@ function Get-TargetResource DisplayName = $getValue.DisplayName ConnectAutomatically = $getValue.AdditionalProperties.connectAutomatically ConnectWhenNetworkNameIsHidden = $getValue.AdditionalProperties.connectWhenNetworkNameIsHidden + DeploymentChannel = $getValue.AdditionalProperties.deploymentChannel NetworkName = $getValue.AdditionalProperties.networkName PreSharedKey = $getValue.AdditionalProperties.preSharedKey ProxyAutomaticConfigurationUrl = $getValue.AdditionalProperties.proxyAutomaticConfigurationUrl ProxyManualAddress = $getValue.AdditionalProperties.proxyManualAddress ProxyManualPort = $getValue.AdditionalProperties.proxyManualPort ProxySettings = $getValue.AdditionalProperties.proxySettings + RoleScopeTagIds = $getValue.RoleScopeTagIds Ssid = $getValue.AdditionalProperties.ssid WiFiSecurityType = $getValue.AdditionalProperties.wiFiSecurityType Ensure = 'Present' @@ -226,6 +241,15 @@ function Set-TargetResource [System.Boolean] $ConnectWhenNetworkNameIsHidden, + [Parameter()] + [System.String] + [ValidateSet('deviceChannel', 'userChannel')] + $DeploymentChannel, + + [Parameter()] + [System.Boolean] + $ForcePreSharedKeyUpdate, + [Parameter()] [System.String] $NetworkName, @@ -251,6 +275,10 @@ function Set-TargetResource [System.String] $ProxySettings, + [Parameter()] + [System.String[]] + $RoleScopeTagIds, + [Parameter()] [System.String] $Ssid, @@ -299,16 +327,17 @@ function Set-TargetResource $AccessTokens ) - try - { - $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` - -InboundParameters $PSBoundParameters + if ($ProxySettings -ne 'automatic' -and $ProxyAutomaticConfigurationUrl -ne '') { + throw 'ProxyAutomaticConfigurationUrl must be empty if ProxySettings is not "automatic"' } - catch - { - Write-Verbose -Message $_ + + if ($WiFiSecurityType -eq 'wpaPersonal' -and [string]::IsNullOrEmpty($PreSharedKey)) { + throw 'PreSharedKey is required but was not set.' } + $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` + -InboundParameters $PSBoundParameters + #Ensure the proper dependencies are installed in the current environment. Confirm-M365DSCDependencies @@ -326,9 +355,10 @@ function Set-TargetResource if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Absent') { - Write-Verbose -Message "Creating {$DisplayName}" + Write-Verbose -Message "Creating an Intune Wifi Configuration Policy for MacOS with DisplayName {$DisplayName}" $CreateParameters = ([Hashtable]$BoundParameters).Clone() $CreateParameters.Remove('Assignments') | Out-Null + $CreateParameters.Remove('ForcePreSharedKeyUpdate') | Out-Null $AdditionalProperties = Get-M365DSCAdditionalProperties -Properties ($CreateParameters) foreach ($key in $AdditionalProperties.keys) @@ -351,6 +381,9 @@ function Set-TargetResource if ($AdditionalProperties) { + if ($AdditionalProperties['proxyAutomaticConfigurationUrl'] -eq '') { + $AdditionalProperties['proxyAutomaticConfigurationUrl'] = $null + } $CreateParameters.Add('AdditionalProperties', $AdditionalProperties) } @@ -369,9 +402,10 @@ function Set-TargetResource } elseif ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Present') { - Write-Verbose -Message "Updating {$DisplayName}" + Write-Verbose -Message "Updating the Intune Wifi Configuration Policy for MacOS with Id {$($currentInstance.Id)} and DisplayName {$DisplayName}" $UpdateParameters = ([Hashtable]$BoundParameters).Clone() $UpdateParameters.Remove('Assignments') | Out-Null + $UpdateParameters.Remove('ForcePreSharedKeyUpdate') | Out-Null $AdditionalProperties = Get-M365DSCAdditionalProperties -Properties ($UpdateParameters) foreach ($key in $AdditionalProperties.keys) @@ -394,6 +428,9 @@ function Set-TargetResource if ($AdditionalProperties) { + if ($AdditionalProperties['proxyAutomaticConfigurationUrl'] -eq '') { + $AdditionalProperties['proxyAutomaticConfigurationUrl'] = $null + } $UpdateParameters.Add('AdditionalProperties', $AdditionalProperties) } @@ -409,7 +446,7 @@ function Set-TargetResource } elseif ($Ensure -eq 'Absent' -and $currentInstance.Ensure -eq 'Present') { - Write-Verbose -Message "Removing {$DisplayName}" + Write-Verbose -Message "Removing the Intune Wifi Configuration Policy for MacOS with Id {$($currentInstance.Id)} and DisplayName {$DisplayName}" #region resource generator code Remove-MgBetaDeviceManagementDeviceConfiguration -DeviceConfigurationId $currentInstance.Id #endregion @@ -443,6 +480,15 @@ function Test-TargetResource [System.Boolean] $ConnectWhenNetworkNameIsHidden, + [Parameter()] + [System.String] + [ValidateSet('deviceChannel', 'userChannel')] + $DeploymentChannel, + + [Parameter()] + [System.Boolean] + $ForcePreSharedKeyUpdate, + [Parameter()] [System.String] $NetworkName, @@ -468,6 +514,10 @@ function Test-TargetResource [System.String] $ProxySettings, + [Parameter()] + [System.String[]] + $RoleScopeTagIds, + [Parameter()] [System.String] $Ssid, @@ -528,43 +578,29 @@ function Test-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - Write-Verbose -Message "Testing configuration of {$Id}" + Write-Verbose -Message "Testing the Intune Wifi Configuration policy for MacOS with Id {$Id} and DisplayName {$DisplayName}" + + if ($ProxySettings -ne 'automatic' -and $ProxyAutomaticConfigurationUrl -ne '') { + throw 'ProxyAutomaticConfigurationUrl must be empty if ProxySettings is not "automatic".' + } $CurrentValues = Get-TargetResource @PSBoundParameters $ValuesToCheck = ([Hashtable]$PSBoundParameters).Clone() $testResult = $true + #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) { - if ($PSBoundParameters[$key].GetType().Name -like '*CimInstance*') + $source = $PSBoundParameters.$key + $target = $CurrentValues.$key + if ($null -ne $source -and $source.GetType().Name -like '*CimInstance*') { - $CIMArraySource = @() - $CIMArrayTarget = @() - $CIMArraySource += $PSBoundParameters[$key] - $CIMArrayTarget += $CurrentValues.$key - if ($CIMArraySource.Count -ne $CIMArrayTarget.Count) - { - Write-Verbose -Message "Configuration drift:Number of items does not match: Source=$($CIMArraySource.count) Target=$($CIMArrayTarget.count)" - $testResult = $false - break - } - $i = 0 - foreach ($item in $CIMArraySource ) - { - $testResult = Compare-M365DSCComplexObject ` - -Source (Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $CIMArraySource[$i]) ` - -Target ($CIMArrayTarget[$i]) + $testResult = Compare-M365DSCComplexObject ` + -Source ($source) ` + -Target ($target) - $i++ - if (-Not $testResult) - { - $testResult = $false - break - } - } - if (-Not $testResult) + if (-not $testResult) { - $testResult = $false break } @@ -572,20 +608,11 @@ function Test-TargetResource } } $ValuesToCheck.Remove('Id') | Out-Null + $ValuesToCheck.Remove('PreSharedKey') | Out-Null Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - #Convert any DateTime to String - foreach ($key in $ValuesToCheck.Keys) - { - if (($null -ne $CurrentValues[$key]) ` - -and ($CurrentValues[$key].GetType().Name -eq 'DateTime')) - { - $CurrentValues[$key] = $CurrentValues[$key].ToString() - } - } - if ($testResult) { $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` @@ -761,6 +788,7 @@ function Get-M365DSCAdditionalProperties $additionalProperties = @( 'ConnectAutomatically' 'ConnectWhenNetworkNameIsHidden' + 'DeploymentChannel' 'NetworkName' 'PreSharedKey' 'ProxyAutomaticConfigurationUrl' diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/MSFT_IntuneWifiConfigurationPolicyMacOS.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/MSFT_IntuneWifiConfigurationPolicyMacOS.schema.mof index 9f3c5d6f32..56a1a85af6 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/MSFT_IntuneWifiConfigurationPolicyMacOS.schema.mof +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/MSFT_IntuneWifiConfigurationPolicyMacOS.schema.mof @@ -17,12 +17,15 @@ class MSFT_IntuneWifiConfigurationPolicyMacOS : OMI_BaseResource [Write, Description("Description of the Intune policy.")] String Description; [Write, Description("Connect automatically")] Boolean ConnectAutomatically; [Write, Description("Connect when network name is hidden")] Boolean ConnectWhenNetworkNameIsHidden; + [Write, Description("Indicates the deployment channel type used to deploy the configuration profile."), ValueMap{"deviceChannel","userChannel"}, Values{"deviceChannel","userChannel"}] String DeploymentChannel; + [Write, Description("If the pre shared key should be updated, even if the policy is already equal.")] Boolean ForcePreSharedKeyUpdate; [Write, Description("Network name")] String NetworkName; [Write, Description("Pre shared key")] String PreSharedKey; [Write, Description("Proxy automatic configuration url")] String ProxyAutomaticConfigurationUrl; [Write, Description("Proxy manual address")] String ProxyManualAddress; [Write, Description("Proxy manual port")] UInt32 ProxyManualPort; [Write, Description("Proxy settings"), ValueMap{"none","manual","automatic"}, Values{"none","manual","automatic"}] String ProxySettings; + [Write, Description("List of Scope Tags for this Entity instance.")] String RoleScopeTagIds[]; [Write, Description("SSID")] String Ssid; [Write, Description("Wi-Fi security"), ValueMap{"open","wpaPersonal","wpaEnterprise","wep","wpa2Personal","wpa2Enterprise"}, Values{"open","wpaPersonal","wpaEnterprise","wep","wpa2Personal","wpa2Enterprise"}] String WiFiSecurityType; [Write, Description("Represents the assignment to the Intune policy."), EmbeddedInstance("MSFT_DeviceManagementConfigurationPolicyAssignments")] String Assignments[]; diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/readme.md b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/readme.md index f31837ceee..14660891ed 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/readme.md +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/readme.md @@ -3,4 +3,4 @@ ## Description -This resource configures an Intune Wifi Configuration Policy for MacOS Device. +This resource configures an Intune Wifi Configuration Policy for MacOS with Basic Wi-Fi type. diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/settings.json b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/settings.json index f83e95e9c8..d9b7815a1f 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/settings.json +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyMacOS/settings.json @@ -1,6 +1,6 @@ { "resourceName": "IntuneWifiConfigurationPolicyMacOS", - "description": "This resource configures an Intune Wifi Configuration Policy for MacOS Device.", + "description": "This resource configures an Intune Wifi Configuration Policy for MacOS with Basic Wi-Fi type.", "permissions": { "graph": { "delegated": { diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/MSFT_IntuneWifiConfigurationPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/MSFT_IntuneWifiConfigurationPolicyWindows10.psm1 index ce63e7c122..1551a9abf6 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/MSFT_IntuneWifiConfigurationPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/MSFT_IntuneWifiConfigurationPolicyWindows10.psm1 @@ -29,10 +29,22 @@ function Get-TargetResource [System.Boolean] $ConnectWhenNetworkNameIsHidden, + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance] + $DeviceManagementApplicabilityRuleOsEdition, + + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance] + $DeviceManagementApplicabilityRuleOsVersion, + [Parameter()] [System.Boolean] $ForceFIPSCompliance, + [Parameter()] + [System.Boolean] + $ForcePreSharedKeyUpdate, + [Parameter()] [ValidateSet('unrestricted', 'fixed', 'variable')] [System.String] @@ -63,6 +75,10 @@ function Get-TargetResource [System.String] $ProxySetting, + [Parameter()] + [System.String[]] + $RoleScopeTagIds, + [Parameter()] [System.String] $Ssid, @@ -145,9 +161,9 @@ function Get-TargetResource if ($null -eq $getValue) { $getValue = Get-MgBetaDeviceManagementDeviceConfiguration -All -Filter "DisplayName eq '$DisplayName'" -ErrorAction SilentlyContinue | Where-Object ` - -FilterScript { ` - $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.windowsWifiConfiguration' ` - } + -FilterScript { + $_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.windowsWifiConfiguration' + } } #endregion @@ -161,34 +177,56 @@ function Get-TargetResource { $getValue = $Script:exportedInstance } + $Id = $getValue.Id Write-Verbose -Message "Found an Intune Wifi Configuration Policy for Windows10 with id {$Id}" + + $complexDeviceManagementApplicabilityRuleOsEdition = @{} + $complexDeviceManagementApplicabilityRuleOsEdition.Add('OsEditionTypes', [string[]]$getValue.DeviceManagementApplicabilityRuleOSEdition.OsEditionTypes) + $complexDeviceManagementApplicabilityRuleOsEdition.Add('RuleType', [string]$getValue.DeviceManagementApplicabilityRuleOSEdition.RuleType) + if ($complexDeviceManagementApplicabilityRuleOsEdition.values.Where({$null -ne $_}).Count -eq 0) + { + $complexDeviceManagementApplicabilityRuleOsEdition = $null + } + + $complexDeviceManagementApplicabilityRuleOsVersion = @{} + $complexDeviceManagementApplicabilityRuleOsVersion.Add('MaxOSVersion', $getValue.DeviceManagementApplicabilityRuleOSVersion.MaxOSVersion) + $complexDeviceManagementApplicabilityRuleOsVersion.Add('MinOSVersion', $getValue.DeviceManagementApplicabilityRuleOSVersion.MinOSVersion) + $complexDeviceManagementApplicabilityRuleOsVersion.Add('RuleType', [string]$getValue.DeviceManagementApplicabilityRuleOSVersion.RuleType) + if ($complexDeviceManagementApplicabilityRuleOsVersion.values.Where({$null -ne $_}).Count -eq 0) + { + $complexDeviceManagementApplicabilityRuleOsVersion = $null + } + $results = @{ #region resource generator code - Id = $getValue.Id - Description = $getValue.Description - DisplayName = $getValue.DisplayName - ConnectAutomatically = $getValue.AdditionalProperties.connectAutomatically - ConnectToPreferredNetwork = $getValue.AdditionalProperties.connectToPreferredNetwork - ConnectWhenNetworkNameIsHidden = $getValue.AdditionalProperties.connectWhenNetworkNameIsHidden - ForceFIPSCompliance = $getValue.AdditionalProperties.forceFIPSCompliance - MeteredConnectionLimit = $getValue.AdditionalProperties.meteredConnectionLimit - NetworkName = $getValue.AdditionalProperties.networkName - PreSharedKey = $getValue.AdditionalProperties.preSharedKey - ProxyAutomaticConfigurationUrl = $getValue.AdditionalProperties.proxyAutomaticConfigurationUrl - ProxyManualAddress = $getValue.AdditionalProperties.proxyManualAddress - ProxyManualPort = $getValue.AdditionalProperties.proxyManualPort - ProxySetting = $getValue.AdditionalProperties.proxySetting - Ssid = $getValue.AdditionalProperties.ssid - WifiSecurityType = $getValue.AdditionalProperties.wifiSecurityType - Ensure = 'Present' - Credential = $Credential - ApplicationId = $ApplicationId - TenantId = $TenantId - ApplicationSecret = $ApplicationSecret - CertificateThumbprint = $CertificateThumbprint - Managedidentity = $ManagedIdentity.IsPresent - AccessTokens = $AccessTokens + Id = $getValue.Id + Description = $getValue.Description + DisplayName = $getValue.DisplayName + ConnectAutomatically = $getValue.AdditionalProperties.connectAutomatically + ConnectToPreferredNetwork = $getValue.AdditionalProperties.connectToPreferredNetwork + ConnectWhenNetworkNameIsHidden = $getValue.AdditionalProperties.connectWhenNetworkNameIsHidden + DeviceManagementApplicabilityRuleOsEdition = $complexDeviceManagementApplicabilityRuleOsEdition + DeviceManagementApplicabilityRuleOsVersion = $complexDeviceManagementApplicabilityRuleOsVersion + ForceFIPSCompliance = $getValue.AdditionalProperties.forceFIPSCompliance + MeteredConnectionLimit = $getValue.AdditionalProperties.meteredConnectionLimit + NetworkName = $getValue.AdditionalProperties.networkName + PreSharedKey = $getValue.AdditionalProperties.preSharedKey + ProxyAutomaticConfigurationUrl = $getValue.AdditionalProperties.proxyAutomaticConfigurationUrl + ProxyManualAddress = $getValue.AdditionalProperties.proxyManualAddress + ProxyManualPort = $getValue.AdditionalProperties.proxyManualPort + ProxySetting = $getValue.AdditionalProperties.proxySetting + RoleScopeTagIds = $getValue.RoleScopeTagIds + Ssid = $getValue.AdditionalProperties.ssid + WifiSecurityType = $getValue.AdditionalProperties.wifiSecurityType + Ensure = 'Present' + Credential = $Credential + ApplicationId = $ApplicationId + TenantId = $TenantId + ApplicationSecret = $ApplicationSecret + CertificateThumbprint = $CertificateThumbprint + Managedidentity = $ManagedIdentity.IsPresent + AccessTokens = $AccessTokens } $assignmentsValues = Get-MgBetaDeviceManagementDeviceConfigurationAssignment -DeviceConfigurationId $Id @@ -245,10 +283,22 @@ function Set-TargetResource [System.Boolean] $ConnectWhenNetworkNameIsHidden, + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance] + $DeviceManagementApplicabilityRuleOsEdition, + + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance] + $DeviceManagementApplicabilityRuleOsVersion, + [Parameter()] [System.Boolean] $ForceFIPSCompliance, + [Parameter()] + [System.Boolean] + $ForcePreSharedKeyUpdate, + [Parameter()] [ValidateSet('unrestricted', 'fixed', 'variable')] [System.String] @@ -279,6 +329,10 @@ function Set-TargetResource [System.String] $ProxySetting, + [Parameter()] + [System.String[]] + $RoleScopeTagIds, + [Parameter()] [System.String] $Ssid, @@ -327,16 +381,17 @@ function Set-TargetResource $AccessTokens ) - try - { - $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` - -InboundParameters $PSBoundParameters + if ($ProxySetting -ne 'automatic' -and $ProxyAutomaticConfigurationUrl -ne '') { + throw 'ProxyAutomaticConfigurationUrl must be empty if ProxySetting is not "automatic"' } - catch - { - Write-Verbose -Message $_ + + if ($WiFiSecurityType -eq 'wpaPersonal' -and [string]::IsNullOrEmpty($PreSharedKey)) { + throw 'PreSharedKey is required but was not set.' } + $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` + -InboundParameters $PSBoundParameters + #Ensure the proper dependencies are installed in the current environment. Confirm-M365DSCDependencies @@ -350,40 +405,30 @@ function Set-TargetResource #endregion $currentInstance = Get-TargetResource @PSBoundParameters - - $PSBoundParameters.Remove('Ensure') | Out-Null - $PSBoundParameters.Remove('Credential') | Out-Null - $PSBoundParameters.Remove('ApplicationId') | Out-Null - $PSBoundParameters.Remove('ApplicationSecret') | Out-Null - $PSBoundParameters.Remove('TenantId') | Out-Null - $PSBoundParameters.Remove('CertificateThumbprint') | Out-Null - $PSBoundParameters.Remove('ManagedIdentity') | Out-Null - $PSBoundParameters.Remove('AccessTokens') | Out-Null + $BoundParameters = Remove-M365DSCAuthenticationParameter -BoundParameters $PSBoundParameters if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Absent') { - Write-Verbose -Message "Creating {$DisplayName}" - $PSBoundParameters.Remove('Assignments') | Out-Null + Write-Verbose -Message "Creating an Intune Wifi Configuration Policy for Windows10 with DisplayName {$DisplayName}" - $CreateParameters = ([Hashtable]$PSBoundParameters).clone() - $CreateParameters = Rename-M365DSCCimInstanceParameter -Properties $CreateParameters + $CreateParameters = ([Hashtable]$BoundParameters).Clone() + $CreateParameters.Remove('Assignments') | Out-Null + $CreateParameters.Remove('Id') | Out-Null + $CreateParameters.Remove('ForcePreSharedKeyUpdate') | Out-Null $AdditionalProperties = Get-M365DSCAdditionalProperties -Properties ($CreateParameters) - foreach ($key in $AdditionalProperties.keys) + foreach ($key in $AdditionalProperties.Keys) { if ($key -ne '@odata.type') { - $keyName = $key.substring(0, 1).ToUpper() + $key.substring(1, $key.length - 1) - $CreateParameters.remove($keyName) + $keyName = $key.Substring(0, 1).ToUpper() + $key.Substring(1, $key.Length - 1) + $CreateParameters.Remove($keyName) } } - $CreateParameters.Remove('Id') | Out-Null - $CreateParameters.Remove('Verbose') | Out-Null - - foreach ($key in ($CreateParameters.clone()).Keys) + foreach ($key in ($CreateParameters.Clone()).Keys) { - if ($CreateParameters[$key].getType().Fullname -like '*CimInstance*') + if ($CreateParameters[$key].GetType().Fullname -like '*CimInstance*') { $CreateParameters[$key] = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $CreateParameters[$key] } @@ -391,16 +436,19 @@ function Set-TargetResource if ($AdditionalProperties) { - $CreateParameters.add('AdditionalProperties', $AdditionalProperties) + if ($AdditionalProperties['proxyAutomaticConfigurationUrl'] -eq '') { + $AdditionalProperties['proxyAutomaticConfigurationUrl'] = $null + } + $CreateParameters.Add('AdditionalProperties', $AdditionalProperties) } #region resource generator code $policy = New-MgBetaDeviceManagementDeviceConfiguration @CreateParameters $assignmentsHash = ConvertTo-IntunePolicyAssignment -IncludeDeviceFilter:$true -Assignments $Assignments - if ($policy.id) + if ($policy.Id) { - Update-DeviceConfigurationPolicyAssignment -DeviceConfigurationPolicyId $policy.id ` + Update-DeviceConfigurationPolicyAssignment -DeviceConfigurationPolicyId $policy.Id ` -Targets $assignmentsHash ` -Repository 'deviceManagement/deviceConfigurations' } @@ -408,28 +456,26 @@ function Set-TargetResource } elseif ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Present') { - Write-Verbose -Message "Updating {$DisplayName}" - $PSBoundParameters.Remove('Assignments') | Out-Null + Write-Verbose -Message "Updating the Intune Wifi Configuration Policy with Id {$($currentInstance.Id)} and DisplayName {$DisplayName}" - $UpdateParameters = ([Hashtable]$PSBoundParameters).clone() - $UpdateParameters = Rename-M365DSCCimInstanceParameter -Properties $UpdateParameters + $UpdateParameters = ([Hashtable]$BoundParameters).Clone() + $UpdateParameters.Remove('Assignments') | Out-Null + $UpdateParameters.Remove('Id') | Out-Null + $UpdateParameters.Remove('ForcePreSharedKeyUpdate') | Out-Null $AdditionalProperties = Get-M365DSCAdditionalProperties -Properties ($UpdateParameters) foreach ($key in $AdditionalProperties.keys) { if ($key -ne '@odata.type') { - $keyName = $key.substring(0, 1).ToUpper() + $key.substring(1, $key.length - 1) - $UpdateParameters.remove($keyName) + $keyName = $key.Substring(0, 1).ToUpper() + $key.Substring(1, $key.Length - 1) + $UpdateParameters.Remove($keyName) } } - $UpdateParameters.Remove('Id') | Out-Null - $UpdateParameters.Remove('Verbose') | Out-Null - - foreach ($key in ($UpdateParameters.clone()).Keys) + foreach ($key in ($UpdateParameters.Clone()).Keys) { - if ($UpdateParameters[$key].getType().Fullname -like '*CimInstance*') + if ($UpdateParameters[$key].GetType().Fullname -like '*CimInstance*') { $UpdateParameters[$key] = Convert-M365DSCDRGComplexTypeToHashtable -ComplexObject $UpdateParameters[$key] } @@ -437,7 +483,10 @@ function Set-TargetResource if ($AdditionalProperties) { - $UpdateParameters.add('AdditionalProperties', $AdditionalProperties) + if ($AdditionalProperties['proxyAutomaticConfigurationUrl'] -eq '') { + $AdditionalProperties['proxyAutomaticConfigurationUrl'] = $null + } + $UpdateParameters.Add('AdditionalProperties', $AdditionalProperties) } #region resource generator code @@ -490,10 +539,22 @@ function Test-TargetResource [System.Boolean] $ConnectWhenNetworkNameIsHidden, + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance] + $DeviceManagementApplicabilityRuleOsEdition, + + [Parameter()] + [Microsoft.Management.Infrastructure.CimInstance] + $DeviceManagementApplicabilityRuleOsVersion, + [Parameter()] [System.Boolean] $ForceFIPSCompliance, + [Parameter()] + [System.Boolean] + $ForcePreSharedKeyUpdate, + [Parameter()] [ValidateSet('unrestricted', 'fixed', 'variable')] [System.String] @@ -524,6 +585,10 @@ function Test-TargetResource [System.String] $ProxySetting, + [Parameter()] + [System.String[]] + $RoleScopeTagIds, + [Parameter()] [System.String] $Ssid, @@ -584,43 +649,29 @@ function Test-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - Write-Verbose -Message "Testing configuration of {$Id}" + Write-Verbose -Message "Testing configuration of the Intune Wifi Configuration Policy for Windows10 with Id {$Id} and DisplayName {$DisplayName}" + + if ($ProxySetting -ne 'automatic' -and $ProxyAutomaticConfigurationUrl -ne '') { + throw 'ProxyAutomaticConfigurationUrl must be empty if ProxySetting is not "automatic".' + } $CurrentValues = Get-TargetResource @PSBoundParameters - $ValuesToCheck = ([Hashtable]$PSBoundParameters).clone() + $ValuesToCheck = ([Hashtable]$PSBoundParameters).Clone() $testResult = $true + #Compare Cim instances foreach ($key in $PSBoundParameters.Keys) { - if ($PSBoundParameters[$key].getType().Name -like '*CimInstance*') + $source = $PSBoundParameters.$key + $target = $CurrentValues.$key + if ($null -ne $source -and $source.GetType().Name -like '*CimInstance*') { - $CIMArraySource = @() - $CIMArrayTarget = @() - $CIMArraySource += $PSBoundParameters[$key] - $CIMArrayTarget += $CurrentValues.$key - if ($CIMArraySource.count -ne $CIMArrayTarget.count) - { - Write-Verbose -Message "Configuration drift:Number of items does not match: Source=$($CIMArraySource.count) Target=$($CIMArrayTarget.count)" - $testResult = $false - break - } - $i = 0 - foreach ($item in $CIMArraySource ) - { - $testResult = Compare-M365DSCComplexObject ` - -Source (Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $CIMArraySource[$i]) ` - -Target ($CIMArrayTarget[$i]) + $testResult = Compare-M365DSCComplexObject ` + -Source ($source) ` + -Target ($target) - $i++ - if (-Not $testResult) - { - $testResult = $false - break - } - } - if (-Not $testResult) + if (-not $testResult) { - $testResult = $false break } @@ -628,20 +679,11 @@ function Test-TargetResource } } $ValuesToCheck.Remove('Id') | Out-Null + $ValuesToCheck.Remove('PreSharedKey') | Out-Null Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)" Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)" - #Convert any DateTime to String - foreach ($key in $ValuesToCheck.Keys) - { - if (($null -ne $CurrentValues[$key]) ` - -and ($CurrentValues[$key].getType().Name -eq 'DateTime')) - { - $CurrentValues[$key] = $CurrentValues[$key].toString() - } - } - if ($testResult) { $testResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` @@ -753,6 +795,32 @@ function Export-TargetResource $Script:exportedInstance = $config $Results = Get-TargetResource @Params + if ($Results.DeviceManagementApplicabilityRuleOsEdition) + { + $complexTypeStringResult = Get-M365DSCDRGComplexTypeToString -ComplexObject $Results.DeviceManagementApplicabilityRuleOsEdition -CIMInstanceName DeviceManagementApplicabilityRuleOsEdition + if ($complexTypeStringResult) + { + $Results.DeviceManagementApplicabilityRuleOsEdition = $complexTypeStringResult + } + else + { + $Results.Remove('DeviceManagementApplicabilityRuleOsEdition') | Out-Null + } + } + + if ($Results.DeviceManagementApplicabilityRuleOsVersion) + { + $complexTypeStringResult = Get-M365DSCDRGComplexTypeToString -ComplexObject $Results.DeviceManagementApplicabilityRuleOsVersion -CIMInstanceName DeviceManagementApplicabilityRuleOsVersion + if ($complexTypeStringResult) + { + $Results.DeviceManagementApplicabilityRuleOsVersion = $complexTypeStringResult + } + else + { + $Results.Remove('DeviceManagementApplicabilityRuleOsVersion') | Out-Null + } + } + if ($Results.Assignments) { $complexTypeStringResult = Get-M365DSCDRGComplexTypeToString -ComplexObject $Results.Assignments -CIMInstanceName DeviceManagementConfigurationPolicyAssignments @@ -771,7 +839,7 @@ function Export-TargetResource -ModulePath $PSScriptRoot ` -Results $Results ` -Credential $Credential ` - -NoEscape @('Assignments') + -NoEscape @('Assignments', 'DeviceManagementApplicabilityRuleOsEdition', 'DeviceManagementApplicabilityRuleOsVersion') ` $dscContent += $currentDSCBlock Save-M365DSCPartialExport -Content $currentDSCBlock ` @@ -818,6 +886,8 @@ function Get-M365DSCAdditionalProperties 'ConnectAutomatically' 'ConnectToPreferredNetwork' 'ConnectWhenNetworkNameIsHidden' + 'DeviceManagementApplicabilityRuleOsEdition' + 'DeviceManagementApplicabilityRuleOsVersion' 'ForceFIPSCompliance' 'MeteredConnectionLimit' 'NetworkName' @@ -831,15 +901,15 @@ function Get-M365DSCAdditionalProperties ) $results = @{'@odata.type' = '#microsoft.graph.windowsWifiConfiguration' } - $cloneProperties = $Properties.clone() + $cloneProperties = $Properties.Clone() foreach ($property in $cloneProperties.Keys) { if ($property -in ($additionalProperties) ) { $propertyName = $property[0].ToString().ToLower() + $property.Substring(1, $property.Length - 1) - if ($properties.$property -and $properties.$property.getType().FullName -like '*CIMInstance*') + if ($properties.$property -and $properties.$property.GetType().FullName -like '*CIMInstance*') { - if ($properties.$property.getType().FullName -like '*[[\]]') + if ($properties.$property.GetType().FullName -like '*[[\]]') { $array = @() foreach ($item in $properties.$property) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/MSFT_IntuneWifiConfigurationPolicyWindows10.schema.mof b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/MSFT_IntuneWifiConfigurationPolicyWindows10.schema.mof index 9de4a873a5..ce71e30790 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/MSFT_IntuneWifiConfigurationPolicyWindows10.schema.mof +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/MSFT_IntuneWifiConfigurationPolicyWindows10.schema.mof @@ -9,6 +9,22 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments [Write, Description("The collection Id that is the target of the assignment.(ConfigMgr)")] String collectionId; }; +[ClassVersion("1.0.0")] +class MSFT_DeviceManagementApplicabilityRuleOsEdition +{ + [Write, Description("Name for object")] String Name; + [Write, Description("Applicability rule OS edition type")] String OsEditionTypes[]; + [Write, Description("Applicability Rule type"), ValueMap{"include","exclude"}, Values{"include","exclude"}] String RuleType; +}; +[ClassVersion("1.0.0")] +class MSFT_DeviceManagementApplicabilityRuleOsVersion +{ + [Write, Description("Name for object")] String Name; + [Write, Description("Min OS version for Applicability Rule")] String MinOSVersion; + [Write, Description("Max OS version for Applicability Rule")] String MaxOSVersion; + [Write, Description("Applicability Rule type"), ValueMap{"include","exclude"}, Values{"include","exclude"}] String RuleType; +}; + [ClassVersion("1.0.0.0"), FriendlyName("IntuneWifiConfigurationPolicyWindows10")] class MSFT_IntuneWifiConfigurationPolicyWindows10 : OMI_BaseResource { @@ -18,7 +34,10 @@ class MSFT_IntuneWifiConfigurationPolicyWindows10 : OMI_BaseResource [Write, Description("Connect automatically")] Boolean ConnectAutomatically; [Write, Description("Connect to preferred network")] Boolean ConnectToPreferredNetwork; [Write, Description("Connect when network name is hidden")] Boolean ConnectWhenNetworkNameIsHidden; + [Write, Description("The OS edition applicability for this Policy. "), EmbeddedInstance("MSFT_DeviceManagementApplicabilityRuleOsEdition")] String DeviceManagementApplicabilityRuleOsEdition; + [Write, Description("The OS version applicability rule for this Policy."), EmbeddedInstance("MSFT_DeviceManagementApplicabilityRuleOsVersion")] String DeviceManagementApplicabilityRuleOsVersion; [Write, Description("Force FIPS compliance")] Boolean ForceFIPSCompliance; + [Write, Description("If the pre shared key should be updated, even if the policy is already equal.")] Boolean ForcePreSharedKeyUpdate; [Write, Description("Metered connection limit"), ValueMap{"unrestricted","fixed","variable"}, Values{"unrestricted","fixed","variable"}] String MeteredConnectionLimit; [Write, Description("Network name")] String NetworkName; [Write, Description("Pre shared key")] String PreSharedKey; @@ -26,6 +45,7 @@ class MSFT_IntuneWifiConfigurationPolicyWindows10 : OMI_BaseResource [Write, Description("Proxy manual address")] String ProxyManualAddress; [Write, Description("Proxy manual port")] UInt32 ProxyManualPort; [Write, Description("Proxy setting"), ValueMap{"none","manual","automatic"}, Values{"none","manual","automatic"}] String ProxySetting; + [Write, Description("List of Scope Tags for this Entity instance.")] String RoleScopeTagIds[]; [Write, Description("SSID")] String Ssid; [Write, Description("Wi-Fi security"), ValueMap{"open","wpaPersonal","wpaEnterprise","wep","wpa2Personal","wpa2Enterprise"}, Values{"open","wpaPersonal","wpaEnterprise","wep","wpa2Personal","wpa2Enterprise"}] String WifiSecurityType; [Write, Description("Represents the assignment to the Intune policy."), EmbeddedInstance("MSFT_DeviceManagementConfigurationPolicyAssignments")] String Assignments[]; diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/readme.md b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/readme.md index fecfe1f6a8..b21cac9c06 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/readme.md +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/readme.md @@ -3,4 +3,4 @@ ## Description -This resource configures an Intune Wifi Configuration Policy for Windows10 Device. +This resource configures an Intune Wifi Configuration Policy for Windows10 with Basic Wi-Fi type. diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/settings.json b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/settings.json index 2ba6389c60..38d039f50a 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/settings.json +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneWifiConfigurationPolicyWindows10/settings.json @@ -1,6 +1,6 @@ { "resourceName": "IntuneWifiConfigurationPolicyWindows10", - "description": "This resource configures an Intune Wifi Configuration Policy for Windows10 Device.", + "description": "This resource configures an Intune Wifi Configuration Policy for Windows10 with Basic Wi-Fi type.", "permissions": { "graph": { "delegated": { diff --git a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 index bcc1613c31..f2df1f9c5b 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1 @@ -897,7 +897,7 @@ function Compare-M365DSCComplexObject { $compareResult = Compare-Object ` -ReferenceObject ($referenceObject) ` - -DifferenceObject ($differenceObject) + -DifferenceObject ($differenceObject) -PassThru } if ($null -ne $compareResult -and $compareResult.Length -gt 0) diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyAndroidOpenSourceProject.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyAndroidOpenSourceProject.Tests.ps1 index cf19f19562..f2499a6638 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyAndroidOpenSourceProject.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyAndroidOpenSourceProject.Tests.ps1 @@ -239,6 +239,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'ReverseDSC Tests' -Fixture { BeforeAll { + $Global:PartialExportFileName = "$(New-Guid).partial.ps1" $testParams = @{ Credential = $Credential } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyIOS.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyIOS.Tests.ps1 index 29f6181734..22aebeeef4 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyIOS.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyIOS.Tests.ps1 @@ -70,10 +70,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' WiFiSecurityType = 'open' - Ensure = 'Present' Credential = $Credential } @@ -108,10 +107,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' WiFiSecurityType = 'open' - Ensure = 'Absent' Credential = $Credential } @@ -128,15 +126,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' PreSharedKey = 'FakeStringValue' ConnectWhenNetworkNameIsHidden = $True - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' Id = 'FakeStringValue' - } } } @@ -168,10 +164,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' WiFiSecurityType = 'open' - Ensure = 'Present' Credential = $Credential } @@ -188,20 +183,17 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' PreSharedKey = 'FakeStringValue' ConnectWhenNetworkNameIsHidden = $True - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' Id = 'FakeStringValue' - } } } - It 'Should return true from the Test method' { Test-TargetResource @testParams | Should -Be $true } @@ -221,10 +213,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' WiFiSecurityType = 'open' - Ensure = 'Present' Credential = $Credential } @@ -238,15 +229,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' PreSharedKey = 'FakeStringValue' ProxyManualPort = 7 - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' Id = 'FakeStringValue' - } } } @@ -267,6 +256,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'ReverseDSC Tests' -Fixture { BeforeAll { + $Global:PartialExportFileName = "$(New-Guid).partial.ps1" $testParams = @{ Credential = $Credential } @@ -283,15 +273,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' PreSharedKey = 'FakeStringValue' ConnectWhenNetworkNameIsHidden = $True - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' Id = 'FakeStringValue' - } } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyMacOS.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyMacOS.Tests.ps1 index 5fd8ca2c6c..2d83cf2647 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyMacOS.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyMacOS.Tests.ps1 @@ -69,10 +69,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' WiFiSecurityType = 'open' - Ensure = 'Present' Credential = $Credential } @@ -106,10 +105,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' WiFiSecurityType = 'open' - Ensure = 'Absent' Credential = $Credential } @@ -125,15 +123,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' PreSharedKey = 'FakeStringValue' ConnectWhenNetworkNameIsHidden = $True - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' Id = 'FakeStringValue' - } } } @@ -164,10 +160,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' WiFiSecurityType = 'open' - Ensure = 'Present' Credential = $Credential } @@ -183,15 +178,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' PreSharedKey = 'FakeStringValue' ConnectWhenNetworkNameIsHidden = $True - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' Id = 'FakeStringValue' - } } } @@ -215,10 +208,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' WiFiSecurityType = 'open' - Ensure = 'Present' Credential = $Credential } @@ -232,15 +224,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' PreSharedKey = 'FakeStringValue' ProxyManualPort = 7 - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' Id = 'FakeStringValue' - } } } @@ -261,6 +251,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'ReverseDSC Tests' -Fixture { BeforeAll { + $Global:PartialExportFileName = "$(New-Guid).partial.ps1" $testParams = @{ Credential = $Credential } @@ -276,15 +267,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' PreSharedKey = 'FakeStringValue' ConnectWhenNetworkNameIsHidden = $True - ProxySettings = 'none' + ProxySettings = 'automatic' Ssid = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' Id = 'FakeStringValue' - } } } diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyWindows10.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyWindows10.Tests.ps1 index 33b3dcadc1..5f5a40b9b1 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyWindows10.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.IntuneWifiConfigurationPolicyWindows10.Tests.ps1 @@ -72,10 +72,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySetting = 'none' + ProxySetting = 'automatic' Ssid = 'FakeStringValue' WifiSecurityType = 'open' - Ensure = 'Present' Credential = $Credential } @@ -112,10 +111,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySetting = 'none' + ProxySetting = 'automatic' Ssid = 'FakeStringValue' WifiSecurityType = 'open' - Ensure = 'Absent' Credential = $Credential } @@ -132,12 +130,11 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyManualPort = 25 ProxyManualAddress = 'FakeStringValue' ConnectWhenNetworkNameIsHidden = $True - ProxySetting = 'none' + ProxySetting = 'automatic' ProxyAutomaticConfigurationUrl = 'FakeStringValue' ConnectAutomatically = $True ConnectToPreferredNetwork = $True Ssid = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' @@ -176,10 +173,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySetting = 'none' + ProxySetting = 'automatic' Ssid = 'FakeStringValue' WifiSecurityType = 'open' - Ensure = 'Present' Credential = $Credential } @@ -196,12 +192,11 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyManualPort = 25 ProxyManualAddress = 'FakeStringValue' ConnectWhenNetworkNameIsHidden = $True - ProxySetting = 'none' + ProxySetting = 'automatic' ProxyAutomaticConfigurationUrl = 'FakeStringValue' ConnectAutomatically = $True ConnectToPreferredNetwork = $True Ssid = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' @@ -233,10 +228,9 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyAutomaticConfigurationUrl = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' ProxyManualPort = 25 - ProxySetting = 'none' + ProxySetting = 'automatic' Ssid = 'FakeStringValue' WifiSecurityType = 'open' - Ensure = 'Present' Credential = $Credential } @@ -253,8 +247,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyManualPort = 7 Ssid = 'FakeStringValue' ProxyManualAddress = 'FakeStringValue' - ProxySetting = 'none' - + ProxySetting = 'automatic' } Description = 'FakeStringValue' DisplayName = 'FakeStringValue' @@ -280,6 +273,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Context -Name 'ReverseDSC Tests' -Fixture { BeforeAll { + $Global:PartialExportFileName = "$(New-Guid).partial.ps1" $testParams = @{ Credential = $Credential } @@ -296,12 +290,11 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { ProxyManualPort = 25 ProxyManualAddress = 'FakeStringValue' ConnectWhenNetworkNameIsHidden = $True - ProxySetting = 'none' + ProxySetting = 'automatic' ProxyAutomaticConfigurationUrl = 'FakeStringValue' ConnectAutomatically = $True ConnectToPreferredNetwork = $True Ssid = 'FakeStringValue' - } Description = 'FakeStringValue' DisplayName = 'FakeStringValue'