PowerShell

How to run Child PowerShell Process in PoweShell

 

Hi Guys,

may be you are wondering what is its meaning, it mean how we can use PowerShell with in a PowerShell as a child process

It is very useful when we want to call a cmdlets or script within PowerShell Script.

Syntax

Syntax is Simple type PowerShell following by Curly Braces and in Curly braces you can provide any script, or cmdlet.

PowerShell  { }

for example  open PowerShell console and type the below command:

powershell {Get-ChildItem c:\}

ChildPowerShell process0

How we know that its the above command running as Child Process not as a same process.

okays I have a proof.

Currently there is  only one “PowerShell.exe ”  process is running.[fig.1]

ChildPowerShell process  fig.1

 

now execute our command as let’s see what happens [fig.2]

ChildPowerShell process 2 fig.2

now see below when we execute the script a new child “PowerShell.exe” process starts beneath our old “PowerShell.exe” process and when it done executing it the child process will exit automatically [fig.3]

ChildPowerShell process 3 fig.3

 

hope u like it 🙂

thanks

aman dhally

2 thoughts on “How to run Child PowerShell Process in PoweShell

Comments are closed.