Guy recommends :
Free Permissions
Analyzer Tool

Solarwinds Free Download of Permissions Analyzer

View the effective permissions for a folder or shared drive. Free download try it now!


PowerShell 3.0 -PassThru

PowerShell 3 -PassThru Parameter PowerShell PassThru  Version 3.0

PowerShell' s -PassThru parameter has found signficantly more uses in PowerShell 3.0.

In a nutshell -PassThru shows you the results of a command that would otherwise be silent.

 ♦

Example 1: Out-GridView -PassThruPowerShell 3.0 Passthru Parameter

Let us take this example where we are using PowerShell 3.0 to display the processes.

Get-Process Out-GridView -PassThru 

The benefit of the -PassThru parameter comes when you select rows with the mouse, and then click OK.  The result is that PowerShell refreshes the output. 

Take the screenshot to the right where I have selected just 5 rows,  dlhost, LogonUI, lsass, MsMpEng and SearchIndex.  When I pressed ' OK' , the result was a display with just those 5 rows.

Result of -PassThru and pressing ' OK'

PowerShell 3.0 Out-GridView Passthru Parameter

Guy Recommends: Free WMI Monitor for PowerShellSolarwinds Free WMI Monitor for PowerShell

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft's operating systems.  Fortunately, SolarWinds have created a Free WMI Monitor so that you can discover these gems of performance information, and thus improve your PowerShell scripts.

Take the guess work out of which WMI counters to use when scripting the operating system, Active Directory, or Exchange Server. Give this WMI monitor a try - it's free.

Download your free copy of WMI Monitor

Other Examples of PowerShell PassThru

To see the full list of PowerShell PassThru cmdlets try this:

Clear-host
Get-Command | Where {$_.parameters.keys -Contains "PassThru" `
-And $_.CommandType -Contains "Cmdlet"} |
Ft Name, CommandType -AutoSize

Note 1: Parameters.Keys is the crucial property.

Cmdlets for further study of PowerShell -PassThru

Simple Example of -PassThru

Here is an example where you want to rename a Windows computer.

# PowerShell 3.0 Rename-Computer with -PassThru
$Old ="OriginalName"
$New ="GuyServer"
Rename-Computer -NewName $New -ComputerName $Old `
-PassThru -WhatIf

Note 2: To get this working you need to change $Old to the value of your machine; don't worry the -WhatIf will stop this actually renaming this computer.

See more on Rename-Computer »

Launching PowerShell v 3.0PowerShell 3.0

This is how to get started from the Metro user interface in Windows 8.

  • From anywhere in the Metro UI, press the ' p' key.  You should see a list of the programs and Apps beginning with ' p' .
  • At this point you could ' Pin' the ' Windows PowerShell ISE' by right-clicking and selecting ' Pin' at the bottom right of the screen.
  • Incidentally, I prefer the GUI (ISE) version to the plain command line Windows PowerShell.
  • I like to drag the PowerShell ISE tile to the left of my screen because it' s one of the most important Windows 8 Tiles that use.

See more of what's new in PowerShell v 3.0 »

Summary of PowerShell 3.0 PassThru

The best way to learn about PowerShell's -PassThru parameter is by experimenting with examples such as Stop-Process or Out-GridView.

If you like this page then please share it with your friends

 


See more Microsoft PowerShell output tutorials:

PShell Home   • Out-GridView   • PowerShell Splatting   • Read-Host   • Write-Host   • ConvertTo-Html

Export-CSV   • Import-CSV   • PowerShell Write-Progress   • PowerShell Measure-Command

PowerShell 3 -PassThru   • PowerShell 3.0 Redirection   • ConvertFrom-Csv   • Free CSV Import Tool

Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.

 

 *


Custom Search

Site Home

Guy Recommends: SolarWinds' NPM - Review of Orion NPM
Network Performance Monitor

SolarWinds' performance monitor is designed for detecting network outages, making it easy to see what's working, and what needs your attention.

This utility guides you through creating network maps; it also helps identifying whether the root cause is faulty equipment, or resource overload. Give NPM a try.

Download a free trial of Network Performance Monitor

Article by: Guy Thomas Copyright © 1999-2014 Computer Performance LTD All rights reserved.

Please report any broken link, or an error to: