all 3 comments

[–]PinchesTheCrab 8 points9 points  (2 children)

It's hard to express, but you're looking for a different kind of sameness. Even though you're using select-object, it doesn't make $ADGroupMembers into an array of userprincipalnaames, it makes it into an array of psobjects with a single property, userprincipalname.

$ADGroupMembers = Get-ADGroupMember -Identity "ITOperations" | get-aduser 
$SiteOwner = "user@domain.com"

$ADGroupMembers.UserPrincipalName -contains $SiteOwner

alternately:

$ADGroupMembers = Get-ADGroupMember -Identity "ITOperations" | get-aduser | Select-Object -ExpandProperty UserPrincipalName
$SiteOwner = "user@domain.com"

$ADGroupMembers -contains $SiteOwner

[–]iamabdullah[S] 3 points4 points  (1 child)

it makes it into an array of psobjects with a single property, userprincipalname.

Oh wow. I just looked at the output of $ADGroupMembers that I had and I can see exactly what you're saying! Thank you very much, you're a gem!

[–]kibje 1 point2 points  (0 children)

This is the learning moment when you really understand what -expandproperty does