Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New command: Unused Mailboxes #5984

Open
murati opened this issue Apr 18, 2024 · 8 comments
Open

New command: Unused Mailboxes #5984

murati opened this issue Apr 18, 2024 · 8 comments

Comments

@murati
Copy link

murati commented Apr 18, 2024

Usage

m365 outlook mail unused

Description

It retrieves the list of mailboxes which have no activity starting the given period

Options

Option Description
--period D7, D30, D90, D180
--since Starting date

Examples

Retrieve the list of inactive mailboxes in last 30 days

m365 outlook mail unused

Retrieve the list of active mailboxes starting the given date

m365 outlook mail unused --since 2024-01-01T00:00:000Z

Default properties

  • DisplayName
  • UserPrincipalName
  • LastActivityDate
  • IsArchived

Additional Info

No response

@waldekmastykarz
Copy link
Member

Thanks for the suggestion @murati! A couple of ideas:

  • what's the API that we could use to retrieve this information?
  • it seems like a report command, so I suggest that we rename it to m365 outlook report mailbox unused

@pnp/cli-for-microsoft-365-maintainers any other feedback before we open it up?

@waldekmastykarz waldekmastykarz added needs peer review Needs second pair of eyes to review the spec or PR feature request labels Apr 20, 2024
@milanholemans
Copy link
Contributor

I'm curious if there's an API for this. If there isn't, this should probably be converted to a sample script in my opinion.

@waldekmastykarz waldekmastykarz added needs research and removed needs peer review Needs second pair of eyes to review the spec or PR labels Apr 21, 2024
@murati
Copy link
Author

murati commented Apr 26, 2024

Per my research, it requires EXO V3. That was actually my question. Graph does not directly support EXO but when I read the source code, I saw some endpoints apart from graph usage. Therefore, I thought, you could reach EXO beyond my knowledge.

We are building a smart admin panel for M365 and the EXO requiring modules are the slowest ones. Please let me know, if I can contribute somehow and further.

@milanholemans
Copy link
Contributor

Can you provide some documentation about the API you want to leverage?

@murati
Copy link
Author

murati commented Apr 29, 2024

Can you provide some documentation about the API you want to leverage?

This is how I execute this command:

Get-EXOMailbox -InactiveMailboxOnly

And here is the link : https://learn.microsoft.com/en-us/powershell/module/exchange/get-exomailbox?view=exchange-ps

I wasn't able to find further API documentation about it.

@milanholemans
Copy link
Contributor

Let's see if we can get it to work.

@MathijsVerbeeck
Copy link
Contributor

So, I've done a little bit of research, and the endpoint being called by the cmdlet Get-EXOMailbox is the following one:
https://outlook.office365.com/adminapi/beta/{tenantid}/Mailbox?InactiveMailboxOnly=True

I have executed the cmdlet and also done some research regarding the permission scopes, however this one seems to use some permission scopes that I personally can't really place. The permission scopes being used are:

  • AdminApi.AccessAsUser.All
  • FfoPowerShell.AccessAsUser.All
  • RemotePowerShell.AccessAsUser.All
  • VivaFeatureAccessPolicy.Manage.All

Also, it uses the application Microsoft Exchange REST API Based Powershell, which I'm not really able to find within my tenant it seems, not even in the Enterprise Applications.

So, in theory, we should be able to replicate this call but it looks to be quite hard.

@murati
Copy link
Author

murati commented May 25, 2024

I wasnt aware of outlook adminapi. Would it be somehow possible to call https://admin.exchange.microsoft.com/beta/ ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants