I'm developing a simple PowerShell script to retrieve office365 user mailbox folder IDs, my code fails at authentication stage displaying error 401 unauthorized
. Is there a step that is missing so as to connect to office 365 mailbox using the Invoke-RestMethod
cmdlet?
Below is the code
$cred = Get-Credential
Invoke-RestMethod -Uri "https://outlook.office.com/api/v1.0/me/MailFolders/" -Credential $cred | foreach-object{$_.value |select DisplayName,ID}