1

I have to get the list of sites which are using any of the 3 sharepoint AD groups. Here is function responsible for this:

function Search-Groups ($Web, $FilePath)
{
    try
    {
        foreach($User in $Web.Users)
        {
            if($User.Name -eq "GLOpRED-SP_LT" -Or $User.Name -eq "GLOpRED-SP_PPDA" -Or $User.Name -eq "GLOpRED-SP_GPM")
            {
                Write-Output $Web.Url | Out-File $FilePath -append
                break
            }
            else
            {
                Write-Host "Given groups are not being used in $($Web)"
            }
        }
    }
    catch
    {
        Write-Warning "An errorr occured when trying to access groups: $_" 
    }
}

The problem is, that it didn't found any sites with those groups, despite that they exist. Anyone has an idea what is wrong with this function?

1 Answer 1

1

The "Name" of the SPUser (in this case AD Group) isn't necessarily the same as the "LoginName".

Run the following query to see the AD groups on a particular web. This will point you in the right direction:

$Web.Users | ? { ($_.IsDomainGroup) } | select Name, LoginName

It might be that the "Name" you're querying is totally different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.