msgraph-sdk-powershell
msgraph-sdk-powershell copied to clipboard
Get-MgDomainNameReference does not return all results
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
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?
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 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.