msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Get-MgDomainNameReference does not return all results

Open titlerequired opened this issue 1 year ago • 2 comments

Describe the bug

Get-MgDomainNameReference -DomainId $domain.id -All Returns 300 results by default. Using page size, you can return 999. However in environments with more recipients the command does not seem to paginate.

Expected behavior

Using -all returns all references in a tenant.

How to reproduce

Get-MgDomainNameReference -DomainId $domain.id -All | measure-object

SDK Version

2.19.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Debug information is truncated.

Configuration

Name Value


PSVersion 5.1.19041.4648 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.4648 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Other information

No response

titlerequired avatar Jul 16 '24 15:07 titlerequired

Work around, using Invoke-RestMethod if you query: https://graph.microsoft.com/v1.0/domains/<domain id>/domainNameReferences/microsoft.graph.group or https://graph.microsoft.com/v1.0/domains/<domain.id>/domainNameReferences/microsoft.graph.user You can retrieve all results, it is not clear how to do this using Get-MgDomainNameReference as trying to filter on type appears to be unsupported. "The specified filter to the reference property query is currently not supported." Get-MgDomainNameReference -Filter "@odata.type eq '#microsoft.graph.user'"

Is there a way to query this using PowerShell?

titlerequired avatar Jul 19 '24 12:07 titlerequired

Invoke-MgGraphRequest < is the way to go. You still need to use a filtered URL, but It returns a @odata.nextLink that you can follow to loop through/paginate.

titlerequired avatar Jul 19 '24 13:07 titlerequired

@titlerequired thank you for suggesting an alternative. However, I will close this because the issue had already been reported here https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2580. Looks like is a general problem across certain cmdlets.

timayabi2020 avatar Feb 10 '25 13:02 timayabi2020