PowerShell.CreateNestedPowerShell Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a nested powershell within the current instance. Nested PowerShell is used to do simple operations like checking state of a variable while another command is using the runspace.
Nested PowerShell should be invoked from the same thread as the parent PowerShell invocation thread. So effectively the parent Powershell invocation thread is blocked until nested invoke() operation is complete.
Implement PSHost.EnterNestedPrompt to perform invoke() operation on the nested powershell.
public:
System::Management::Automation::PowerShell ^ CreateNestedPowerShell();
public System.Management.Automation.PowerShell CreateNestedPowerShell ();
member this.CreateNestedPowerShell : unit -> System.Management.Automation.PowerShell
Public Function CreateNestedPowerShell () As PowerShell
Returns
Exceptions
- State of powershell instance is not valid to create a nested powershell instance. Nested PowerShell should be created only for a running powershell instance.