Is there a PowerShell script that gets all SharePoint sites and the owners of the site

MDuBose 716 Reputation points
2023-09-18T20:15:47.89+00:00

Using the PowerShell commands below, it lists all sites and sub sites including the title, author and url of those site. However, the author property returns the user who created the site not the site owner.

Write-Host("Getting Site Data")

Get-SPSite | Get-SPWeb -Limit All | select Title, Author, Url

I've also tried the command below but Owner returns empty.

Write-Host("Getting Site Data")

Get-SPSite | Get-SPWeb -Limit All | select Title, Author, Url, Owner, @{Expression={$_.Owner}}

Is there a property where I can get the site owner of a site?

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,335 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,468 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ChengFeng - MSFT 5,020 Reputation points Microsoft Vendor
    2023-09-19T07:02:17.8533333+00:00

    Hi @ MDuBose

    The Author property of the Get-SPWeb cmdlet returns the user who created the site, not the site owner. To get the site owner, you need to use the Get-SPOSite cmdlet, which returns the site collection information, including the owner.

    If you want to get the site owner of a SharePoint Online site, you can use the following PowerShell script:

    #Variables for Admin Center & Site Collection URL 
    $AdminCenterURL = “https://<TenantName>-admin.sharepoint.com/” $SiteURL = “https://<TenantName>.sharepoint.com/sites/<SiteName>”
    #Connect to SharePoint Online 
    Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)
    #Get Site Owner 
    Get-SPOSite $SiteURL | Select Owner
    

    This script will connect to your SharePoint Online admin center and then get the owner of the specified site collection.

    If you want to get the site owner of all SharePoint Online sites, you can use this script:

    $AdminCenterURL = “https://<TenantName>-admin.sharepoint.com/”
    #Connect to SharePoint Online 
    Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)
    #Get Site owners of all site collections Get-SPOSite -limit ALL | Select URL, Owner
    

    This script will connect to your SharePoint Online admin center and then get the URL and owner of all site collections.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards

    Cheng Feng


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.