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

Issue with get-mggroup and other cmdlets in PowerShell 7.4.0 #2460

Closed
Mirandur opened this issue Nov 23, 2023 · 6 comments
Closed

Issue with get-mggroup and other cmdlets in PowerShell 7.4.0 #2460

Mirandur opened this issue Nov 23, 2023 · 6 comments

Comments

@Mirandur
Copy link

Mirandur commented Nov 23, 2023

Describe the bug
When running get-mggroup in a PowerShell 7.4.0 environment, the following error is returned:

> get-mggroup

ParentContainsErrorRecordException: C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\ProxyCmdletDefinitions.ps1:41287
 Line |
41287 |          $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."

I get similar errors when executing Get-MgGraphMember and Get-MgGraphOwner. I have not tried any other cmdlets, but they may be affected.

Versions affected: 2.9.0, 2.9.1, 2.10.0. I have not tried earlier versions. In versions prior to 2.10.0, Get-MgUser is affected by the same error, but it works in 2.10.0.
The issue is not present with a PowerShell 7.3.10 environment or earlier.

As this issue reports, the same error exist when module is installed directly in PowerShell Core and not via Windows PowerShell as I have: PowerShell/PowerShell#20707

To Reproduce
Steps to reproduce the behavior:

  1. Open a PowerShell 7.4.0 environment.
  2. Connect using Connect-MgGraph
  3. Execute Get-MgGraph with a valid group ID
  4. See error.
  5. Execute Get-MgGraphMember with a valid group ID
  6. See error.
  7. Execute Get-MgGraphOwner with a valid group ID
  8. See error.

Expected behavior

> get-mggroup -GroupId "12345678-90ab-cdef-g123-4567890abcde" # GroupID replaced with mockup

DisplayName Id                                   MailNickname    Description GroupTypes
----------- --                                   ------------    ----------- ----------

Debug Output

Run the problematic command with -Debug and paste the resulting debug stream below.
⚠ ATTENTION: Be sure to remove any sensitive information that may be in the logs.

> get-mggroup -GroupId "12345678-90ab-cdef-g123-4567890abcde" -debug # GroupID replaced with mockup
ParentContainsErrorRecordException: C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\ProxyCmdletDefinitions.ps1:41287
 Line |
41287 |          $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."

> 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 pip
eline 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 : 41287
            OffsetInLine     : 9
            HistoryId        : 9
            ScriptName       : C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\ProxyCm
dletDefinitions.ps1
            Line             :         $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin
)

            Statement        : $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
            PositionMessage  : At C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\Prox
yCmdletDefinitions.ps1:41287 char:9
                               +         $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvoc …
                               +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            PSScriptRoot     : C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports
            PSCommandPath    : C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\ProxyCm
dletDefinitions.ps1
            CommandOrigin    : Internal
        ScriptStackTrace      : at Get-MgGroup<Begin>, C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Group
s\2.10.0\exports\ProxyCmdletDefinitions.ps1: line 41287
                                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 : 41286
                OffsetInLine     : 25
                HistoryId        : -1
                ScriptName       : C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\Pro
xyCmdletDefinitions.ps1
                Line             :         $scriptCmd = {& $wrappedCmd @PSBoundParameters}

                Statement        : $wrappedCmd
                PositionMessage  : At C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\
ProxyCmdletDefinitions.ps1:41286 char:25
                                   +         $scriptCmd = {& $wrappedCmd @PSBoundParameters}
                                   +                         ~~~~~~~~~~~
                PSScriptRoot     : C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports
                PSCommandPath    : C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\Pro
xyCmdletDefinitions.ps1
                CommandOrigin    : Internal
            ScriptStackTrace      : at Get-MgGroup<Begin>, C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.G
roups\2.10.0\exports\ProxyCmdletDefinitions.ps1: line 41287
                                    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 res
ult 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[] commandEle
ments, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
   at System.Management.Automation.PipelineOps.GetSteppablePipeline(PipelineAst pipelineAst, CommandOrigin commandOrigi
n, 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, ExecutionOp
tions options)
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : RuntimeException
InvocationInfo        :
    ScriptLineNumber : 41287
    OffsetInLine     : 9
    HistoryId        : 9
    ScriptName       : C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\ProxyCmdletDefi
nitions.ps1
    Line             :         $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)

    Statement        : $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin)
    PositionMessage  : At C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\ProxyCmdletD
efinitions.ps1:41287 char:9
                       +         $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvoc …
                       +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports
    PSCommandPath    : C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0\exports\ProxyCmdletDefi
nitions.ps1
    CommandOrigin    : Internal
ScriptStackTrace      : at Get-MgGroup<Begin>, C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.10.0
\exports\ProxyCmdletDefinitions.ps1: line 41287
                        at <ScriptBlock>, <No file>: line 1

Module Version

Please run Get-Module Microsoft.Graph* after cmdlet execution and paste the output below.
If a module cannot be installed or imported, please run Get-Module -ListAvailable and paste the output.

> get-module Microsoft.Graph*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.10.0                Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-M…
Script     2.10.0                Microsoft.Graph.Groups              {Add-MgGroupDriveListContentTypeCopy, Add-MgGroup…
Script     2.10.0                Microsoft.Graph.Users               {Get-MgUser, Get-MgUserCount, Get-MgUserCreatedOb…

Environment Data

Please run $PSVersionTable and paste the output below. If running the Docker container image, indicate the tag of the image used and the version of Docker engine.

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Screenshots

If applicable, add screenshots to help explain your problem.
image

Edit: A screenshot that shows Get-MgGroup being used in PowerShell 7.4.0 and 7.3.10 environments, with clarification that both environments use the same modules:
image

Additional context

Add any other context about the problem here.

@Mirandur Mirandur changed the title Issue with get-mggroup in PowerShell 7.4.0 Issue with cmdlets in PowerShell 7.4.0 Nov 23, 2023
@Mirandur Mirandur changed the title Issue with cmdlets in PowerShell 7.4.0 Issue with get-mggroup and other cmdlets in PowerShell 7.4.0 Nov 23, 2023
@ma-kal
Copy link

ma-kal commented Nov 24, 2023

Got the same exact problem
7 4 0 get-mggroup

mod-version

The funny part is when I run it in VS Code also with 7.4.0. There seems to be no problem?
vscode

@timayabi2020
Copy link
Contributor

@Mirandur I wasn't able to reproduce the issue because I was able to execute the cmdlet without any errors.
image

I'm suspecting that it could be an issue with module conflicts. Maybe you try uninstall the previous versions and manually delete those modules from the installation location.

@ma-kal
Copy link

ma-kal commented Nov 28, 2023

@Mirandur I wasn't able to reproduce the issue because I was able to execute the cmdlet without any errors. image

I'm suspecting that it could be an issue with module conflicts. Maybe you try uninstall the previous versions and manually delete those modules from the installation location.

Good point. Remove all the modules. I had version 1.2.7 and 2.10.0
uninstall-Module $module.Name -Force -AllVersions

But no luck even with just one version the problem still occurs.
2023-11-28-Issue with get-mggroup and other cmdlets in PowerShell 7 4 0 · Issue #2460 · mic
2023-11-28-Learn the Many Ways in PowerShell to Get The Windows Version en nog 2 andere pag

@Mirandur
Copy link
Author

Apologies, I forgot to include in the original post that I had already tried to remove previous versions of the module.

I had the same thought, that it could be a module version mismatch, and made sure I had all versions removed before reinstalling version 2.10.0. I also tried reinstalling PowerShell 7.4.0 from Microsoft Store, though I have not tried the MSI.

I can also note that I have the problem in VSCode as well.

Also, when I first noticed the problem, I had only PowerShell 7.4.0 from Microsoft Store installed, in addition to Windows PowerShell 5, I installed PowerShell Core 7.3.10 from MSI after, to test.

OSversion

@timayabi2020
Copy link
Contributor

@Mirandur just found out that it's a bug with an experimental feature (WDAC) in PowerShell 7.4.0. I think the work around is to roll back to version 7.3.9 or just use PowerShell 5.

This is the related issue PowerShell/PowerShell#20785 which has been classified as a bug.

@Mirandur
Copy link
Author

@Mirandur just found out that it's a bug with an experimental feature (WDAC) in PowerShell 7.4.0. I think the work around is to roll back to version 7.3.9 or just use PowerShell 5.

This is the related issue PowerShell/PowerShell#20785 which has been classified as a bug.

In that case, I guess this thread can be closed either now, or when that bug has been fixed? -I'm afraid I'm unfamiliar with due process, here...?

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

3 participants