Symptoms
Get-MsolUser
powershell comandlet fails with the following error:
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://provisioning.microsoftonline.com/:ListUsersResult.
The InnerException message was
'Maximum number of items that can be serialized or deserialized in an object graph is '65536'.
Change the object graph or increase the MaxItemsInObjectGraph quota. '. Please see InnerException for more details
Cause
The total items in Object Graph to be serialize / deserialize are more than the default allowed limit - 65536.
Resolution
Increase the limit.
Check your powershell version:
$psversiontable.psversion.tostring()
- Modify the
machine.config
file inC:\Windows\Microsoft.NET\Framework[64]\[Powershell version]\CONFIG
directory:
Add <dataContractSerializer maxItemsInObjectGraph="2147483646" />
line to the <endpointBehaviors>
section like:
<endpointBehaviors>
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
<Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior/>
</endpointBehaviors>