February 2019
Intermediate to advanced
626 pages
15h 51m
English
A number of classes in .NET offer Runspace synchronization. This means that an instance of an object can be made accessible from Runspaces that share a common parent.
The most commonly used Runspace-synchronized object is a hashtable. The hashtable is created using the Synchronized static method of the Hashtable type:
$synchronizedHashtable = [Hashtable]::Synchronized(@{ Key = 'Value'})
The synchronized hashtable can be added to an InitialSessionState object and then used within a script or command that is running in a Runspace. The changes made to the hashtable within the runspace are visible outside:
$variableEntry = [System.Management.Automation.Runspaces.SessionStateVariableEntry]::new( 'synchronizedHashtable', ...
Read now
Unlock full access