{"id":67,"date":"2026-06-19T10:57:34","date_gmt":"2026-06-19T10:57:34","guid":{"rendered":"https:\/\/psttooffice365.com\/blogs\/?p=67"},"modified":"2026-06-19T11:04:08","modified_gmt":"2026-06-19T11:04:08","slug":"the-most-useful-powershell-commands-for-office-365-exchange-online","status":"publish","type":"post","link":"https:\/\/psttooffice365.com\/blogs\/the-most-useful-powershell-commands-for-office-365-exchange-online\/","title":{"rendered":"The Most Useful PowerShell Commands for Office 365 Exchange Online"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"67\" class=\"elementor elementor-67\">\n\t\t\t\t<div class=\"elementor-element elementor-element-5cb22dd e-con e-atomic-element e-flexbox-base e-93cfd2c \" data-id=\"5cb22dd\" data-element_type=\"e-flexbox\" data-e-type=\"e-flexbox\" data-interaction-id=\"5cb22dd\">\n    \t\t<div class=\"elementor-element elementor-element-2106b77 elementor-widget elementor-widget-text-editor\" data-id=\"2106b77\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>Before connecting the Office 365 to the Windows PowerShell we need to give and install following required permissions:<span id=\"more-27\"><\/span><\/p><ol><li>First, we need to provide a Global Admin Role to that O365 account.<\/li><li>Microsoft.Net Framework 4.5 and Windows Management Framework 4.0 or any latest version should be installed.<\/li><li>Now download and install PowerShell modules of office 365 and its services like Skype for business.<\/li><\/ol><ul><li>Microsoft Online Services Sign-In Assistant for IT Professionals RTW<\/li><li>Skype for Business Online, Windows PowerShell Module<\/li><li>Windows Azure Active Directory Tool<\/li><\/ul><h2><strong>Connect Office 365 with the PowerShell Commands<\/strong><\/h2><p>For connecting the o365 Cloud Platform to the Windows PowerShell follow all the steps.<\/p><p><strong>Step 1:<\/strong> First open the installed Azure Active Directory and import the online services of Active Directory &amp; Office 365 for PowerShell Modules.<\/p><p><code>Install-Module \u2013Name AzureAD<\/code><\/p><p><code>Install-Module \u2013Name MSOnline<\/code><\/p><p><strong>Step 2:<\/strong> Now open the Windows PowerShell and log in the Exchange Online administrator account in Windows PowerShell.<\/p><p><code>$Credential = Get-Credential<\/code><\/p><p>Step 3: After that create the Remote session<\/p><p><code>$O365 = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https:\/\/outlook.office365.com\/powershell-liveid\/ -Credential $Cred -Authentication Basic -AllowRedirection<\/code><\/p><p><strong>Step 4:<\/strong> Import the Session<\/p><p><code>Import-PSSession $O365<\/code><\/p><p><strong>Step 5:<\/strong> Connect the Office 365 services with PowerShell<\/p><p><code>Connect-MsolService \u2013Credential $O365<\/code><\/p><p>Now we are ready to navigate or manage our Exchange Online Account by the PowerShell Commands.<\/p><h2><strong>Connect the SharePoint with the PowerShell Command<\/strong><\/h2><p><strong>Step 1:<\/strong> We can also connect the SharePoint and Exchange Online by putting the following commands<\/p><p><code>$Cred = Get-Credential<\/code><\/p><p><code>$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https:\/\/outlook.office365.com\/powershell-liveid\/ -Credential $Cred -Authentication Basic \u2013AllowRedirection<\/code><\/p><p><strong>Step 2: <\/strong>After that, you need to install the SharePoint Online Management Shell and then run the given commands.<\/p><p><code>$admin=\"Admin@enterprise.onmicrosoft.com\"<\/code><\/p><p><code>$orgname=\"enterprise\"<\/code><\/p><p><code>$userCred = Get-Credential -UserName $admin -Message \"Type the password.\"<\/code><\/p><p><code>Connect-SPOService -Url https:\/\/$orgname-admin.sharepoint.com -Credential $userCred<\/code><\/p><h3><strong>Get the cmdlets of available Exchange Online PowerShell Commands.<\/strong><\/h3><p>For knowing the list of available o365 PowerShell by putting:<\/p><p><code>Get-Command -module MSOnline<\/code><\/p><p>Here you can also check the Azure Active Directory command list by typing the following command.<\/p><p><code>Get-Command -module AzureAD<\/code><\/p><h2><strong>Know the list of all office 365 Users with the Windows PowerShell<\/strong><\/h2><p>If you want to know the lists of all Office 365 Users Mailbox then use the Get-MsolUser command. For showing the DisplayName, City, Department, and ObjectID Parameters type the below command.<\/p><p><code>Get-MsolUser | Select DisplayName, City, Department, ObjectID<\/code><\/p><p>To know the number of licenses:<\/p><p><code>Get-MsolAccountSku<\/code><\/p><p>For the available services type:<\/p><p><code>Get-MsolAccountSku | select -ExpandProperty ServiceStatus<\/code><\/p><h3><strong>Create a New Exchange Online User Using PowerShell<\/strong><\/h3><p>You can create a New User of the Office 365 Exchange Online with the PowerShell by putting the following command.<\/p><p><code>New-MsolUser -UserPrincipalName pankaj@daddymails.onmicrosoft.com -DisplayName \"Pankaj Kumar\" -FirstName \u201cPankaj\u201d -LastName \u201cKumar\u201d<\/code><\/p><h3><strong>Remove the user of Office 365 list by PowerShell<\/strong><\/h3><p>Here you can also remove or delete an Office 365 User from a list.<\/p><p><code>Get-SPOSite | ForEach {Remove-SPOUser -Site $_.Url -LoginName \u201cpankaj@daddymails.onmicrosoft.com\"}<\/code><\/p><h3><strong>Change o365 Password using PowerShell<\/strong><\/h3><p>If you want to change the Password of Exchange Online by PowerShell Command then type the following command.<\/p><p><code>Set-MsolUserPassword -UserPrincipalName pankaj@daddymails.onmicrosoft.com -NewPassword P@SSw0rd!<\/code><\/p><h2>Conclusion:<\/h2><p>In this article, I explain the most useful Office 365 Exchange Online PowerShell. So follow all the step by step solution for connecting o365 with PowerShell. If you still have any doubt just leave a message on the comment box.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\n<\/div>\n\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Before connecting the Office 365 to the Windows PowerShell we need to give and install following required permissions: First, we need to provide a Global Admin Role to that O365 account. Microsoft.Net Framework 4.5 and Windows Management Framework 4.0 or any latest version should be installed. Now download and install PowerShell modules of office 365 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-blog"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/psttooffice365.com\/blogs\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/psttooffice365.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/psttooffice365.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/psttooffice365.com\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/psttooffice365.com\/blogs\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":4,"href":"https:\/\/psttooffice365.com\/blogs\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":71,"href":"https:\/\/psttooffice365.com\/blogs\/wp-json\/wp\/v2\/posts\/67\/revisions\/71"}],"wp:attachment":[{"href":"https:\/\/psttooffice365.com\/blogs\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/psttooffice365.com\/blogs\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/psttooffice365.com\/blogs\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}