Friday, May 8, 2020

PowerShell Passthru Parameter




There are many Windows PowerShell cmdelts that simply work, and they do not return any data.
Here with the Passthru parameter, PowerShell returns the output in the console.

Here I simply use "Start-Process notepad", It started notepad process but did not return the Output
to the console.

PS D:\VS Codes\C\myproject1> Start-Process notepad       
PS D:\VS Codes\C\myproject1>


Now I will use "PassThru" Parameter, Let's See .

PS D:\VS Codes\C\myproject1> Start-Process notepad -PassThru

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
      1       2      520        196       0.16  23436   1 notepad

Here It started the the Process Notepad, and gave me the output of the execution of command .

Note: You want to know how many Windows PowerShell cmdlets have "passthru" patameter

Get-Command -CommandType 8 | where {$_.definition -match ‘passthru’}

No comments:

Post a Comment

Featured post

System-preferred multifactor authentication (MFA)

Popular Posts