soteria-security / 365Inspect

A PowerShell script that automates the security assessment of Microsoft 365 environments.
https://soteria.io/solutions/soteria-inspect/
MIT License
561 stars 105 forks source link

When excuting The term 'Select-MgProfile' is not recognized #70

Closed kennyb7322 closed 12 months ago

kennyb7322 commented 12 months ago

When executing 365inspect and the parameters using Powershell 7.3.5 not able to select MGProfiles as seen below from the output.

Verifying environment.

Environment is 7.3.5 [+] PowerShellGet is installed. Importing PowerShellGet Environment is 7.3.5 [+] ExchangeOnlineManagement is installed. Inporting ExchangeOnlineManagement Importing Microsoft.Graph Environment is 7.3.5 [+] Microsoft.Graph is installed. Inporting ExchangeOnlineManagement Importing Microsoft.Graph Environment is 7.3.5 [+] Microsoft.Online.SharePoint.PowerShell is installed. Importing Microsoft.Online.SharePoint.PowerShell Environment is 7.3.5 [+] MicrosoftTeams is installed. Importing MicrosoftTeams Connecting to Microsoft Graph Welcome To Microsoft Graph! Connecting to Microsoft Graph Failed. Write-Error: C:\365inspect\365Inspect.ps1:294 Line | 294 | Connect-Services | ~~~~ | The term 'Select-MgProfile' is not recognized as a name of a cmdlet, function, script file, or executable | program. Check the spelling of the name, or if a path was included, verify that the path is correct and try | again.**** PS C:\365inspect>

It has worked on earlier versions of the 365Inspect but not with the most updated one with some changes and modifications.

kennyb7322 commented 12 months ago

Here is what I executed using 7.3.5 version of powershell

image
ThoughtContagion commented 12 months ago

Hi there! Thank you for checking out our tool! Please verify that you are able to connect to, and approve permissions for, Microsoft Graph PowerShell. In your screenshot, your connection to Microsoft Graph failed (the line immediately before the error message about Select-MgProfile image

When properly connected, you should see a message that you are connected via Graph to your tenant before connecting to the next module. image

kennyb7322 commented 12 months ago

I agree on the connectivity to Graph when running it direct connect-graph & connect-mggraph It works without failure.

image
ThoughtContagion commented 12 months ago

Could you try running the tool again? In our testing, and the screenshot above, we ran it in PS version 7.3.5 and had no issues connecting.

kennyb7322 commented 12 months ago

Yes, I ran it several times and still received the same error. The service principal I am using is fully capable and has all the access. Not sure why it bombs out on the Microsoft Graph on the new version but the old version works fine.

ThoughtContagion commented 12 months ago

Hi @kennyb7322 The authentication methods used in this tool are designed for an authenticated user, and currently does not support using a Service Principal or Application authentication context.

kennyb7322 commented 12 months ago

I could get it to work by using an older version of PowerShell, the beta version; I was getting the same results. I don't know if some authentication caused it not to execute properly. I am going to try it on different instances and report back.

image
ThoughtContagion commented 12 months ago

What version of Microsoft.Graph PowerShell Module do you have installed? This works currently, using user credentials, with version 1.19.0 and lower.

ThoughtContagion commented 12 months ago

We can replicate this in version 2.0.0 of Microsoft Graph and are working on a resolution.

kennyb7322 commented 12 months ago

So it works on Powershell 1.9.6 Microsoft.Graph and lower you are correct it does not work in 2.0.0. and it does not work also on the release candidates.

kennyb7322 commented 12 months ago

So it works on my VM that I have running 1.9.6 that I configured with the older Graph versions, but when I try to push anything over 2.0.0 and RC, it does not work. My other question is it not necessarily an issue at all, but can I submit inspectors that would be helpful that I have created?

kennyb7322 commented 12 months ago

So it works on my VM but when I try to push it up to github I get an error. Any help will be greatly appreciated! Thanks.Manifest 1.9.6 Microsoft.Graph

ThoughtContagion commented 12 months ago

Version 2.0.0 no longer supports the Select-MgProfile command. In Microsoft's release notes for version 2.0.0 - https://github.com/microsoftgraph/msgraph-sdk-powershell/releases image

We are working on a resolution to accommodate this change, in the meantime, you will need version 1.19.0 or lower to run the tool.