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

Get-MgAgreement - Exception Error when querying the agreements #2498

Closed
alphasteff opened this issue Dec 20, 2023 · 3 comments
Closed

Get-MgAgreement - Exception Error when querying the agreements #2498

alphasteff opened this issue Dec 20, 2023 · 3 comments

Comments

@alphasteff
Copy link

Describe the bug
When I try to read out the user agreements, an error appears.

To Reproduce
Steps to reproduce the behavior:

  1. Install Microsoft.Graph.Identity.Governance (2.10.0 or 2.11.1)
  2. Login: Connect-MgGraph -Scopes "Policy.Read.All", "Policy.ReadWrite.ConditionalAccess" -ErrorAction Stop
  3. Execute from: Get-MgAgreement`

Expected behavior
List of existing agreements, including id's.

Debug Output
Default Output

ParentContainsErrorRecordException: C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1:2825
Line |
2825 |          $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvoc …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "GetSteppablePipeline" with "1" argument(s): "The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object."

Output of Get-Error

Exception             :
    Type                        : System.Management.Automation.MethodInvocationException
    ErrorRecord                 :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Exception calling "GetSteppablePipeline" with "1" argument(s): "The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object."
            HResult : -2146233087
        CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : RuntimeException
        InvocationInfo        :
            ScriptLineNumber : 2825
            OffsetInLine     : 9
            HistoryId        : 32
            ScriptName       : C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1
            Line             :         $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)

            Statement        : $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
            PositionMessage  : At C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1:2825 char:9
                               +         $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvoc …
                               +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            PSScriptRoot     : C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports
            PSCommandPath    : C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1
            CommandOrigin    : Internal
        ScriptStackTrace      : at Get-MgAgreement<Begin>, C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1: line 2825
                                at <ScriptBlock>, <No file>: line 1
    WasThrownFromThrowStatement : True
    TargetSite                  :
        Name          : Invoke
        DeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation, Version=7.4.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message                     : Exception calling "GetSteppablePipeline" with "1" argument(s): "The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object."
    Data                        : System.Collections.ListDictionaryInternal
    InnerException              :
        Type        : System.Management.Automation.RuntimeException
        ErrorRecord :
            Exception             :
                Type    : System.Management.Automation.ParentContainsErrorRecordException
                Message : The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
                HResult : -2146233087
            CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException
            FullyQualifiedErrorId : BadExpression
            InvocationInfo        :
                ScriptLineNumber : 2824
                OffsetInLine     : 25
                HistoryId        : -1
                ScriptName       : C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1
                Line             :         $scriptCmd = {& $wrappedCmd @PSBoundParameters}

                Statement        : $wrappedCmd
                PositionMessage  : At C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1:2824 char:25
                                   +         $scriptCmd = {& $wrappedCmd @PSBoundParameters}
                                   +                         ~~~~~~~~~~~
                PSScriptRoot     : C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports
                PSCommandPath    : C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1
                CommandOrigin    : Internal
            ScriptStackTrace      : at Get-MgAgreement<Begin>, C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1: line 2825
                                    at <ScriptBlock>, <No file>: line 1
        TargetSite  :
            Name          : AddCommand
            DeclaringType : System.Management.Automation.PipelineOps, System.Management.Automation, Version=7.4.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
            MemberType    : Method
            Module        : System.Management.Automation.dll
        Message     : The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
        Source      : System.Management.Automation
        HResult     : -2146233087
        StackTrace  :
   at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
   at System.Management.Automation.PipelineOps.GetSteppablePipeline(PipelineAst pipelineAst, CommandOrigin commandOrigin, ScriptBlock scriptBlock, Object[] args)
   at CallSite.Target(Closure, CallSite, Object, Object)
    Source                      : System.Management.Automation
    HResult                     : -2146233087
    StackTrace                  :
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options)
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : RuntimeException
InvocationInfo        :
    ScriptLineNumber : 2825
    OffsetInLine     : 9
    HistoryId        : 32
    ScriptName       : C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1
    Line             :         $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)

    Statement        : $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
    PositionMessage  : At C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1:2825 char:9
                       +         $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvoc …
                       +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports
    PSCommandPath    : C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1
    CommandOrigin    : Internal
ScriptStackTrace      : at Get-MgAgreement<Begin>, C:\Users\xxxxxx\OneDrive - xxxx\Dokumente\PowerShell\Modules\Microsoft.Graph.Identity.Governance\2.11.1\exports\ProxyCmdletDefinitions.ps1: line 2825
                        at <ScriptBlock>, <No file>: line 1

Module Version

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.11.1                Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext…}
Script     2.11.1                Microsoft.Graph.Identity.Governance {Add-MgIdentityGovernanceAccessReviewDefinitionInstanceDecision, Get-MgAgreement, Get-MgAgreementAcceptance, Get-MgAgreementAcceptanceCount…}

Environment Data

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@alphasteff
Copy link
Author

I have tested further, and I get no error message with version PowerShell 5.1.x and the same module version.

@timayabi2020
Copy link
Contributor

Hi @alphasteff,
I was able to successfully run the command but only added the "Agreement.ReadWrite.All" scope.
image

@alphasteff
Copy link
Author

Just a small update. After some time, I checked everything again and also installed the latest modules. I can no longer reproduce the problem.

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

No branches or pull requests

2 participants