# Searching for guest users in Microsoft Teams

**URL:** <https://forums.powershell.org/t/searching-for-guest-users-in-microsoft-teams/13734>\
**Category:** PowerShell Help\
**Created:** [January 29, 2020, 11:40am UTC](https://forums.powershell.org/t/searching-for-guest-users-in-microsoft-teams/13734 "2020-01-29T11:40:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaredmitchell](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@jaredmitchell](https://forums.powershell.org/u/jaredmitchell)\
**Post date:** [January 29, 2020, 11:40am UTC](https://forums.powershell.org/t/searching-for-guest-users-in-microsoft-teams/13734/1 "2020-01-29T11:40:11Z")

</div>

Hi everyone,

I am trying to figure out how to use PowerShell to search for the guest users I have inside my Microsoft Teams. When I run the following:

Get-Team -User first.last@company.com | Select GroupId

I get the Group Id for all teams that I am in, listed like so (dummy values):

61e72e0d-eb48-4eq9-b02a-6a29420e9d4f

9q4b769l-16bb-4040-a740-4208ce9a61f9

aca41337-fc87-4fdb-9a2d-b14276a514c6

Next, I can run:

Get-TeamUser -GroupId 61e72e0d-eb48-4eq9-b02a-6a29420e9d4f -Role Guest

to see all the guests within an individual group. When I run the following:

Get-Team -User first.last@company.com | Select GroupId | Get-TeamUser -GroupId $\_ -Role Guest

I get the error:

Cannot bind argument to parameter 'GroupId' because it is null.

I also tried

Get-Team -User first.last@company.com

ForEach-Object {

 $\_ | Get-TeamUser

}

and get the error:

Get-TeamUser : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.

Any suggestions? Thank you very much!

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [January 29, 2020, 1:05pm UTC](https://forums.powershell.org/t/searching-for-guest-users-in-microsoft-teams/13734/2 "2020-01-29T13:05:28Z")

</div>

You have to really understand how the pipelining works. $\_ has value only inside a scriptblock when used with some specific cmdlets like Where-Object, Foreach-Object etc and in some other special scenarios, it doesn’t hold a value otherwise.

From the below doc, I can see that parameter GroupId of Get-TeamUser cmdlet takes input via pipeline, hence you just need to

```
Get-Team -User first.last@company.com | Get-TeamUser -Role Guest
```

Get-TeamUser: [Get-TeamUser (MicrosoftTeamsPowerShell) | Microsoft Docs](https://docs.microsoft.com/en-us/powershell/module/teams/get-teamuser?view=teams-ps)  
More on PowerShell pipeline binding: [https://4sysops.com/archives/understanding-powershell-pipeline-parameter-binding/](https://4sysops.com/archives/understanding-powershell-pipeline-parameter-binding/)

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:30pm UTC](https://forums.powershell.org/t/searching-for-guest-users-in-microsoft-teams/13734/3 "2024-05-16T20:30:47Z")

</div>


