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

Export does not work with ApplicationSecret #2447

Closed
ykuijs opened this issue Oct 26, 2022 · 0 comments · Fixed by #2449 or #2451
Closed

Export does not work with ApplicationSecret #2447

ykuijs opened this issue Oct 26, 2022 · 0 comments · Fixed by #2449 or #2451

Comments

@ykuijs
Copy link
Member

ykuijs commented Oct 26, 2022

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

With the switch of the ApplicationSecret from String to PSCredential, the code in the Export function has not been updated. It still accepts the ApplicationSecret as a string and does not convert it later on. But then it calls New-M365DSCTenantDomain here:

$organization = Get-M365DSCTenantDomain -ApplicationId $ApplicationId `
-TenantId $TenantId `
-CertificateThumbprint $CertificateThumbprint `
-ApplicationSecret $ApplicationSecret `
-CertificatePath $CertificatePath

That in turn is calling the New-M365DSCConnection function and passing in all parameters, including the ApplicationSecret as string:

$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' `
-InboundParameters $PSBoundParameters

The New-M365DSCConnection function is then trying to get the secrets from the PSCredential object (which it is not):

$InboundParameters.ApplicationSecret = $InboundParameters.ApplicationSecret.GetNetworkCredential().Password

This results in a "Method invocation failed because [System.String] does not contain a method named 'GetNetworkCredential'." error

Verbose logs showing the problem

Suggested solution to the issue

Update the export functions to also require the ApplicationSecret as a PSCredential

The DSC configuration that is used to reproduce the issue (as detailed as possible)

# insert configuration here

The operating system the target node is running

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

dev

NikCharlebois added a commit to NikCharlebois/Microsoft365DSC that referenced this issue Oct 26, 2022
NikCharlebois added a commit to NikCharlebois/Microsoft365DSC that referenced this issue Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant