Skip to content

about_Remote_Output needs clarifications, corrections and additional information, especially in the "DESERIALIZED OBJECTS" section #5075

@mklement0

Description

@mklement0

It should be clarified that serialization and deserialization also happens in the following contexts, in addition to remoting:

  • background jobs (child-process-based jobs created with Start-Job, not thread-based ones created with Start-ThreadJob / ForEach-Object -Parallel)
  • calling the CLI with a script block from within PowerShell (e.g., pwsh -c { Get-Item / })

However, the remoting-related properties such as PSComputerName aren't added in these scenarios.


Re section "DISPLAYING THE MACHINENAME PROPERTY":

It should be clarified that the per-cmdlet, DCOM-based remoting supported by some cmdlets (with their own -ComputerName parameter) in Windows PowerShell is no longer supported in PowerShell Core - in PowerShell Core, these cmdlets never had -ComputerName parameters.


Re section "DESERIALIZED OBJECTS":

However, the deserialized object is not a live object. It is a snapshot of the object at the time that it was serialized, and it includes properties but no methods.

This is true for most reference types and most non-primitive value types.
The set of well-known types that deserialize type-faithfully is in the MS-PSRP (PowerShell remoting) protocol, which the topic should at least link to.

Some object types, such as DirectoryInfo objects and GUIDs, are converted back into live objects when they are received.

DirectoryInfo instances (and FileInfo instances) are not converted back to live objects - they cannot be.

Enumerating the full set of well-known types - those that deserialize type-faithfully - directly in this topic would be helpful.

Non-type-faithfully-deserialized objects, which are [pscustomobject] instances, reflect the type of origin in their hidden .pstypenames property, as also reported by Get-Member.
Specifically, the original type name and its inheritance chain are recreated with prefix Deserialized.

To illustrate this with a deserialized DirectoryInfo type:

PS> (Start-Job { Get-Item / } | Receive-Job -Wait -AutoRemoveJob).pstypenames
Deserialized.System.IO.DirectoryInfo
Deserialized.System.IO.FileSystemInfo
Deserialized.System.MarshalByRefObject
Deserialized.System.Object

When objects are not formatted, all of the properties of each object appear in the console in a streaming list.

It would be helpful to clarify that this means that Format-List formatting is implicitly applied, but you're free to pipe to Format-Table instead, for instance.

Or, you can use the Out-GridView cmdlet to display the objects in a table.

Worth noting that Out-GridView is currently only available in Windows PowerShell.


Also worth clarifying that serialization / deserialization is also performed when sending values to remotely executing script blocks / script blocks in child-process-based background jobs (Start-Job), as input / arguments, as discussed in about_Remote_Variables (which is already linked to in the "SEE ALSO" section, but without context).


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-remotingArea - PowerShell remoting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions