Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 36188

PowerTip: Easily Send Output to Both the PowerShell Console and a Variable

$
0
0

Summary: Learn how to send output to both the Windows PowerShell console and to a variable.

Hey, Scripting Guy! Question How can I easily send Windows PowerShell output to both the console and to a variable?

Hey, Scripting Guy! Answer Use the Tee-Object cmdlet and specify a variable name, as shown here.

PS C:\> gps | select name -Last 1 | Tee-Object -Variable a

Name

----

ZeroConfigService

 

PS C:\> $a

Name

----

ZeroConfigService

>


Viewing all articles
Browse latest Browse all 36188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>