Hi @susmitha ,
You can refer to following code to retrieve details
#Set the Web application URL
$WebAppURL="https://xxx.sharepoint.com"
#Get the Web Application
$WebApp = Get-SPWebApplication $WebAppURL
#Get all Site collections from the web application
$SitesCollection = $WebApp.Sites
#Enumerate all site collections in the web application
Foreach($Sites in $SitesCollection)
{
#Get Site Collection URL, Owner, Content Database Details
$SiteURL = $Sites.URL
Write-host $Sites.URL
$site = new-object Microsoft.SharePoint.SPSite($siteCollURL)
$web = $site.openweb()
$siteUsers = $web.SiteUsers
Write-Host "Site Collection URL:" , $siteCollURL
foreach($user in $siteUsers)
{
if($user.IsSiteAdmin -eq $true)
{
Write-Host "User Name: ", $user.LoginName , "Role: Admin"
}
else
{
Write-Host "User Name: ", $user.LoginName, "Role: User"
}
}
$web.Dispose()
$site.Dispose()
}
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.