I'm attempting to make a Powershell module to work with an external API. I have a custom object which looks like this:

```
$Subscriber = New-Module -AsCustomObject -ScriptBlock {
    [string] $EmailAddress=$null
    [string] $Name=$null
    [bool]   $Resubscribe=$false
    [bool]   $RestartSubscriptionBasedAutoresponders=$false

    Export-ModuleMember -Variable * -Function *
}

```

Now, I'd like this object to be able to implement a function which outputs itself in JSON format. I'm aware that the normal way to do this is: `$Subscriber | ConvertTo-Json` but instead, I'd like this object to implement something along these lines:

```
$Subscriber = New-Module -AsCustomObject -ScriptBlock {
    [string] $EmailAddress=$null
    [string] $Name=$null
    [bool]   $Resubscribe=$false
    [bool]   $RestartSubscriptionBasedAutoresponders=$false

    Function ToJson {
        $this | ConvertTo-Json
    }

    Export-ModuleMember -Variable * -Function *
}

```

But my problem is that there is no $this variable nor have I been able to find any information about any other way to do it. Am I simply attempting to misuse Powershell to such a degree that this isn't supported at all? Or am I just missing something obvious? I'm open to any critique and advice :)