Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@
* 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
* Removed the parameter `MaxProcesses` from the internal `Start-M365DSCConfigurationExtract` function.
* 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ function Get-TargetResource
[System.Boolean]
$DisableMacAddressRandomization,

[Parameter()]
[System.Boolean]
$ForcePreSharedKeyUpdate,

[Parameter()]
[System.String]
$NetworkName,
Expand All @@ -54,6 +58,10 @@ function Get-TargetResource
[System.String]
$ProxySettings,

[Parameter()]
[System.String[]]
$RoleScopeTagIds,

[Parameter()]
[System.String]
$Ssid,
Expand Down Expand Up @@ -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 = @{
Expand All @@ -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'
Expand All @@ -176,7 +186,7 @@ function Get-TargetResource
TenantId = $TenantId
ApplicationSecret = $ApplicationSecret
CertificateThumbprint = $CertificateThumbprint
Managedidentity = $ManagedIdentity.IsPresent
ManagedIdentity = $ManagedIdentity.IsPresent
AccessTokens = $AccessTokens
}

Expand Down Expand Up @@ -234,6 +244,10 @@ function Set-TargetResource
[System.Boolean]
$DisableMacAddressRandomization,

[Parameter()]
[System.Boolean]
$ForcePreSharedKeyUpdate,

[Parameter()]
[System.String]
$NetworkName,
Expand All @@ -259,6 +273,10 @@ function Set-TargetResource
[System.String]
$ProxySettings,

[Parameter()]
[System.String[]]
$RoleScopeTagIds,

[Parameter()]
[System.String]
$Ssid,
Expand Down Expand Up @@ -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

Expand All @@ -330,94 +349,87 @@ 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]
}
}

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'
}
#endregion
}
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]
}
}

if ($AdditionalProperties)
{
$UpdateParameters.add('AdditionalProperties', $AdditionalProperties)
if ($AdditionalProperties['proxyAutomaticConfigurationUrl'] -eq '') {
$AdditionalProperties['proxyAutomaticConfigurationUrl'] = $null
}
$UpdateParameters.Add('AdditionalProperties', $AdditionalProperties)
}

#region resource generator code
Expand All @@ -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
Expand Down Expand Up @@ -469,6 +481,10 @@ function Test-TargetResource
[System.Boolean]
$DisableMacAddressRandomization,

[Parameter()]
[System.Boolean]
$ForcePreSharedKeyUpdate,

[Parameter()]
[System.String]
$NetworkName,
Expand All @@ -494,6 +510,10 @@ function Test-TargetResource
[System.String]
$ProxySettings,

[Parameter()]
[System.String[]]
$RoleScopeTagIds,

[Parameter()]
[System.String]
$Ssid,
Expand Down Expand Up @@ -554,64 +574,41 @@ 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
}

$ValuesToCheck.Remove($key) | Out-Null
}
}
$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 `
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Loading