Reputation: 1
I am a total newbie on powershell with no guidance from someone more senior. I want to delete all meetings from a list of e-mail addresses. We are an educational organisation and want to remove all old cancelled meetings before scheduling the meetings in Teams for the new semester.
I've been able to connect powershell to our Microsoft tenant using the Connect-MsolService command and I can get a list of users using Get-MsolUser.
I've googled and found that I can delete all meetings from a calendar using this command search-Mailbox -Identity [email protected] -SearchQuery "kind:meetings" -DeleteContent -confirm:$false -Force
But when I run it, I get search-Mailbox : The term 'search-Mailbox' 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:1 char:1
I am a Global Administrator on the tenant.
Any suggestions?
Upvotes: 0
Views: 9177
Reputation: 725
Search-Mailbox is only available to onprem system for cloud based system Microsoft want you to use
New-ComplianceSearch -Name "Remove older than 30 days messages" -ExchangeLocation email -ContentMatchQuery "(Received >= 05/20/2024)"
Upvotes: 0
Reputation: 26
Like js2010 mentioned, you need to connect to Exchange:
Connect-ExchangeOnline -UserPrincipalName <UPN> [-ExchangeEnvironmentName <Value>] [-ShowBanner:$false] [-DelegatedOrganization <String>] [-SkipLoadingFormatData]
But you also need to have the correct permissions since only cmdlets you are allowed to run will be loaded. https://learn.microsoft.com/en-us/powershell/module/exchange/search-mailbox?view=exchange-ps
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. To use this cmdlet, you need to add one or both of the roles to a role group (for example, the Organization Management role group). Only the Mailbox Import Export role gives you access to the DeleteContent parameter.
Your query, once you get the access to the cmdlet, will delete ALL meetings for the specified mailbox, you might want to consider adding some kind of timespan to the query as well.
Upvotes: 1