1

I am using the following powershell command to list all users in a site collection:

$sites = get-spsite "http://mysite/sitecollection/"
$web = $site.RootWeb
$web.Users | select-object
$web.sitegroups | select-object
$site.Dispose()

However, when i look at the People and Groups page I see a number of other users listed which are not being returned by this script. There are no sub sites to this sitecollection and the users that appear on the page look to be Active Directory users.

To clarify, when i click People and Groups from the site setting screen, i am then clicking the "more.." link on the left navigation.

How do i get all these users to return in my script. I basically want to remove all users and groups who dont have any permissions in this newly imported site which was exported from a larger sitecollection and moved under a new sitecollection.

Thanks in advance.

2

You can use the Get-SPUser command to list all users in the site collection

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

Get-SPUser -Web http://mysite/sitecollection/ -Limit ALL | ft -auto

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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