Connect to MS SharePoint Online Using PowerShell Commands

Aftab Alam
Aftab Alam | Published On - 13 Jun 2022 |

Read time 5 minutes

SharePoint administrators manage the whole SharePoint Online environment using SharePoint Admin Center in Microsoft 365 Admin center. It is the simple GUI-based place where most of the controlling take place. You can manage site collections, policies (sharing & access control), reports, migration, and other settings from here.SharePoint Admin Center

However, multiple tasks should be run routinely, and the administrator may find it monotonous. Whenever you see such repetitive tasks, you can use PowerShell and run the valuable cmdlets. These cmdlets will help you in running administrative tasks more easily.

In Windows, there is a PowerShell application by which you can connect with SharePoint Online and check out the site collections and other data.

Connect SharePoint Online with Windows PowerShell

Before using a cmdlet to run administrative tasks, you must connect your SharePoint Online account with SharePoint Online Management PowerShell. Connecting PowerShell with SharePoint Online will give the capability to take actions on sites and lists and run scripts.

SharePoint Online Management Shell

SharePoint Online Management PowerShell has the PowerShell module exceptionally crafted for SharePoint Online purposes. A PowerShell application is a command-line utility that interacts directly with the selected SharePoint account. The global administrator can get direct access without using the SharePoint Admin Center. Many tasks will be automated like the following-

  • Create Sites
  • Monitor sites
  • Monitor the site collections
  • Get the active site users
  • Enable site permissions
  • Check site groups
  • Upgrade selected site

Step 1. Download SharePoint Online Management PowerShell

First, download the utility from the given link- https://www.microsoft.com/en-us/download/details.aspx?id=35588

Download SharePoint Online Management

Step 2. Download and install the module on your PC. It will be added as a new application. Later, you can go to the application’s menu and start it as the administrator. It will open as the PowerShell window. Here, you must write the first command to connect your SharePoint Online with the module.

Connect-SPOService -Url https://<business-name>-admin.sharepoint.com -Credential usrname@businessname.onmicrosoft.com

connect SharePoint Online

Step 3. This wizard will appear where you require to input the password of the selected SharePoint account. Input the password and click OK.

Input password

Step 4. After a successful connection with SharePoint Online, you can continue to run more cmdlets to perform actions on your account.

run cmdlets

For example, if you want to check the number of sites in your accounts, you can write a cmdlet like ‘Get-SPOSite’ and click enter.

Get-SPOSite

The result will provide a comprehensive list of all the sites created under the Global administrator account.

Helpful commands to use in SharePoint Online Management Shell

As you get complete control over the SharePoint Online account, so you can perform multiple actions on it through various commands. We are listing some critical cmdlets here-

  • Set-SPOHomeSite: It will set the SharePoint Site as the Home Site.
  • Set-SPOTenant: It will set the properties on the SharePoint Online tenant.
  • Set-SPOUser: It will set various properties on an active user.
  • Test-SPOSite: It will evaluate the SharePoint Online site collection.
  • Upgrade-SPOSite: It will initialize an upgrade process for the SharePoint Online site collections.
  • Export-SPOUserProfile. It will export the selected user profile to a CSV file
  • Get-SPOAppErrors: If there is an error in the SharePoint Online account, it will show them.
  • Enable-SPOCommSite: The command creates a communication site experience on a previously existing classic team site.
  • New-SPOSiteGroup: It will create a new site group for the SharePoint Online account collection.
  • Remove-SPODeletedSite: The command will remove a SharePoint Site by deleting it from the recycle bin.
  • Add-SPOSiteDesign: It will create a new site design for the users when they create a new site.
  • Repair-SPOSite: It will check the sites and repair for minute issues.
  • Disconnect-SPOService: It will disconnect the SharePoint Online Service.

Conclusion

SharePoint Online Management Shell helps you run multiple commands and perform various tasks. You can not only manage the existing accounts and sites, but create more site collections, assign permissions, migrate site collections, and delete various parts. If you have not migrated to SharePoint Online till now, then use Kernel Migrator for SharePoint and migrate from on-premises SharePoint quickly. The SharePoint Migration software will help you perform the migration in less time and with more efficiency.