New-PSUEndpoint - Self referencing loop detected


Trying to setup a PSU Endpoint, so trying out something simple first

New-PSUEndpoint -Url "/locked/:Identity" -Method 'GET' -Endpoint { 
    Get-ADUser -Identity $Identity

I would expect


to return my test active directory account, However it returns this

Invoke-RestMethod: Self referencing loop detected for property 'AccountDomainSid' with type 'System.Security.Principal.SecurityIdentifier'. Path '[0].SID.AccountDomainSid'.

If i throw in a username for an account that doesn’t exist it returns that the account doesn’t exist, but looking up a real account just errors.

Am i missing something obvious here?


hey, on what version on psu you on ?


using 1.3.0

The issue is, that the user’s SID is stored as a System.Security.Principal.SecurityIdentifier object. This class defines a property AccountDomainSid which is a SecurityIdentifier again and again has the property AccountDomainSid.

$s = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-21-2574500967-3820011325-2890284680-1000')

To work-around this, you can create a pscustomobject with the properties you need that don’t create this recursion issue.

@adam, can we set the serialization depth somewhere?

I’ve logged an issue for this. We should be able to fix that.

You can work around it by using ConvertTo-Json directly and specifying the depth that way.