liveBook · Manning

Deserialization

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

Deserialization is the conversion of a stored or transmitted representation back into an in-memory object or data structure.

Deserialization converts transmitted XML back into objects that PowerShell can work with. During remoting, a computer serializes command output into XML, sends it across the network, and the receiving computer deserializes it. section 13.1.3

Treat deserialized objects as snapshots, not live remote objects. Process values such as memory and CPU usage reflect the moment they were generated, and the objects cannot perform actions such as stopping themselves. section 13.1.3

Use deserialized results carefully when processing remote data:

  • Complete filtering and other processing on the remote computer whenever possible, then transmit only the results you need. section 13.7.2
  • Expect local handling after Invoke-Command to display or store results, rather than to operate on the original remote resources. section 13.7.2

Filter remotely before deserialization

Invoke-Command -HostName SRV2,DC3,SRV4 -ScriptBlock { Get-Process pwsh -UserName tylerl | Where-Object {$_.Parent.ProcessName -like '*term*'} } places the filtering inside the remote script block. The smaller result is then serialized, transmitted, and deserialized locally. section 13.7.2

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

Compare remote filtering with local filtering to see how script-block placement controls transmitted data. 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
Explains XML conversion, snapshots, and action limits, but stops short of internal serialization mechanics.
Examples
Demonstrates remote process filtering and contrasts transmitting filtered results with filtering deserialized results locally.
What it assumes
Assumes familiarity with PowerShell objects, pipelines, and remote commands, while defining serialization and deserialization directly.
What you can do after
Apply it via PowerShell remoting by filtering remote data before transmission and treating received objects as reports or stored data.
How it connects
Connects serialization with XML, PowerShell remoting, Invoke-Command, remote objects, and local versus remote processing.

Also explained in

Compare how 10 books explain deserialization →

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.