Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android Device Administrator Basic Wi-Fi Policy #3989

Closed
Closed
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change log for Microsoft365DSC

# UNRELEASED

* IntuneWiFiConfigurationPolicyAndroidDeviceAdministrator
* Renamed resource to IntuneWiFiConfigurationPolicyAndroidDeviceAdministratorBasic
* Updated properties
* Fixed import, update and test of the resource
FIXES [#3975](https://github.com/microsoft/Microsoft365DSC/issues/3975)

# 1.23.1129.1

* AADRoleSetting
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Get-TargetResource
$Ssid,

[Parameter()]
[ValidateSet('open', 'wpaEnterprise', 'wpa2Enterprise')]
[ValidateSet('open')]
[System.String]
$WiFiSecurityType,

Expand Down Expand Up @@ -108,6 +108,7 @@ function Get-TargetResource
-FilterScript { `
$_.AdditionalProperties.'@odata.type' -eq '#microsoft.graph.androidWiFiConfiguration' `
}
$Id = $getValue.Id
}
#endregion

Expand Down Expand Up @@ -202,7 +203,7 @@ function Set-TargetResource
$Ssid,

[Parameter()]
[ValidateSet('open', 'wpaEnterprise', 'wpa2Enterprise')]
[ValidateSet('open')]
[System.String]
$WiFiSecurityType,

Expand Down Expand Up @@ -418,7 +419,7 @@ function Test-TargetResource
$Ssid,

[Parameter()]
[ValidateSet('open', 'wpaEnterprise', 'wpa2Enterprise')]
[ValidateSet('open')]
[System.String]
$WiFiSecurityType,

Expand Down Expand Up @@ -474,7 +475,7 @@ function Test-TargetResource
$CurrentValues = Get-TargetResource @PSBoundParameters
$ValuesToCheck = ([Hashtable]$PSBoundParameters).clone()

if ($CurrentValues.Ensure -eq 'Absent')
if ($CurrentValues.Ensure -ne $PSBoundParameters.Ensure)
{
Write-Verbose -Message "Test-TargetResource returned $false"
return $false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ class MSFT_DeviceManagementConfigurationPolicyAssignments
[Write, Description("The collection Id that is the target of the assignment.(ConfigMgr)")] String collectionId;
};

[ClassVersion("1.0.0.0"), FriendlyName("IntuneWifiConfigurationPolicyAndroidDeviceAdministrator")]
class MSFT_IntuneWifiConfigurationPolicyAndroidDeviceAdministrator : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("IntuneWifiConfigurationPolicyAndroidDeviceAdministratorBasic")]
class MSFT_IntuneWifiConfigurationPolicyAndroidDeviceAdministratorBasic : OMI_BaseResource
{
[Write, Description("Id of the Intune Policy.")] String Id;
[Key, Description("Display name of the Intune Policy.")] String DisplayName;
[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("Connect if the network name is hidden.")] Boolean ConnectWhenNetworkNameIsHidden;
[Write, Description("Network name.")] String NetworkName;
[Write, Description("SSID.")] String Ssid;
[Write, Description("Wi-Fi security type."), ValueMap{"open","wpaEnterprise","wpa2Enterprise"}, Values{"open","wpaEnterprise","wpa2Enterprise"}] String WiFiSecurityType;
[Write, Description("Wi-Fi security type."), ValueMap{"open"}, Values{"open"}] String WiFiSecurityType;
[Write, Description("Represents the assignment to the Intune policy."), EmbeddedInstance("MSFT_DeviceManagementConfigurationPolicyAssignments")] String Assignments[];
[Write, Description("Present ensures the policy exists, absent ensures it is removed."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure;
[Write, Description("Credentials of the Intune Admin"), EmbeddedInstance("MSFT_Credential")] string Credential;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# IntuneWifiConfigurationPolicyAndroidDeviceAdministratorBasic

## Description

This resource configures an Intune Android Device Administrator Basic Wifi Configuration Policy.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceName": "IntuneWifiConfigurationPolicyAndroidDeviceAdministrator",
"description": "This resource configures an Intune Wifi Configuration Policy Android Device Administrator Device.",
"resourceName": "IntuneWifiConfigurationPolicyAndroidDeviceAdministratorBasic",
"description": "This resource configures an Intune Android Device Administrator Basic Wifi Configuration Policy.",
"permissions": {
"graph": {
"delegated": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Configuration Example

node localhost
{
IntuneWiFiConfigurationPolicyAndroidDeviceAdministrator 'myWifiConfigAndroidDevicePolicy'
IntuneWiFiConfigurationPolicyAndroidDeviceAdministratorBasic 'myWifiConfigAndroidDevicePolicy'
{
Id = '41869a42-3217-4bfa-9929-92668fc674c5'
Assignments = @(
Expand All @@ -23,12 +23,12 @@ Configuration Example
dataType = '#microsoft.graph.allDevicesAssignmentTarget'
}
)
ConnectAutomatically = $False
ConnectAutomatically = $True
ConnectWhenNetworkNameIsHidden = $True
DisplayName = 'Wifi Configuration Androind Device'
DisplayName = 'Android Device Admin Basic Wi-Fi Profile'
NetworkName = 'b71f8c63-8140-4c7e-b818-f9b4aa98b79b'
Ssid = 'sf'
WiFiSecurityType = 'wpaEnterprise'
Ssid = 'ssid'
WiFiSecurityType = 'open'
Ensure = 'Present'
Credential = $credsGlobalAdmin
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Import-Module -Name (Join-Path -Path $M365DSCTestFolder `
-Resolve)

$Global:DscHelper = New-M365DscUnitTestHelper -StubModule $CmdletModule `
-DscResource 'IntuneWifiConfigurationPolicyAndroidDeviceAdministrator' -GenericStubModule $GenericStubPath
-DscResource 'IntuneWifiConfigurationPolicyAndroidDeviceAdministratorBasic' -GenericStubModule $GenericStubPath
Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
InModuleScope -ModuleName $Global:DscHelper.ModuleName -ScriptBlock {
Invoke-Command -ScriptBlock $Global:DscHelper.InitializeScript -NoNewScope
Expand All @@ -24,7 +24,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
$secpasswd = ConvertTo-SecureString 'test@password1' -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ('tenantadmin@mydomain.com', $secpasswd)


Mock -CommandName Confirm-M365DSCDependencies -MockWith {
}

Expand Down Expand Up @@ -54,7 +53,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
}

# Test contexts
Context -Name 'The IntuneWifiConfigurationPolicyAndroidDeviceAdministrator should exist but it DOES NOT' -Fixture {
Context -Name 'The IntuneWifiConfigurationPolicyAndroidDeviceAdministratorBasic should exist but it DOES NOT' -Fixture {
BeforeAll {
$testParams = @{
ConnectAutomatically = $True
Expand All @@ -65,7 +64,6 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
NetworkName = 'FakeStringValue'
Ssid = 'FakeStringValue'
WiFiSecurityType = 'open'

Ensure = 'Present'
Credential = $Credential
}
Expand All @@ -86,7 +84,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
}
}

Context -Name 'The IntuneWifiConfigurationPolicyAndroidDeviceAdministrator exists but it SHOULD NOT' -Fixture {
Context -Name 'The IntuneWifiConfigurationPolicyAndroidDeviceAdministratorBasic exists but it SHOULD NOT' -Fixture {
BeforeAll {
$testParams = @{
ConnectAutomatically = $True
Expand Down Expand Up @@ -134,7 +132,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
Should -Invoke -CommandName Remove-MgBetaDeviceManagementDeviceConfiguration -Exactly 1
}
}
Context -Name 'The IntuneWifiConfigurationPolicyAndroidDeviceAdministrator Exists and Values are already in the desired state' -Fixture {
Context -Name 'The IntuneWifiConfigurationPolicyAndroidDeviceAdministratorBasic Exists and Values are already in the desired state' -Fixture {
BeforeAll {
$testParams = @{
ConnectAutomatically = $True
Expand Down Expand Up @@ -169,13 +167,12 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
}
}


It 'Should return true from the Test method' {
Test-TargetResource @testParams | Should -Be $true
}
}

Context -Name 'The IntuneWifiConfigurationPolicyAndroidDeviceAdministrator exists and values are NOT in the desired state' -Fixture {
Context -Name 'The IntuneWifiConfigurationPolicyAndroidDeviceAdministratorBasic exists and values are NOT in the desired state' -Fixture {
BeforeAll {
$testParams = @{
ConnectAutomatically = $True
Expand Down