Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

powershell - Search-Mailbox cmdlet availability with app-only authentication in Exchange Online

I'm connecting to Exchange Online using PowerShell and the following command:

Connect-ExchangeOnline -AppId APP_ID -CertificateFilePath CERTIFICATE_PATH -Organization ORG_NAME

And would like to use the "Search-Mailbox" cmdlet.

The docs say:

By default, Search-Mailbox is available only in the Mailbox Search or Mailbox Import Export roles, and these roles aren't assigned to any role groups.

The app has the Exchange administrator role assigned in Azure.

In Exchange admin center, I added Exchange administrators to the Discovery Management role group that has the Mailbox Search role enabled.

After reconnecting, Search-Mailbox is still not available:

Search-Mailbox: The term 'Search-Mailbox' 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.

Could someone please explain why it doesn't work and how to make it work?

question from:https://stackoverflow.com/questions/65952476/search-mailbox-cmdlet-availability-with-app-only-authentication-in-exchange-onli

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When the CmdLet is not available it needs to be imported, installed or run on the correct server. It seems like Search-Mailbox is part of the module ExchangePowerShell.

I believe you either need to import the module in your PowerShell session:

Import-Module -Name 'ExchangePowerShell'

Or run the CmdLet on the Exchange server directly or use Connect-ExchangeOnline.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...