microsoftgraph / microsoftgraph/msgraph-sdk-powershell

Get-MgSite properties not returning when -all is used in conjunction with -ExpandProperty.

Open
#3,222 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
C#
Stars
898
Forks
230
Avg merge
2d 5h
Merged PRs (30d)
31

Description

Describe the bug

When I run: Get-MgSite -All -ExpandProperty Drive

All some properties are empty when using -All or -Top 10

$Sites[0].Drive

Name Id DriveType CreatedDateTime


But when running Get-MgSite -siteId <example site id> -ExpandProperty Drive it works as expected:

$site.Drive

Name Id DriveType CreatedDateTime


OneDrive b!Pk2E5-ljkk<>DvB business 01/03/2025 02:30:31

Same behavior for other expanded properties like Analytics and CreatedByUser (not tested all)

Expected behavior

Expected same property output from calling by siteId as calling All.

How to reproduce

Execute $Sites = Get-MgSite -All -ExpandProperty Drive
Note none of the Drive attributes are populated.

SDK Version

2.26.1

Latest version known to work for scenario above?

No response

Known Workarounds

Can run a foreach-object loop to run the command individually but it takes a lot longer.

Debug output
Click to expand log ```
</details>


### Configuration

Windows 11 x64

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

### Other information

_No response_

Contributor guide

Open the contributing guide

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

Start by reproducing Get-MgSite with -All or -Top 10 and -ExpandProperty Drive, then compare its results with a siteId request and the similar Analytics and CreatedByUser cases. Trace how Get-MgSite handles paging and expanded properties, and verify the generated requests and responses. Done means expanded properties are populated consistently and regression coverage exists for the collection calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.