pnp / pnp/script-samples

Property "displayName" cannot be found.

Open
#770 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
347
Forks
191
Avg merge
5d 16h
Merged PRs (30d)
10

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open scripts/teams-list-teams-owners-and-members and inspect the Owner, Member, and Guest name pipelines reported in the issue. Compare them with the proposed replacements, then verify that each role produces semicolon-separated names without the property error on PowerShell 5.1.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.