PowerShell Script To Retrieve The List Of All Site Collection Admins

Steps
  1. Open your SharePoint Management Shell.
  2. Copy the code given below and paste it there.
  3. Run the code given below to delete the SharePoint search component.
Code 
  1. $siteUrl = Read-Host "https://gowtham.sharepoint.com/tutorials"  
  2. $rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)  
  3. $spWebApp = $rootSite.WebApplication  
  4.   
  5. foreach($site in $spWebApp.Sites)  
  6. {  
  7.    foreach($siteAdmin in $site.RootWeb.SiteAdministrators)  
  8.    {  
  9.       Write-Host "$($siteAdmin.ParentWeb.Url) - $($siteAdmin.DisplayName)"  
  10.    }  
  11.    $site.Dispose()  
  12. }  
Thanks for reading my blog.