How to Get the SharePoint Site Owner Using PowerShell?

A SharePoint site needs to be managed once it is created. The owner of the SharePoint site steps in at this point. Over the site, they can have complete control.

This quick PowerShell guide will demonstrate how to get the SharePoint site owner using PowerShell and PnP PowerShell.

How to Get the SharePoint Site Owner Using PowerShell

Using PowerShell, we can get the site owner of the below SharePoint sites:

  • Get the SharePoint Site Owner [Microsoft 365 Non-Group Connected]
  • Get the SharePoint Site Owner [Microsoft 365 Group Connected]

Get the SharePoint Site Owner [Microsoft 365 Non-Group Connected] Using PowerShell

In this example, we see how to get site owners using PowerShell in theSharePoint site without office 365 group connected.

Before starting with the PowerShell code, ensure you have a SharePoint site without office 365 group connected presented in your tenant.

Get all SharePoint and Teams sites owners using PowerShell

1. First, we need to connect our site with PowerShell. To connect PowerShell you need to run below code. Then Click the Run Script button.

#Credentials to connect
Connect-SPOService -Url https://szg52-admin.sharepoint.com/ -Credential MiriamG@szg52.onmicrosoft.com
Get the Site Owner using PowerShell

2. After that, one dialog box comes up where you enter your Password and Click OK.

Getting the owners for team Site using PowerShell

Now we successfully connected PowerShell into our tenant.

3. To get the site owner. Copy and paste the PowerShell code into Windows PowerShell ISE. Then Click the Run Script button.

#sharepoint online powershell get site owner

Get-SPOSite "https://szg52.sharepoint.com/sites/CollaborativeCore" | Select Owner
How to Find a team Site(no microsoft 365 group) Owners using PnP PowerShell

4. You can see the site owner in the output window.

get site owners using PowerShell in the team site without office 365 group connected

You can get site owners using PowerShell on the SharePoint site without the Office 365 group connected.

Get the SharePoint Site Owner [Microsoft 365 Non-Group Connected] Using PnP PowerShell

In this example, we see how to get SharePoint site(no microsoft 365 group) owners name using PnP Power Shell.

We are using the above SharePoint site(no Microsoft 365 group).

1. First, open Windows PowerShell ISE. Then, connect your site with PnP PowerShell by running the code below. Finally, click the “Run Script” button.

#connected site into Pnp PowerShell
Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/CollaborativeCore" -Credentials (Get-Credential)
Get the Team Site(no Microsoft 365 group) Owner using PnP PowerShell

2. Then, a dialog box will appear where you need to enter your username and password. After that, click OK.

How to Find Team Site(no Microsoft 365 group) Owner using PnP Power Shell

3. To find the site owner, copy and paste the PnP PowerShell code into Windows PowerShell ISE. Then Click the Run Script button.

#Get site owner using PnP PowerShell
$site = Get-PnPTenantSite -Url "https://szg52.sharepoint.com/sites/CollaborateHubSolutions"
$site.Owner
get a team site(no Microsoft 365 group) Owners using PnP PowerShell

4. You can see the site owner in the output window.

Get Team Site(no Microsoft 365 group) Owners using PnP PowerShell

This way you can get SharePoint site(no microsoft 365 group) owners name using PnP Power Shell.

PowerShell Get the SharePoint Site Owner [Microsoft 365 Group Connected]

This example shows how to get the SharePoint site(Microsoft 365 group) owners using PowerShell.

Before starting with the PowerShell code, ensure you have a SharePoint site with office 365 group connected presented in your tenant.

PowerShell get Team Site(Microsoft 365 group) owner

Before starting, you must install the AzureAD module. To install AzureAD, use the below expression:

Install-Module -Name AzureAD

1. Open Windows PowerShell ISE. First, we need to connect our site with PowerShell. To connect PowerShell you need to run below code. Then Click the Run Script button.

Connect-AzureAD
How to get a SharePoint site owner in PowerShell

2. To find the site owner, copy and paste the PowerShell code into Windows PowerShell ISE. Then Click the Run Script button.

$site = Get-SPOSite -Identity "https://szg52.sharepoint.com/sites/CollabNexus" 
Get-AzureADGroupOwner -ObjectId $site.GroupID | Select -ExcludeProperty UserPrincipalName
How to get list of site owners in PowerShell script

3. You can see the site owner in the output window.

Get the Team Site(Microsoft 365 group) Owners using PowerShell

PowerShell lets you get the team site (Microsoft 365 group) owners this way.

Conclusion

I hope this article gave you a lot of knowledge about how to get the SharePoint site owner using PowerShell and PnP PowerShell.

Additionally, you may like some more PowerShell tutorials:

How to Connect to SharePoint Online Using PowerShell