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-M365DSCConfiguration fails with "...parameter name 'Error' is ambigious" #2682

Closed
elygre opened this issue Dec 17, 2022 · 1 comment · Fixed by #2684 or #2705
Closed

Export-M365DSCConfiguration fails with "...parameter name 'Error' is ambigious" #2682

elygre opened this issue Dec 17, 2022 · 1 comment · Fixed by #2684 or #2705
Labels
Bug Something isn't working Core Engine

Comments

@elygre
Copy link

elygre commented Dec 17, 2022

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

Running an initial export. Using powershell 7.1.7, installed modules in elevated command prompt. Runs as shown below, ending with the error "Parameter cannot be processed because the parameter name 'Error' is ambiguous. Possible matches include: -ErrorAction -ErrorVariable".

> Export-M365DSCConfiguration ApplicationId $ApplicationId -ApplicationSecret $ApplicationSecret -TenantId $TenantId
Exporting Microsoft 365 configuration for Mode: Default

Authentication methods specified:
- Service Principal with Application Secret

[WARNING] Based on the provided Authentication parameters, the following resources cannot be extracted:
(...long list of resources deleted from issue entry...)
Parameter cannot be processed because the parameter name 'Error' is ambiguous. Possible matches include: -ErrorAction -ErrorVariable.

Verbose logs showing the problem

VERBOSE: Loading module from path 'C:\Users\eirik.lygre\Documents\PowerShell\Modules\Microsoft.Graph.Teams\1.9.2\Microsoft.Graph.Teams.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Users.
VERBOSE: Loading module from path 'C:\Users\eirik.lygre\Documents\PowerShell\Modules\Microsoft.Graph.Users\1.13.0\Microsoft.Graph.Users.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Users.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Users.Actions.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.Graph.Users.Actions.
VERBOSE: Loading module from path 'C:\Users\eirik.lygre\Documents\PowerShell\Modules\Microsoft.Graph.Users.Actions\1.9.2\Microsoft.Graph.Users.Actions.psm1'.
Parameter cannot be processed because the parameter name 'Error' is ambiguous. Possible matches include: -ErrorAction -ErrorVariable.
Partial Export file was saved at: C:\Users\EIRIK~1.LYG\AppData\Local\Temp\0d828988-fde2-4037-a44b-7dafa2c1ac0a.partial.ps1

(There is in fact no partial export file)

Suggested solution to the issue

Using ripgrep through the repository (the dev-version), I find only one instance of " -Error ":

PS C:\git\azure\Microsoft365DSC> git checkout 1.22.1214.1
HEAD is now at 4137458f Merge pull request #2668 from microsoft/Dev
PS C:\git\azure\Microsoft365DSC> rg -B8 -A3 -e " -Error " -e "-Error$" -t ps
Modules\Microsoft365DSC\Modules\M365DSCLogEngine.psm1
249-    catch
250-    {
251-        Write-Verbose -Message $_
252-
253-        $MessageText = "Could not write to event log Source {$Source} EntryType {$EntryType} Message {$Message}"
254-        # Check call stack to prevent indefinite loop between New-M365DSCLogEntry and this function
255-        if ((Get-PSCallStack)[1].FunctionName -ne 'New-M365DSCLogEntry')
256-        {
257:            New-M365DSCLogEntry -Error $_ -Message $MessageText `
258-                -Source '[M365DSCLogEngine]' `
259-                -TenantId $TenantId
260-        }

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

N/A

The operating system the target node is running

OsName               : Microsoft Windows 10 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage           : en-US
OsMuiLanguages       : {en-US, da-DK, de-DE, es-ES…}

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

1.22.1214.1

@andikrueger andikrueger added Bug Something isn't working Core Engine labels Dec 17, 2022
@andikrueger
Copy link
Collaborator

That one is a good catch. The function New-M365DSCLogEntry has a parameter $Exception and not $Error.

This one is an easy fix.

NikCharlebois added a commit to NikCharlebois/Microsoft365DSC that referenced this issue Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Core Engine
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants