Hi @Sunny Rastogi ,
We could use pnp powershell to achieve this.
- Get all site collections in the tenant and get the group in the root site.
- Get all subsites in the current site collection and get the group in the root site.
Code for your reference:
$username = "amos@contoso.onmicrosoft.com"
$password = "password"
$groupName = "Designers"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/dev -Credentials $cred
$sites=Get-PnPTenantSite
for($i=0; $i -le $sites.length; $i++){
try {
Connect-PnPOnline -Url $sites[$i].URL -Credentials $cred
$group=Get-PnPGroup -Identity $groupName -ErrorAction Stop
if($group -ne $null){
Write-Host $sites[$i].URL $group.Title -Foregroundcolor green
}
}
catch {
Write-Host $sites[$i].URL "$($_.Exception.Message)" -Foregroundcolor Red
}
$subwebs=Get-PnPSubWebs -Recurse
if($subwebs -ne $null) {
for($j=0; $j -le $subwebs.length; $j++){
try {
Connect-PnPOnline -Url $subwebs[$j].URL -Credentials $cred
$group=Get-PnPGroup -Identity $groupName -ErrorAction Stop
if($group -ne $null){
Write-Host $subwebs[$j].URL $group.Title -Foregroundcolor green
}
}
catch {
Write-Host $subwebs[$j].URL "$($_.Exception.Message)" -Foregroundcolor Red
}
}
}
}
It will list the sites containing this group in green, and the sites without this group in red.
If the response is helpful, please click "Accept Answer" and upvote it.
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.