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-MGGroupOwner in 2.6 errors #2312

Closed
andersidahl opened this issue Sep 20, 2023 · 15 comments
Closed

Get-MGGroupOwner in 2.6 errors #2312

andersidahl opened this issue Sep 20, 2023 · 15 comments
Assignees
Labels

Comments

@andersidahl
Copy link

Describe the bug
Get-MGGroupOwner fails in version 2.6 with error:
Unable to find type [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet].
At C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Groups\2.6.0\exports\ProxyCmdletDefinitions.ps1:30673 cha
r:52

image

To Reproduce
Steps to reproduce the behavior:
Get-MGGroupOwner -GroupId xxxxxxx

@peterboba
Copy link

We're hitting the same issue - seems like the just released 2.6 version is broken

Describe the bug
Multiple cmdlets in version 2.6 of Microsoft.Graph fail with
Unable to find type [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]

To Reproduce
Steps to reproduce the behavior:
Execute:

Get-MgApplication -Filter "AppId eq 'hello'"

Fails with:

Unable to find type [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet].
At C:\Program
Files\WindowsPowerShell\Modules\Microsoft.Graph.Applications\2.6.0\exports\ProxyCmdletDefinitions.ps1:11961 char:52
+ ... ommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePS ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Windo...n.AzurePSCmdlet:TypeName) [], ParentContainsErrorRe
   cordException
    + FullyQualifiedErrorId : TypeNotFound

Expected behavior

Get-MgApplication -Filter "AppId eq 'hello'" 
Get-MgApplication_List1: Authentication needed, call Connect-MgGraph.

Debug Output

Get-MgApplication -Filter "AppId eq 'hello'" -Debug
Unable to find type [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet].
At C:\Program
Files\WindowsPowerShell\Modules\Microsoft.Graph.Applications\2.6.0\exports\ProxyCmdletDefinitions.ps1:11961 char:52
+ ... ommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePS ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Windo...n.AzurePSCmdlet:TypeName) [], ParentContainsErrorRe
   cordException
    + FullyQualifiedErrorId : TypeNotFound

Module Version

Get-Module Microsoft.Graph*

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.6.0      Microsoft.Graph.Applications        {Add-MgApplicationKey, Add-MgApplicationPassword, Add-MgSe...
Script     2.6.0      Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, G...

Environment Data

Name                           Value
----                           -----
PSVersion                      5.1.19041.3031
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.3031
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

@eagle00789
Copy link

It is many Get-MG commands that have this issue and isn't limited to the ones mentioned here already

@MTI-gh
Copy link

MTI-gh commented Sep 20, 2023

Can confirm, seeing the issues appear with Get-Mg commands. (example: Get-MgGroup)

@rsta7540
Copy link

rsta7540 commented Sep 20, 2023

I am also seeing the same issue running Get-Mg cmdlets in version 2.6.0.

For instance, when running:

Get-MgGroup -All:$true;
InvalidOperation: C:\Users\..\Documents\PowerShell\Modules\Microsoft.Graph.Groups\2.6.0\exports\ProxyCmdletDefinitions.ps1:43080
Line |
43080 | … ommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePS …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Unable to find type [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet].

@bonm014
Copy link

bonm014 commented Sep 20, 2023

Same here when I want to get all users.
But reverting back to 2.5 give me the same error

@peterboba
Copy link

Same here when I want to get all users. But reverting back to 2.5 give me the same error

2.5.0 works fine for me. So it's likely that it's still loading the assemblies from 2.6.0 and that causes the error or you haven't reverted completely.

@DarrenGowing
Copy link

I was getting "Unable to find type [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]." using any MG-Graph command. I found this this module is broken:

C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Files\2.6.0\exports\ProxyCmdletDefinitions.ps1

To fix it I removed this section starting from line 89490

    if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Graph.PowerShell.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){
        [Microsoft.Graph.PowerShell.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
        [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name)
    }

@DarrenGowing
Copy link

DarrenGowing commented Sep 20, 2023

Hmm, running another Graph command i got:

Unable to find type [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet].
At C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Files\2.6.0\exports\ProxyCmdletDefinitions.ps1:545000
char:52

So again I removed from line 545000 this section and now that command works:

    if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Graph.PowerShell.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){
        [Microsoft.Graph.PowerShell.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
        [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name)
    }

It looks like the same command is used for every Mg-Graph command so a quick find and replace all commands now work.

I think someone needs to fix this module / script "C:\Program Files\WindowsPowerShell\Modules\Microsoft.Graph.Files\2.6.0\exports\ProxyCmdletDefinitions.ps1"

@UnixC0rn
Copy link

Got the same issue for Get-MGUser, New-MgUser, Get-MgSubscribedSku, Set-MgUserLicense, ...
Deleting the Lines mentioned by @DarrenGowing in the corresponding File fixed the issue.

@fasteiner
Copy link

Can confirm: we got a similar issue when using "Get-MGGroup":
image

@8ctavious
Copy link

Can confirm the same issue with 2.6.0 since updating. I have had to pull the ability to update Microsoft.Graph from scripts for now.
Also working on a way to roll back if 2.6 is installed anywhere. It's annoying that I discovered this when it started breaking stuff.

Surprised that no one from Microsoft is assigned this bug yet to look at.

@AdamPhils
Copy link

If anyone still have problem even after uninstalling 2.6.0 version like I had, I found out that module files still exist for some reason and I created small script to get rid of them one by one (this helped me, maybe someone else will find it useful). It is taking a lot of time though.

$allgraphmodules = (Get-InstalledModule -Name "Microsoft.Graph.*").Name
foreach ($module in $allgraphmodules) {
Uninstall-Module -Name "$module" -RequiredVersion "2.6.0" -Force
}

@ddyett ddyett assigned ddyett and timayabi2020 and unassigned ddyett Sep 20, 2023
@ddyett
Copy link
Contributor

ddyett commented Sep 20, 2023

a dependency was introduced here inside of autorest that is for Azure SDK but we don't have. We are going to roll versions of autorest back and push out a 2.6.1 version. It will take a few hours to complete.

@peterboba
Copy link

peterboba commented Sep 21, 2023

Can confirm that 2.6.1 is not affected by this and since 2.6.0 has been removed from Powershell gallery I guess this can be closed.

Thank you for the quick fix.

@timayabi2020
Copy link
Contributor

@peterboba thank you for the feedback.

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

No branches or pull requests