Share via

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

Anonymous
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

Microsoft 365 and Office | SharePoint | For business | Windows

2 answers

Sort by: Most helpful
  1. Alvaro Avila 175 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.

    Was this answer helpful?

    0 comments No comments

  2. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    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.

    Was this answer helpful?


Your answer

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