asterictnl-lvdw / M365SAT

Microsoft 365 Security Assessment Tool - A Easy-To-Use Microsoft 365 Security Assessment Tool
MIT License
35 stars 17 forks source link

The term 'Get-MgOrganization' is not recognized #29

Closed swagman69xd closed 7 months ago

swagman69xd commented 7 months ago

Hi today when I was trying to execute the .ps1 I was getting the followig exception.

Get-MgOrganization : The term 'Get-MgOrganization' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At C:\M365SAT-production\core\m365connectors\Connect-MicrosoftGraph.ps1:27 char:17
+         $OrgName = (((Get-MgOrganization).VerifiedDomains |  Where-Ob ...
+                       ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-MgOrganization:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Why is this happening? I am trying it with a demo account from a @controso domain.

Thank you,

BR,

Miro

asterictnl-lvdw commented 7 months ago

Hello Miro,

Thank you for your submission.

I have tried to reproduce this issue but for me it is working. I need some more information to see why this problem is occurring:

This you can use to install Microsoft-Graph

# For Microsoft Graph
Install-Module Microsoft.Graph -AllowClobber
# For Microsoft Graph Beta
Install-Module Microsoft.Graph.Beta -AllowClobber

Please let me know the output.

~LvdW

swagman69xd commented 7 months ago

Hi,

I was trying other tools and my current version of Microsoft.Graph is 2.12, its not the latest.

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.12.0     Microsoft.Graph.Authentication      {Connect-MgGraph, Disconnect-MgGraph, Get-MgContext, Invok...
Script     2.12.0     Microsoft.Graph.Beta.Groups         {Add-MgBetaGroupDriveListContentTypeCopy, Add-MgBetaGroupD...
Script     2.12.0     Microsoft.Graph.Beta.Identity.Di... {Add-MgBetaTenantRelationshipManagedTenantAlertUserInputLo...
Script     2.12.0     Microsoft.Graph.Beta.Identity.Go... {Add-MgBetaAccessReviewDecision, Add-MgBetaAccessReviewIns...
Script     2.12.0     Microsoft.Graph.Beta.Identity.Si... {Confirm-MgBetaInformationProtectionSignature, Confirm-MgB...
Script     2.12.0     Microsoft.Graph.Beta.Users          {Get-MgBetaUser, Get-MgBetaUserAppRoleAssignedResource, Ge...

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.12.0     Microsoft.Graph.Authentication      {Connect-MgGraph, Disconnect-MgGraph, Get-MgContext, Invok...
Script     2.13.1     Microsoft.Graph.Calendar            {Get-MgGroupCalendar, Get-MgGroupCalendarEvent, Get-MgGrou...
Script     2.13.1     Microsoft.Graph.Groups              {Add-MgGroupDriveListContentTypeCopy, Add-MgGroupDriveList...
Script     2.13.1     Microsoft.Graph.Mail                {Get-MgUserInferenceClassification, Get-MgUserInferenceCla...
Script     2.13.1     Microsoft.Graph.Teams               {Add-MgChatMember, Add-MgTeamChannelMember, Add-MgTeamMemb...
Script     2.13.1     Microsoft.Graph.Users               {Get-MgUser, Get-MgUserCount, Get-MgUserCreatedObject, Get..

I will try updating it.

Thank you,

Miro

asterictnl-lvdw commented 7 months ago

Do let me know. Sometimes Microsoft Graph is often very buggy when it comes to installing stuff. You have to install the non-beta version first and then install the beta version over it, else you stumble into issues. Do use the allow-clobber parameter to make sure beta things are installed correctly.

I hope this is helpful for you :)

~LvdW

swagman69xd commented 7 months ago

Hi again,

I have uninstalled all the Graph modules and installed them again on their latest version (2.13.1 currently) and it worked correctly. I have the report. Thank you for the help. Great tool.

BR,

Miro

asterictnl-lvdw commented 7 months ago

Thank you! I will close this issue then. :)

~LvdW