OfficeDev / O365-InvestigationTooling

MIT License
574 stars 360 forks source link

Get-MailboxPermission : The term 'Get-MailboxPermission' 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. #37

Open JamesHeathcote opened 6 years ago

JamesHeathcote commented 6 years ago

DumpDelegatesandForwardingRules.ps1

Get-MailboxPermission : The term 'Get-MailboxPermission' 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 line:23 char:23

PsychoData commented 5 years ago

@JamesHeathcote
Can we get a more complete output? Most likely your Exchange PSSession just didn't work (bad login, MFA, or some other thing), and so it didn't import the module with the Commands

Might could also be Exchange Permissions being too low on your user. Try these lines again and see if it imports commands.

$ExoSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $userCredential -Authentication Basic -AllowRedirection
Import-PSSession $ExoSession

Once that is done, you should be able to see a Session and a Module output when you run below

Get-PSSession | where {($_.ComputerName -eq 'outlook.office365.com') -and ($_.ConfigurationName -eq 'Microsoft.Exchange'  )} 
Get-Module | where {$_.Description -like "*outlook.office365.com*" }  | tee-Object -Variable 'exoModule'

And then you should be able to get commands for mailboxes, which will probably be sourced from the module listed above. Get-Command -Name *mailbox* If you're not getting any Get-Mailbox* commands from that, see if it even pulled any commands with the module. It could be something like AV is blocking the script.

#After Running the Get-Module command listed a couple code blocks above
$exoModule.ExportedFunctions.Keys + $exoModule.ExportedCommands.Keys  | select -Unique