liveBook · Manning

Serialization

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

Serialization is the conversion of an in-memory object or data structure into a representation suitable for storage or transmission.

Serialization converts an in-memory object or data structure into a transferable representation. In PowerShell remoting, output objects become XML, travel across the network, and are deserialized back into objects on your computer. section 13.1.3

Deserialized remote objects are useful, but they have important limits:

  • They are snapshots of the moment when the remote objects were generated; values such as CPU usage and memory usage do not update automatically. section 13.1.3
  • They are not fully functional remote objects, so you cannot directly instruct one to perform an action such as stopping itself. section 13.1.3
  • Complete filtering and other processing remotely whenever possible, then transmit only the results needed for display or reporting. section 13.7.2

Filter before serialization

Invoke-Command -HostName SRV2,DC3,SRV4 -ScriptBlock { Get-Process pwsh -UserName tylerl | Where-Object {$_.Parent.ProcessName -like '*term*'} } filters on each remote computer before serializing the remaining results. Filtering after Invoke-Command transmits unnecessary data and can leave local commands unable to identify the original remote object. section 13.7.2

Invoke-Command -HostName SRV2,DC3,SRV4
-ScriptBlock { Get-Process pwsh -UserName tylerl  | 
Where-Object {$_.Parent.ProcessName -like '*term*'}}

Compare the remote filtering placement in a working Invoke-Command pipeline. section 13.7.2

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Defines the conversion process and explains snapshots, lost behavior, and remote-processing consequences.
Examples
Uses remote process and event-log filtering examples, including Invoke-Command pipelines and serialized process output.
What it assumes
Assumes PowerShell remoting basics and recommends PowerShell 7.1 or later on both computers.
What you can do after
Apply serialization knowledge via PowerShell remoting to filter remotely and avoid treating results as live remote objects.
How it connects
Connects serialization with PowerShell remoting, XML, deserialization, Invoke-Command, and remote processing.

Also explained in

Compare how 24 books explain serialization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.