Skip to content

Commit

Permalink
Merge pull request #5516 from NikCharlebois/IntuneDeviceManagmentAndr…
Browse files Browse the repository at this point in the history
…oidDeviceOwnerEnrollmentProfile

IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile Fixes
  • Loading branch information
NikCharlebois authored Dec 6, 2024
2 parents fbfbf20 + ed81eae commit d19a632
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 41 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# UNRELEASED

* IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile
* Fixing issue with the way the QrCodeImage property was exported and handled.
* IntuneFirewallPolicyWindows10
* Fix export of properties that appear multiple times in subsections.

Expand Down Expand Up @@ -384,7 +386,7 @@
selected
* Fixed retrieval of resource when it cannot be found by `Id`
* Added a few verbose messages
* IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile
* IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile
* Initial release.
* IntuneEndpointDetectionAndResponsePolicyWindows10
* Fixes an issue with `AutoFromConnector` as the Configuration package type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@
"read": [],
"update": []
}
},
"WindowsDefenderATP":{
"delegated": {
"read": [],
"update": []
},
"application": {
"read": [
"Machine.Read.All"
],
"update": [
"Machine.ReadWrite.All"
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function Get-TargetResource
$QrCodeContent,

[Parameter()]
[System.String]
[Microsoft.Management.Infrastructure.CimInstance]
$QrCodeImage,

[Parameter()]
Expand Down Expand Up @@ -149,6 +149,14 @@ function Get-TargetResource
-All `
-Filter "displayName eq '$DisplayName'" `
-ErrorAction SilentlyContinue

# Need to do another call by id to get QrCode info. Can't just expand the property.
if ($null -ne $androidDeviceOwnerEnrollmentProfile)
{
Write-Verbose -Message 'Found by DisplayName, now retrieving additional details by id.'
$androidDeviceOwnerEnrollmentProfile = Get-MgBetaDeviceManagementAndroidDeviceOwnerEnrollmentProfile `
-AndroidDeviceOwnerEnrollmentProfileId $androidDeviceOwnerEnrollmentProfile.Id
}
}

if ($null -eq $androidDeviceOwnerEnrollmentProfile)
Expand All @@ -157,6 +165,15 @@ function Get-TargetResource
return $nullResult
}

$QrCodeImageValue = $null
if ($null -ne $androidDeviceOwnerEnrollmentProfile.QrCodeImage.Type)
{
$QrCodeImageValue = @{
type = $androidDeviceOwnerEnrollmentProfile.QrCodeImage.Type
value = [Array] ($androidDeviceOwnerEnrollmentProfile.QrCodeImage.Value -join ',')
}
}

$results = @{
Id = $androidDeviceOwnerEnrollmentProfile.Id
DisplayName = $androidDeviceOwnerEnrollmentProfile.DisplayName
Expand All @@ -169,7 +186,7 @@ function Get-TargetResource
EnrollmentTokenUsageCount = $androidDeviceOwnerEnrollmentProfile.EnrollmentTokenUsageCount
IsTeamsDeviceProfile = $androidDeviceOwnerEnrollmentProfile.IsTeamsDeviceProfile
QrCodeContent = $androidDeviceOwnerEnrollmentProfile.QrCodeContent
QrCodeImage = $androidDeviceOwnerEnrollmentProfile.QrCodeImage
QrCodeImage = $QrCodeImageValue
RoleScopeTagIds = $androidDeviceOwnerEnrollmentProfile.RoleScopeTagIds
TokenCreationDateTime = $androidDeviceOwnerEnrollmentProfile.TokenCreationDateTime.ToString()
TokenExpirationDateTime = $androidDeviceOwnerEnrollmentProfile.TokenExpirationDateTime.ToString()
Expand Down Expand Up @@ -253,7 +270,7 @@ function Set-TargetResource
$QrCodeContent,

[Parameter()]
[System.String]
[Microsoft.Management.Infrastructure.CimInstance]
$QrCodeImage,

[Parameter()]
Expand Down Expand Up @@ -334,6 +351,21 @@ function Set-TargetResource
$currentInstance = Get-TargetResource @PSBoundParameters
$setParameters = Remove-M365DSCAuthenticationParameter -BoundParameters $PSBoundParameters

if ($null -ne $QrCodeImage)
{
$QrCodeImageValue = @{
type = $QrCodeImage.type
value = [System.Byte[]] @()
}

foreach ($byteValue in $QrCodeImage.value)
{
$convertedValue = [System.Byte]([BitConverter]::GetBytes($byteValue))[0]
$QrCodeImageValue.value += $convertedValue
}
$setParameters.QrCodeImage = $QrCodeImageValue
$setParameters.QrCodeImage.value = [System.Byte[]]($setParameters.QrCodeImage.value)
}
# CREATE
if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Absent')
{
Expand Down Expand Up @@ -411,7 +443,7 @@ function Test-TargetResource
$QrCodeContent,

[Parameter()]
[System.String]
[Microsoft.Management.Infrastructure.CimInstance]
$QrCodeImage,

[Parameter()]
Expand Down Expand Up @@ -491,19 +523,50 @@ function Test-TargetResource

Write-Verbose -Message "Testing configuration of AndroidDeviceOwnerEnrollmentProfile: {$DisplayName}"

$ValuesToCheck = $PSBoundParameters
$ValuesToCheck.Remove('WifiPassword') | Out-Null
$CurrentValues = Get-TargetResource @PSBoundParameters
Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)"
Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $ValuesToCheck)"
$ValuesToCheck = ([Hashtable]$PSBoundParameters).Clone()
$ValuesToCheck.Remove('WifiPassword') | Out-Null
$ValuesToCheck.Remove("QrCodeImage") | Out-Null
$ValuesToCheck.Remove("QrCodeContent") | Out-Null
$ValuesToCheck.Remove("TokenValue") | Out-Null
$ValuesToCheck.Remove("TokenCreationDateTime") | Out-Null
$ValuesToCheck.Remove("TokenExpirationDateTime") | Out-Null

#Compare Cim instances
Write-Verbose -Message "Evaluating CIM Instances"
$TestResult = $true
$RemainingValuesToCheck = $ValuesToCheck
foreach ($key in $ValuesToCheck.Keys)
{
$source = $ValuesToCheck.$key
$target = $CurrentValues.$key
if ($null -ne $source -and $source.GetType().Name -like '*CimInstance*')
{
$TestResult = Compare-M365DSCComplexObject `
-Source ($source) `
-Target ($target)

if (-not $testResult)
{
Write-Verbose -Message "Found drift in property {$key}"
break
}

$TestResult = Test-M365DSCParameterState `
-CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $ValuesToCheck.Keys
$RemainingValuesToCheck.Remove($key) | Out-Null
}
}
Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)"
Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $RemainingValuesToCheck)"
if ($TestResult)
{
$TestResult = Test-M365DSCParameterState `
-CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
-DesiredValues $PSBoundParameters `
-ValuesToCheck $RemainingValuesToCheck.Keys

Write-Verbose -Message "Test-TargetResource returned $TestResult"
Write-Verbose -Message "Test-TargetResource returned $TestResult"
}

return $TestResult
}
Expand Down Expand Up @@ -598,12 +661,33 @@ function Export-TargetResource
$Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode `
-Results $Results

if ($Results.QrCodeImage)
{
$complexTypeStringResult = Get-M365DSCDRGComplexTypeToString -ComplexObject $Results.QrCodeImage `
-CIMInstanceName 'IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfileQRImage'
if ($complexTypeStringResult)
{
$Results.QrCodeImage = $complexTypeStringResult
$Results.QrCodeImage = $Results.QrCodeImage.ReplacE("@('", "@(").Replace("')", "`)")
}
else
{
$Results.Remove('QrCodeImage') | Out-Null
}
}

$currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName `
-ConnectionMode $ConnectionMode `
-ModulePath $PSScriptRoot `
-Results $Results `
-Credential $Credential

if ($Results.QrCodeImage)
{
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'QrCodeImage' -IsCIMArray:$false

}

$dscContent += $currentDSCBlock
Save-M365DSCPartialExport -Content $currentDSCBlock `
-FileName $Global:PartialExportFileName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[ClassVersion("1.0.0.0")]
class MSFT_IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfileQRImage
class MSFT_IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfileQRImage
{
[Write, Description("Indicates the content mime type.")] String type;
[Write, Description("The byte array that contains the actual content.")] String value;
[Write, Description("The byte array that contains the actual content.")] UInt32 value[];
};

[ClassVersion("1.0.0.0"), FriendlyName("IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile")]
class MSFT_IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile")]
class MSFT_IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile : OMI_BaseResource
{
[Key, Description("Display name for the enrollment profile.")] String DisplayName;
[Write, Description("Unique GUID for the enrollment profile. Read-Only.")] String Id;
Expand All @@ -21,7 +21,7 @@ class MSFT_IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile : OMI_BaseRe
[Write, Description("Total number of Android devices that have enrolled using this enrollment profile.")] UInt32 EnrolledDeviceCount;
[Write, Description("Total number of AOSP devices that have enrolled using the current token. Valid values 0 to 20000")] UInt32 EnrollmentTokenUsageCount;
[Write, Description("String used to generate a QR code for the token.")] String QrCodeContent;
[Write, Description("String used to generate a QR code for the token.")] String QrCodeImage;
[Write, Description("String used to generate a QR code for the token."), EmbeddedInstance("MSFT_IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfileQRImage")] String QrCodeImage;
[Write, Description("List of Scope Tags for this Entity instance.")] String RoleScopeTagIds[];
[Write, Description("Boolean that indicates that the Wi-Fi network should be configured during device provisioning. When set to TRUE, device provisioning will use Wi-Fi related properties to automatically connect to Wi-Fi networks. When set to FALSE or undefined, other Wi-Fi related properties will be ignored. Default value is TRUE. Returned by default.")] Boolean ConfigureWifi;
[Write, Description("String that contains the wi-fi login ssid")] String WifiSsid;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile
# IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile

## Description

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"resourceName": "IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile",
"resourceName": "IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile",
"description": "Enrollment Profile used to enroll Android Enterprise devices using Google's Cloud Management.",
"permissions": {
"graph": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Configuration Example
Import-DscResource -ModuleName Microsoft365DSC
node localhost
{
IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile "IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile-MyTestEnrollmentProfile"
IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile "IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile-MyTestEnrollmentProfile"
{
AccountId = "8d2ac1fd-0ac9-4047-af2f-f1e6323c9a34e";
ApplicationId = $ApplicationId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Configuration Example
Import-DscResource -ModuleName Microsoft365DSC
node localhost
{
IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile "IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile-MyTestEnrollmentProfile"
IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile "IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile-MyTestEnrollmentProfile"
{
AccountId = "8d2ac1fd-0ac9-4047-af2f-f1e6323c9a34e";
ApplicationId = $ApplicationId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Configuration Example
Import-DscResource -ModuleName Microsoft365DSC
node localhost
{
IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile "IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile-MyTestEnrollmentProfile"
IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile "IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile-MyTestEnrollmentProfile"
{
AccountId = "8d2ac1fd-0ac9-4047-af2f-f1e6323c9a34e";
ApplicationId = $ApplicationId;
Expand Down
4 changes: 2 additions & 2 deletions Modules/Microsoft365DSC/SchemaDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -40356,7 +40356,7 @@
]
},
{
"ClassName": "MSFT_IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfileQRImage",
"ClassName": "MSFT_IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfileQRImage",
"Parameters": [
{
"CIMType": "String",
Expand All @@ -40371,7 +40371,7 @@
]
},
{
"ClassName": "MSFT_IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile",
"ClassName": "MSFT_IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile",
"Parameters": [
{
"CIMType": "String",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
AppleIdentifier = "Apple ID";
Certificate = "FakeCertMIIFdjCCBF6gAwIBAgIIMVIk4qQ3QnQwDQYJKoZIhvcNAQELBQAwgYwxQDA+BgNVBAMMN0FwcGxlIEFwcGxpY2F0aW9uIEludGVncmF0aW9uIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMwEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0yNDEwMjUxODE0NThaFw0yNTEwMjUxODE0NTdaMIGPMUwwSgYKCZImiZPyLGQBAQw8Y29tLmFwcGxlLm1nbXQuRXh0ZXJuYWwuMDA1NWU3ZTktNDkyYi00ZDQ2LTk2N2EtMjhmYzVkNDllZGI2MTIwMAYDVQQDDClBUFNQOjAwNTVlN2U5LTQ5MmItNGQ0Ni05NjdhLTI4ZmM1ZDQ5ZWRiNjELMAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4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9kBvvyAXqLBhPm/J3lC+0oU/AJf3EYXwTGNxo2gCiPhJcomX3WXnbYrZHU/TH8umhtVgGqd6Xlke9iFwypidHC9dHWmwud4V42oAMZ9FHItSwh5o6rQMoZop7uKD72vxSuunEWFymF9S22DJ0oums1Ya8JmUpNfMzkyGVMMZs1OCYpzQxYpuwC+sMAVfGucp1IRLutccRGYeSV4LTN4CwfWreCPnPGjkBEmGqmusn5t/THirGjRBykUARWFpthx1wmJqHFqeAv4nhbcR/+Fu4gQQQaayX0dauBcU0T57==";
DataSharingConsetGranted = $True;

Ensure = "Present";
ApplicationId = $ApplicationId;
TenantId = $TenantId;
Expand Down Expand Up @@ -713,7 +713,7 @@
{
Name = 'hosted_app'
}

MSFT_IntuneGroupPolicyDefinitionValuePresentationValueKeyValuePair
{
Name = 'user_script'
Expand Down Expand Up @@ -747,7 +747,7 @@
Id = '14c48993-35af-4b77-a4f8-12de917b1bb9'
odataType = '#microsoft.graph.groupPolicyPresentationValueDecimal'
}

MSFT_IntuneGroupPolicyDefinitionValuePresentationValue
{
presentationDefinitionId = '98998e7f-cc2a-4d96-8c47-35dd4b2ce56b'
Expand All @@ -756,7 +756,7 @@
Id = '4d654df9-6826-470f-af4e-d37491663c76'
odataType = '#microsoft.graph.groupPolicyPresentationValueDecimal'
}

MSFT_IntuneGroupPolicyDefinitionValuePresentationValue
{
presentationDefinitionId = '6900e752-4bc3-463b-9fc8-36d78c77bc3e'
Expand Down Expand Up @@ -2411,7 +2411,7 @@
TenantId = $TenantId;
CertificateThumbprint = $CertificateThumbprint;
}
IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile 'IntuneDeviceManagmentAndroidDeviceOwnerEnrollmentProfile-MyTestEnrollmentProfile'
IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile 'IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile-MyTestEnrollmentProfile'
{
AccountId = "8d2ac1fd-0ac9-4047-af2f-f1e6323c9a34e";
ApplicationId = $ApplicationId;
Expand Down Expand Up @@ -2527,7 +2527,7 @@
ApplicationId = $ApplicationId;
TenantId = $TenantId;
CertificateThumbprint = $CertificateThumbprint;

}
IntuneEndpointDetectionAndResponsePolicyMacOS 'myEDRPolicy'
{
Expand All @@ -2540,7 +2540,7 @@
ApplicationId = $ApplicationId;
TenantId = $TenantId;
CertificateThumbprint = $CertificateThumbprint;

}
IntuneEndpointDetectionAndResponsePolicyWindows10 'myEDRPolicy'
{
Expand Down
Loading

0 comments on commit d19a632

Please sign in to comment.