Title: ScriptBlock and SessionState in PowerShell Authors: MDGRS Factory Category:#articles Tags:#powershell,#coding Number of Highlights: 2 Source URL: https://mdgrs.hashnode.dev/scriptblock-and-sessionstate-in-powershell Date: 2023-05-07 Last Highlighted: 2023-05-07


A PowerShell process has the default Runspace which is the operating environment for the commands invoked by a host. In a Runspace, there is the global SessionState object. When modules are imported to the global SessionState, a new SessionState object is created for each module.


• Do not pass a ScriptBlock that is bound to a Runspace to another Runspace (Thread).