Need a Powershell script to export the SharePoint Sites with a condition..

Santhosh Kumar 0 Reputation points
2024-11-08T17:30:56.5633333+00:00

Hi All,

I need a Powershell script to export the SharePoint Sites with a condition - Zero Members and only one Owners.

Any help would be greatly appreciated!

Regards,

SK

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,957 questions
{count} votes

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 36,731 Reputation points Microsoft Vendor
    2024-11-11T07:27:19.6933333+00:00

    Hi @Santhosh Kumar,

    You could use the Get-SPOSite cmdlet, which returns the site collection information, including the owner.

    $SiteURL = "https://crescent-admin.sharepoint.com"
    $CSVPath = "C:\Temp\SiteOwners.csv"
      
    #Connect to Admin Center Site
    Connect-PnPOnline -Url $SiteURL -Interactive
       
    #Get All Site collections
    $SiteCollections = Get-PnPTenantSite
    $SiteOwners = @()
     
    #Loop through each site collection
    ForEach($Site in $SiteCollections)
    {
         $Owners = $Site.Owner
         If($Owners.count = 1){
         Write-Output "Site:" $Site.Url
    }
    
    }
    

    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.


  2. Alvaro Avila 165 Reputation points
    2024-12-03T13:28:30.5966667+00:00

    You can use this free and open source application to get a report with all the site permissions across all sites in the tenant:

    https://github.com/Barbarur/NovaPoint

    once the report is generated, you can filter it based on the site that doesn’t have users.

    0 comments No comments

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.