---
title: "Getting Started with PowerShell SharePoint Management"
description: "Learn how to use PowerShell SharePoint tools to manage, provision, and update effectively in this ATA Learning tutorial!"
canonical: "https://adamtheautomator.com/powershell-sharepoint/"
---

# Getting Started with PowerShell SharePoint Management

> Learn how to use PowerShell SharePoint tools to manage, provision, and update effectively in this ATA Learning tutorial!

Source: https://adamtheautomator.com/powershell-sharepoint/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Getting Started with PowerShell SharePoint Management](https://adamtheautomator.com/wp-content/uploads/2022/07/Getting-Started-with-PowerShell-SharePoint-Management.jpg)

# Getting Started with PowerShell SharePoint Management

[![](https://secure.gravatar.com/avatar/a9763f0a5c1994a735baeae367d782fbe411c2b8d98d38e0a0eaee13e4b597b2?s=192&d=mm&r=g)Ayomikun Sholademi](https://adamtheautomator.com/author/elijah-sholademi/)18 July 20227 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[PowerShell](/tag/powershell/)[SharePoint](/tag/sharepoint/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Installing the PowerShell SharePoint Online Module](#installing-the-powershell-sharepoint-online-module)
*   [Connecting to PowerShell SharePoint Online](#connecting-to-powershell-sharepoint-online)
*   [Administrator Account without MFA](#administrator-account-without-mfa)
*   [Administrator Account with MFA](#administrator-account-with-mfa)
*   [Managing Sites, Users, and Groups using the PowerShell SharePoint Module](#managing-sites-users-and-groups-using-the-powershell-sharepoint-module)
*   [Creating a New SharePoint Site](#creating-a-new-sharepoint-site)
*   [Creating Site Groups and Adding Users](#creating-site-groups-and-adding-users)
*   [Generating a Site Users List](#generating-a-site-users-list)
*   [Remove Users from Site Groups](#remove-users-from-site-groups)
*   [Using the PowerShell SharePoint Online for Automation](#using-the-powershell-sharepoint-online-for-automation)
*   [Conclusion](#conclusion)

Does the SharePoint admin center bore you, find it lacking, and want to switch to the command line? Yes, it is possible with the [PowerShell SharePoint Online Management](https://www.powershellgallery.com/packages/Microsoft.Online.SharePoint.PowerShell) module.

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

This module allows you to accomplish the same tasks that you typically do in the SharePoint admin center in PowerShell. What’s more, you can automate your SharePoint Online tasks!

This tutorial teaches the PowerShell SharePoint Online Management basics. You’ll learn to install the module, perform common administrative tasks, and automate repetitive actions. Don’t go anywhere and dive right in!

## Prerequisites

This tutorial will be a hands-on demonstration. If you’d like to follow along, be sure you have the following:

*   You must have a [SharePoint Administrator](https://docs.microsoft.com/en-us/sharepoint/sharepoint-admin-role) role or higher in a Microsoft 365 tenant.
    
*   You must know your SharePoint Online admin URL and portal URL. Refer to [this link](https://www.sharepointdiary.com/2019/06/sharepoint-online-get-admin-center-site-url.html) to know how to get the SharePoint Online admin URL in your tenant.
    

This tutorial will be using the portal URL _HTTPS://lzex.sharepoint.com_ and the admin URL _HTTPS://lzex-admin.sharepoint.com._

*   Windows PowerShell 5.1 or the latest [PowerShell 7](https://docs.microsoft.com/en-us/shows/it-ops-talk/how-to-install-powershell-7) on Windows. This tutorial uses Windows PowerShell 5.1 on Windows 10.

## Installing the PowerShell SharePoint Online Module

To manage SharePoint Online with PowerShell, you must first install the [PowerShell SharePoint Online Management](https://www.powershellgallery.com/packages/Microsoft.Online.SharePoint.PowerShell) module. This module provides the cmdlets that allow you to connect and manage your SharePoint online organization and resources.

The quickest and most convenient way to install the PowerShell SharePoint Online module is from the PowerShell gallery using the Install-Module cmdlet. To do so, follow the below steps.

1\. Open PowerShell as an administrator.

Related:[Discover How to Run PowerShell as Administrator](https://adamtheautomator.com/powershell-run-as-administrator/)

2\. Run the command below next. This command installs Microsoft.Online.SharePoint.PowerShell module.

```powershell
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
```

3\. To confirm that the module installation is successful, run the below command to get the module information.

```powershell
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select-Object Name,Version
```

The command returns the module’s name and version. As you can see below, there’s one version of Microsoft.Online.SharePoint.PowerShell module on this computer. The latest version as of this writing is _16.0.22615.12000_.

![Listing the PowerShell SharePoint Online module information](https://adamtheautomator.com/wp-content/uploads/2022/07/image-133.png)

Listing the PowerShell SharePoint Online module information

4\. Lastly, import the PowerShell SharePoint module by running the below command in PowerShell.

> _Note: While the PowerShell SharePoint Online module works with PowerShell 7, you must explicitly import the module with the -UseWindowsPowerShell switch._

```powershell
# On Windows PowerShell 5.1
Import-Module Microsoft.Online.SharePoint.PowerShell

# On PowerShell 7x
Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell
```

> _Ignore the warning about unapproved verbs. This warning warns you about cmdlets that do not start with approved verbs in the Get-Verb list but do not affect the module’s functionality._
> 
> _To avoid this warning, append the -DisableNameChecking switch to the Import-Module cmdlet._

![Importing the PowerShell SharePoint Online module](https://adamtheautomator.com/wp-content/uploads/2022/07/image-134.png)

Importing the PowerShell SharePoint Online module

## Connecting to PowerShell SharePoint Online

You’re now ready to connect to the PowerShell SharePoint Online session. But before you do, understand that the syntax and method would vary depending your your admin account’s multifactor authentication status.

### Administrator Account without MFA

If your admin account is not MFA-enabled, run the below command `Connect-SPOService`. Specify your admin URL after the `-Url` parameter and your _user principal name (UPN)_ after the `-Credential` parameter.

```powershell
Connect-SPOService -Url <https://tenant-admin.sharepoint.com/> -Credential spoadmin@domain.com
```

Type your password on the next prompt and press Enter.

![Connect SPOService](https://adamtheautomator.com/wp-content/uploads/2022/07/image-135.png)

Connect SPOService

![Connecting to PowerShell SharePoint online without MFA](https://adamtheautomator.com/wp-content/uploads/2022/07/image-136.png)

Connecting to PowerShell SharePoint online without MFA

> _The -Credential parameter also accepts a PSCredential object, which you can create with the Get-Credential cmdlet._

Related:[Using the PowerShell Get-Credential Cmdlet and all things credentials](https://adamtheautomator.com/powershell-get-credential/)

### Administrator Account with MFA

For an MFA admin account, follow the steps below to connect to the PowerShell SharePoint Online session.

1\. Run the below command in PowerShell. Ensure to specify the correct SharePoint admin URL.

```powershell
Connect-SPOService -Url https://tenant-admin.sharepoint.com/
```

2\. On the Sign in window that pops up, type your admin username and click Next.

![Type the SharePoint admin username](https://adamtheautomator.com/wp-content/uploads/2022/07/image-137.png)

Type the SharePoint admin username

3\. Next, type the password for the admin account and click Sign in.

![Enter the account password](https://adamtheautomator.com/wp-content/uploads/2022/07/image-138.png)

Enter the account password

4\. Finally, complete your MFA challenge. Depending on how you configured MFA for your account, the MFA method may differ from the screenshot below.

![Completing the MFA challenge](https://adamtheautomator.com/wp-content/uploads/2022/07/image-139.png)

Completing the MFA challenge

Once you’ve completed these steps, your PowerShell SharePoint online connection should now be active.

## Managing Sites, Users, and Groups using the PowerShell SharePoint Module

Through PowerShell, you can perform some functionalities that SharePoint provides to SharePoint Online and various resources. In this section, you will be performing the typical SharePoint Online tasks, such as creating sites, creating groups, adding users, removing users from groups, and generating user reports.

### Creating a New SharePoint Site

Leveraging the New-SPOSite command, you can create a new SharePoint Online site. Suppose you’re creating a new modern Team Site site called _My First Team Site_, execute the following steps.

1\. First, get the name of the Team Site template.

```powershell
Get-SPOWebTemplate
```

Look for the template you wish to apply to the new site. In this example, copy the Name value of the Team site (no Microsoft 365 group) template, STS#3.

![Listing all available SharePoint web templates](https://adamtheautomator.com/wp-content/uploads/2022/07/image-140.png)

Listing all available SharePoint web templates

2\. Now, run the below command to create the modern Team Site. Make sure that the following parameters are complete.

*   `Url - Specifies the new site’s URL. This URL structure follows this convention - _HTTPS://<tenant>.sharepoint.com/sites/<site-slug>._`

> _Ensure the URL is unique. The site creation will fail if a site exists with the same URL, even if the site is in the recycle bin._

*   `Title` – Sets the title for your new site.
    
*   `Owner - Assigns the site owner’s user principal name.`
    

> _Note: SPO automatically sets the Company Administrator group as the site owner if the owner you specify has an administrator role._

*   `Template` – Indicates the web template you’re applying to the new site.
    
*   `StorageQuota - Configures the site’s storage quota value in MB.`
    

> _Note: The StorageQuota value takes effect only if the_ [_Site Storage Limit_](https://docs.microsoft.com/en-us/sharepoint/manage-site-collection-storage-limits) _in your SharePoint Online organization is set to Manual. If the setting is Automatic, the tenant’s total storage quota takes precedence._

```powershell
New-SPOSite `
    -Url 'https://lzex.sharepoint.com/sites/MyFirstTeamSite' `
    -Title 'My First Team Site' `
    -Owner 'spoadmin@lzex.ga' `
    -Template 'STS#3' `
    -StorageQuota 1000
```

If the site creation is successful, you will get no response or message in PowerShell.

3\. Confirm that the new site exists by running the Get-SPOSite cmdlet.

```powershell
Get-SPOSite -Identity 'https://lzex.sharepoint.com/sites/MyFirstTeamSite'
```

![Getting the new SPO site details](https://adamtheautomator.com/wp-content/uploads/2022/07/image-141.png)

Getting the new SPO site details

4\. Lastly, open the SharePoint site URL in your web browser to confirm the site works.

![Opening the new SPO site in the browser](https://adamtheautomator.com/wp-content/uploads/2022/07/image-142.png)

Opening the new SPO site in the browser

### Creating Site Groups and Adding Users

After creating a new SPO site, you can start creating groups and adding users with [specific permission levels](https://docs.microsoft.com/en-us/sharepoint/sites/user-permissions-and-permission-levels). In this section, you will be learning how to create groups and add users to such groups.

First, create the groups that follow the specifications in the table below.

> _To get a list of permission levels, visit the [User permissions and permission levels in SharePoint Server](https://docs.microsoft.com/en-us/sharepoint/sites/user-permissions-and-permission-levels) documentation._

<table><tbody><tr><td>Site</td><td>Group</td><td>PemissionLevels</td></tr><tr><td>https://tenant.sharepoint.com/sites/MyFirstTeamSite</td><td>Editing Team</td><td>Edit</td></tr><tr><td>https://tenant.sharepoint.com.sites/MyFirstSite</td><td>Design Team</td><td>Design</td></tr></tbody></table>

To create groups, the `New-SPOSiteGroup` cmdlet is the one to execute. Run the below commands to create the groups.

```powershell
# Define the Site URL.
$siteURL = '<https://lzex.sharepoint.com/sites/MyFirstTeamSite>'
# Create the 'Editing Team' group with 'Edit' permission on the site.
New-SPOSiteGroup -Site $siteURL -Group 'Editing Team' -PermissionLevels Edit
# Create the 'Design Team' group with 'Design' permission on the site.
New-SPOSiteGroup -Site $siteURL -Group 'Design Team' -PermissionLevels Design
```

![Creating new groups on the SPO site](https://adamtheautomator.com/wp-content/uploads/2022/07/image-143.png)

Creating new groups on the SPO site

Next, add the users you want to be members of the groups. To do so, run the `Add-SPOUser` commands below.

```powershell
# Add a user to the 'Editing Team' site group
Add-SPOUser -Site $siteURL -Group 'Editing Team' –LoginName spoeditor@lzex.ga
# Add a user to the 'Design Team' site group
Add-SPOUser -Site $siteURL -Group 'Design Team' –LoginName spodesigner@lzex.ga
```

After each command execution, you will receive results similar to the screenshot below.

![Adding users to SPO site groups](https://adamtheautomator.com/wp-content/uploads/2022/07/image-144.png)

Adding users to SPO site groups

### Generating a Site Users List

Leveraging the `Get-SPOUser` command, you can generate which users can access the site.

Run the command below to generate the list of users on the _My First Team Site_.

```powershell
Get-SPOUser -Site <https://lzex.sharepoint.com/sites/MyFirstTeamSite> | Format-Table -Wrap -AutoSize | Out-File <path-to-savereport> -Force -Width 360 -Append
```

The result would look similar to the below screenshot. As you can see, the output shows you the list of users and their group memberships.

![Getting the list of users on the SPO site](https://adamtheautomator.com/wp-content/uploads/2022/07/image-145.png)

Getting the list of users on the SPO site

> _You can also output the results to different file types, including [CSV](https://adamtheautomator.com/export-csv/), [XML](https://adamtheautomator.com/powershell-parse-xml/), [JSON, YAML](https://adamtheautomator.com/yaml-to-json/), [HTML](https://adamtheautomator.com/html-report/), and plain-text._

### Remove Users from Site Groups

You may need to remove a user probably because you added the user to the wrong group or the user is no longer with the team. The `Remove-SPOUser` cmdlet is the right tool for this task.

For example, run the command below to remove the user `spodesigner@lzex.ga` from the `Design Te`ow.

```powershell
Remove-SPOUser `
    -LoginName spodesigner@lzex.ga `
    -Site <https://lzex.sharepoint.com/sites/MyFirstTeamSite> `
    -Group 'Design Team'
```

As you can see, the `Users` list in the `Design Team` is now empty after removing its only member.

![Removing a user for the SPO site group](https://adamtheautomator.com/wp-content/uploads/2022/07/image-146.png)

Removing a user for the SPO site group

## Using the PowerShell SharePoint Online for Automation

Since you’re working with PowerShell, you can leverage its power for automation. For example, scripting would be a more practical approach when creating multiple sites.

You can combine the PowerShell SharePoint Online New-SPOSite command with built-in commands like Import-Csv and ForEach-Object. The following steps give you an example of creating multiple sites with different properties.

Related:[Send Import-Csv and the ForEach Loop for Fast Processing](https://adamtheautomator.com/import-csv-and-the-foreach-loop/)

1\. Run the below command to create a new CSV file called _sites.csv_.

```powershell
New-Item -Type File -Path .\sites.csv
```

2\. Next, open the CSV file in a text editor. This example uses notepad.exe.

```powershell
notepad.exe .\sites.csv
```

3\. Copy the below text into your CSV file and save it. Make sure to replace the Owner and Url values to match your organization.

```powershell
Owner,StorageQuota,Url,Template,Name
spoadmin@lzex.ga,100,https://lzex.sharepoint.com/sites/new-site,STS#0,New Site
ata_dev@lzex.ga,100,https://lzex.sharepoint.com/sites/dev-site,DEV#0,Dev Site
```

Your CSV file would look like the screenshot below.

![Creating the CSV list of new sites](https://adamtheautomator.com/wp-content/uploads/2022/07/image-147.png)

Creating the CSV list of new sites

4\. Run the following script in PowerShell.

```powershell
Import-Csv .\sites.csv | ForEach-Object {
    New-SPOSite `
        -Owner $_.Owner `
        -StorageQuota $_.StorageQuota `
        -Url $_.Url `
        -Template $_.Template `
        -Title $_.Name `
        -NoWait
}
```

If there are no errors, you will not get any additional results on the screen.

![Creating multiple sites using the PowerShell SharePoint online script](https://adamtheautomator.com/wp-content/uploads/2022/07/image-148.png)

Creating multiple sites using the PowerShell SharePoint online script

5\. Finally, execute the following command to confirm the new sites exist.

```
Import-Csv .\sites.csv | ForEach-Object {
    Get-SPOSite -Identity $_.Url | Select-Object Title,Url,Owner
}
```

![Listing the new sites](https://adamtheautomator.com/wp-content/uploads/2022/07/image-149.png)

Listing the new sites

You can apply the same technique you just performed to automate bulk tasks like site group creations and site group membership updates.

## Conclusion

The PowerShell SharePoint Online module allows you to improve how you manage your SharePoint Online organization. This module is not meant to replace the SharePoint admin center but as a tool to augment your SharePoint Online skills.

Apart from the PowerShell SharePoint Online module, did you know another module lets you manage SharePoint Online in PowerShell? Yes, that module is the [PnP PowerShell](https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets) module. Why don’t you also explore that module and compare which works best for you?

Related:[How to Use SharePoint PNP PowerShell Module in Office 365](https://adamtheautomator.com/sharepoint-pnp/)

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-sharepoint%2F&text=Getting%20Started%20with%20PowerShell%20SharePoint%20Management)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-sharepoint%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-sharepoint%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/publisher/3ec5d9c85b2b81d9ab7cd5dbb6caf044/21b786d67f19d1813150edf9871e36ead78714b63880de8c6161c7fde11a9769.webp)

### [Pktmon: Capture Windows Traffic Without a Third-Party Driver](/pktmon-capture-windows-traffic/)

Use the in-box Windows Pktmon tool to capture packets and packet-drop reasons, then convert the ETL to pcapng and text for offline analysis.

![](https://adamtheautomator.com/wp-content/uploads/publisher/2e05d9c85b2b81feb24af1f04a889143/3eab14af9dabf46fbd333914ce6ccf46f84117d2394d3e7218c186cd249bb7e2.webp)

### [PowerShell or Power Automate: Stop Automation Mistakes](/powershell-vs-power-automate/)

Score six factors to choose between PowerShell and Power Automate: target system, complexity, data volume, team skills, cost, governance.

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
