List all guest users in tenant based on site collection

%3CLINGO-SUB%20id%3D%22lingo-sub-2306153%22%20slang%3D%22en-US%22%3EList%20all%20guest%20users%20in%20tenant%20based%20on%20site%20collection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2306153%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%3CBR%20%2F%3EI%20would%20like%20to%20export%20a%20list%20of%20guest%20users%20in%20our%20tenancy%20but%20i%20need%20to%20scope%20it%20to%20some%20specific%20site%20collections.%20Don't%20want%20all%20the%20site%20collections%20in%20the%20tenancy%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20know%20i%20can%20use%20the%20below%20to%20get%20all%20users%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EGet-AzureADUser%20-All%20%24true%20-Filter%20%22UserType%20-eq%20'Guest'%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20the%20below%20to%20get%20specific%20site%20collections%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%23Get%20All%20Site%20Collections%20starting%20with%20url%20starting%20with%20ABC%0A%24SiteCollectionsURL%20%3D%20%22%2FABC%22%0A%0A%24GetTenantSite%20%3D%20Get-PnPTenantSite%20-Filter%20%22Url%20-like%20%24SiteCollectionsURL%22%20-Detailed%20%7C%20Select-Object%20Title%2C%20URL%2C%20Created%2C%20Status%2C%20Owner%2C%20LastContentModifiedDate%2C%20WebsCount%2C%20Template%2C%20StorageUsage%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20do%20i%20need%20to%20do%20to%20combine%20the%20two%20to%20get%20the%20site%20collections%20and%20then%20the%20guest%20users%20in%20those%20site%20collections%3F%3C%2FP%3E%3CP%3EAm%20i%20in%20the%20right%20directions%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20Advance%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2306153%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Frequent Contributor

Hi All,
I would like to export a list of guest users in our tenancy but i need to scope it to some specific site collections. Don't want all the site collections in the tenancy

 

I know i can use the below to get all users

 

Get-AzureADUser -All $true -Filter "UserType -eq 'Guest'"

 

 

and the below to get specific site collections

 

#Get All Site Collections starting with url starting with ABC
$SiteCollectionsURL = "/ABC"

$GetTenantSite = Get-PnPTenantSite -Filter "Url -like $SiteCollectionsURL" -Detailed | Select-Object Title, URL, Created, Status, Owner, LastContentModifiedDate, WebsCount, Template, StorageUsage 

 

What do i need to do to combine the two to get the site collections and then the guest users in those site collections?

Am i in the right directions?

 

Thanks in Advance

0 Replies