How to Connect to Office 365 Through Powershell
1- In Windows run PowerShell as an admin
2- Install PowerShell v2 if not installed:
Install-Module -Name ExchangeOnlineManagement
3- Import Exchange Online Management module:
Import-Module ExchangeOnlineManagement
For Windows 11 you might have to allow running scripts because running scripts is disabled by default, run this command to allow running scripts.
Set-ExecutionPolicy RemoteSigned
4- Connect to Office 365 with admin user:
Connect-ExchangeOnline -UserPrincipalName Admin@WhateverDomain.com
Replace admin@whateverdomain.com above with office 365 administrator account. You will be prompted for credentials and a code if multi-factor authentication is enabled.
5- After that if you want, for instance, to grant a user named User1 “Author” permissions on root of public folders
Get-PublicFolder -Identity “\” -Recurse | Add-PublicFolderClientPermission -User User1 -AccessRights Author
Replace User1 above with the user you want to grant access
6- To view permissions on the public folders called My Public Folder
Get-PublicFolderClientPermission “\My Public Folders”
——————
Remove Forwarding on one account:
Set-Mailbox <MailBox> -ForwardingAddress $Null
Set-Mailbox <MailBox> -ForwardingSmtpAddress $Null
Leave a Reply
Want to join the discussion?Feel free to contribute!