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

Error while running export using application id and secret #2423

Closed
sanyoggulaty opened this issue Oct 19, 2022 · 10 comments
Closed

Error while running export using application id and secret #2423

sanyoggulaty opened this issue Oct 19, 2022 · 10 comments

Comments

@sanyoggulaty
Copy link

sanyoggulaty commented Oct 19, 2022

ISSUE TITLE:Error while running export using application id and secret
Please prefix the issue title with the resource name, e.g.
'ResourceName: Exporting AAD Group

ISSUE DESCRIPTION (this template):

While running an export for any component- I get this error

Method invocation failed because [System.String] does not contain a method named 'GetNetworkCredential'.

@sanyoggulaty
Copy link
Author

Error while running an export using service principal with application secret
Method invocation failed because [System.String] does not contain a method named 'GetNetworkCredential'.

@andikrueger
Copy link
Collaborator

What version of m365dsc are you using and what are your environment details? Please provide as much information as possible.

Please review the event log of m365dsc and windows if there are any related events.

@sanyoggulaty
Copy link
Author

I am running 1.22.1019.1 version. I have checked event log and was not able to find anything.

Running on Windows version- Windows 10 19044.2006

The export works fine with username/credentials but it fails with the application id/secret

@andikrueger andikrueger added the V1.22.1019.1 Version 1.22.1019.1 label Oct 20, 2022
@andikrueger
Copy link
Collaborator

What workloads do you want to export?

@NikCharlebois
Copy link
Collaborator

Also, can you post the entire command you are trying to execute when getting this error? Thanks

@sanyoggulaty
Copy link
Author

I am running an export for AADGroup and AADConditionalAccessPolicy. It works fine with app id and certificate but it doesnt with app secrect

Export-M365DSCConfiguration -Components @("AADGroup") -ApplicationId '' -ApplicationSecret '' -TenantId ''

@mwgroenewald
Copy link

mwgroenewald commented Oct 25, 2022

Module version: 1.22.1019.1

I have the same issue. This is my first time using it. I also ran Update-M365DSCDependencies -Force, however oddly enough I'm still get a message indicating newer versions of components are available. the command is:
Export-M365DSCConfiguration -Components @("AADConditionalAccessPolicy") -ApplicationId 'removed' -TenantId 'removed' -ApplicationSecret 'removed' -FileName C:\Temp\M365DSC-Config.ps1

Below is the full message:
New version of {Microsoft.Graph.Applications} is available {1.13.0}
New version of {Microsoft.Graph.DeviceManagement} is available {1.13.0}
New version of {Microsoft.Graph.DeviceManagement.Administration} is available {1.13.0}
New version of {Microsoft.Graph.DeviceManagement.Enrolment} is available {1.13.0}
New version of {Microsoft.Graph.Devices.CorporateManagement} is available {1.13.0}
New version of {Microsoft.Graph.Groups} is available {1.13.0}
New version of {Microsoft.Graph.Identity.DirectoryManagement} is available {1.13.0}
New version of {Microsoft.Graph.Identity.Governance} is available {1.13.0}
New version of {Microsoft.Graph.Identity.SignIns} is available {1.13.0}
New version of {Microsoft.Graph.Planner} is available {1.13.0}
New version of {Microsoft.Graph.Teams} is available {1.13.0}
New version of {Microsoft.Graph.Users} is available {1.13.0}
New version of {Microsoft.Graph.Users.Actions} is available {1.13.0}
New version of {Microsoft.PowerApps.Administration.PowerShell} is available {2.0.154}
New version of {MicrosoftTeams} is available {4.8.0}
New version of {MSCloudLoginAssistant} is available {1.0.96}
New version of {ReverseDSC} is available {2.0.0.13}
Exporting Microsoft 365 configuration for Components: AADConditionalAccessPolicy

Authentication methods specified:

  • Service Principal with Application Secret

New version of {Microsoft.Graph.Applications} is available {1.13.0}
New version of {Microsoft.Graph.DeviceManagement} is available {1.13.0}
New version of {Microsoft.Graph.DeviceManagement.Administration} is available {1.13.0}
New version of {Microsoft.Graph.DeviceManagement.Enrolment} is available {1.13.0}
New version of {Microsoft.Graph.Devices.CorporateManagement} is available {1.13.0}
New version of {Microsoft.Graph.Groups} is available {1.13.0}
New version of {Microsoft.Graph.Identity.DirectoryManagement} is available {1.13.0}
New version of {Microsoft.Graph.Identity.Governance} is available {1.13.0}
New version of {Microsoft.Graph.Identity.SignIns} is available {1.13.0}
New version of {Microsoft.Graph.Planner} is available {1.13.0}
New version of {Microsoft.Graph.Teams} is available {1.13.0}
New version of {Microsoft.Graph.Users} is available {1.13.0}
New version of {Microsoft.Graph.Users.Actions} is available {1.13.0}
New version of {Microsoft.PowerApps.Administration.PowerShell} is available {2.0.154}
New version of {MicrosoftTeams} is available {4.8.0}
New version of {MSCloudLoginAssistant} is available {1.0.96}
New version of {ReverseDSC} is available {2.0.0.13}
Method invocation failed because [System.String] does not contain a method named 'GetNetworkCredential'.
Partial Export file was saved at: C:\Users\ADMINI~1\AppData\Local\Temp\2\d4ea8a11-7245-433e-a199-95e65b7282f2.partial.ps1

menswearUK added a commit to menswearUK/Microsoft365DSC that referenced this issue Oct 26, 2022
changed ApplicationSecret variable from string to PSCredential in functions  Start-M365DSCConfigurationExtract,  Export-M365DSCConfiguration, and Get-M365DSCTenantDomain.
Removed line converting the string to  a pscredential as it is no longer required, added a line to convert back to string for final output
@menswearUK
Copy link
Contributor

I'm getting the same errors, I think it is because a couple of functions in the M365DSCReverse.psm1 and M365DSCUtil.psm1 are still expecting $applicationSecret to be a string (using latest module code and updated dependencies). I've got it to work on my exports ( just exporting IntuneAppProtectionPolicyAndroid config) - I'll submit a pull request for review

@NikCharlebois
Copy link
Collaborator

@menswearUK & @sanyoggulaty can you please confirm if this is still an issue with the latest version? Thanks

@menswearUK
Copy link
Contributor

@NikCharlebois - latest version seems to be working fine for me - passing the secret to Export-M365DSCConfiguration as a string as per previous versions. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants