Skip to content

Property "displayName" cannot be found. #770

Description

@dqncl

Hi,

just encouraged an error while running one of your scripts. Seems like the object is not properly passed by piping it into Select-Object.

Error:

select : Property "displayName" cannot be found.
At line:1 char:112
+ ... --role Owner | ConvertFrom-Json | select -ExpandProperty displayName)
+                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (  :PSObject) [Select-Object], PSArgumentException
    + FullyQualifiedErrorId : ExpandPropertyNotFound,Microsoft.PowerShell.Commands.SelectObjectCommand

Affects:
scripts/teams-list-teams-owners-and-members CLI for Microsoft 365 version

Fix:

$teamOwnerNames = (m365 teams user list --teamId $_.id --role Owner | ConvertFrom-Json | select -ExpandProperty displayName) -join ";" 
-> $teamOwnerNames = (m365 teams user list --teamId $_.id --role Owner | ConvertFrom-Json).displayName -join ";"

$teamMemberNames = (m365 teams user list --teamId $_.id --role Member | ConvertFrom-Json | select -ExpandProperty displayName) -join ";" 
-> $teamMemberNames = (m365 teams user list --teamId $_.id --role Member | ConvertFrom-Json).displayName -join ";"

$teamGuestNames = (m365 teams user list --teamId $_.id --role Guest | ConvertFrom-Json | select -ExpandProperty displayName) -join ";" 
-> $teamGuestNames = (m365 teams user list --teamId $_.id --role Guest | ConvertFrom-Json).displayName -join ";"

PS Version:

Name                           Value
----                           -----
PSVersion                      5.1.19041.5007
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.5007
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

OS Windows 10

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions