Hi,
The PowerShell cmdlet ‘Get-AzureADUser’ is used to retrieve guest users in the tenant. To list all the guest accounts, run the following.
Get-AzureADUser -All $true -Filter "UserType -eq 'Guest'"
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi
I want to get a list of guest users who have access on microsoft teams.
Please look snapshot. How to get these guest users by powershell. thanks
Hi,
The PowerShell cmdlet ‘Get-AzureADUser’ is used to retrieve guest users in the tenant. To list all the guest accounts, run the following.
Get-AzureADUser -All $true -Filter "UserType -eq 'Guest'"
List all guests in Microsoft Teams teams in the tenant and export the results in a CSV.
Install-Module MicrosoftTeams
Connect-MicrosoftTeams
$teams = @()
$externalteams = @()
$teams = get-team
foreach ($team in $teams){
$groupid = ($team.groupid)
$users = (Get-TeamUser -GroupId $team.groupid | Where-Object {$_.Role -eq "Guest"})
$extcount = ($users.count)
foreach ($extuser in $users){
$id = $team.groupid
$teamext = ((Get-Team | Where-Object {$_.groupid -eq "$id"}).DisplayName).ToString()
$ext = $extuser.User
$externalteams += [pscustomobject]@{
ExtUser = $ext
GroupID = $id
TeamName = $teamext
}
}
}
if ($externalteams.Count -gt 0){
Write-Host "Exporting the guest members in teams results.."
$externalteams | Export-Csv -Path "GuestUsersFromTeams.csv" -NoTypeInformation
Write-Host "Completed."
}
else{
Write-host "there are no external user added to any team in your organization" -ForegroundColor yellow
}
Hi @Anonymous
Teams tag is mainly focused on the general issue of Microsoft Teams troubleshooting. According to your description, your problem is related to development, which we are not very familiar. The following suggestion is just for your reference. Thanks for your understanding!
Please run the following command. Returns an array containing the UPN, UserId, Name and Role of users belonging to a specific GroupId.
Get-TeamUser -GroupId -Role Guest
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.
Hi @Anonymous
As he provided the script above, you can easily export all guest users. The following is the complete code, please refer to it.
Install-Module azuread
connect-Azuread
Get-AzureADUser -Filter "UserType eq 'Guest'" | select DisplayName, Mail | Export-Csv guests.csv -NoTypeInformation
Import-Csv -path .\guests.csv
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.