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

IntuneDeviceConfigurationPolicyAndroidDeviceOwner: Credential Parameter as String in Export #2270

Closed
andikrueger opened this issue Sep 12, 2022 · 5 comments · Fixed by #2395
Labels
Bug Something isn't working Intune

Comments

@andikrueger
Copy link
Collaborator

Details of the scenario you tried and the problem that is occurring

  1. Export settings
    The export of the resource does not generate a well formatted configuration. This configuration cannot be applied to a tenant. The parameter Credential is of type string rather than PSCredential. This breaks the configuration.

Verbose logs showing the problem

image

Suggested solution to the issue

Change Credential Param in Exported configuration object.

Version of the DSC module that was used ('dev' if using current dev branch)

1.22.831.1

@andikrueger andikrueger added Bug Something isn't working Intune labels Sep 12, 2022
@William-Francillette
Copy link
Contributor

Hi @andikrueger
Not sure how this is supposed to look but after rebuilding the resource I still get the credentials as a PSCredential
image
image

@andikrueger
Copy link
Collaborator Author

The issue are the quotation marks in the configuration part of this resource. The credentials should be the variable only and not a string…

@andikrueger
Copy link
Collaborator Author

@William-Francillette Were you able to investigate this one any further?

@William-Francillette
Copy link
Contributor

William-Francillette commented Sep 30, 2022

@William-Francillette Were you able to investigate this one any further?

@andikrueger,
I found the problem: it resides in Convert-DSCStringParamToVariable called from Get-M365DSCExportContentForResource inside export-TargetResource

In Convert-DSCStringParamToVariable (ReverseDSC.Core.psm) :

$startPosition = -1
do
{
    $startPosition = $DSCBlock.IndexOf($ParameterName, $startPosition + 1)
    $testValidStartPositionEqual = $DSCBlock.IndexOf("=", $startPosition)
    $testValidStartPositionQuotes = $DSCBlock.IndexOf("`"", $startPosition)
} while ($testValidStartPositionEqual -gt $testValidStartPositionQuotes -and
    $startPosition -ne -1)

This should return the position of Credential parameter however due to CertificateCredentialConfigurationDisabled it returns the wrong start position and thus the quotes are not removed. ($DSCBlock.IndexOf($ParameterName, $startPosition + 1))

The trick could be instead of using

$partialContent = Convert-DSCStringParamToVariable -DSCBlock $partialContent `
-ParameterName 'Credential'

In Get-M365DSCExportContentForResource (M365DSCUtil.psm) we could use instead

$partialContent = Convert-DSCStringParamToVariable -DSCBlock $partialContent `
-ParameterName 'Credential '

With a space at the end of Credential in the parameter name which would ensure to retrieve the startPosition of the Credential parameter and not any other parameter

@William-Francillette
Copy link
Contributor

@andikrueger, @NikCharlebois
I can include that fix in my next PR if adding the space after Credential is acceptable
I'll try to get it done asap -
My next PR is for adding the assignments attributes for Intune resources and also switching to the beta version some of the resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Intune
Projects
None yet
2 participants