HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

Tee-Object — Saves command output in a file or variable and also sends it down the pipeline. Note: This command c

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandsavesclifilevariabletee-objectoutput
windows

Problem

How to use the Tee-Object command: Saves command output in a file or variable and also sends it down the pipeline. Note: This command can only be used through PowerShell. More information: <https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/tee-object>.

Solution

Tee-Object — Saves command output in a file or variable and also sends it down the pipeline. Note: This command can only be used through PowerShell. More information: <https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/tee-object>.

Output processes to a file and to the console:
Get-Process | Tee-Object -FilePath {{path\to\file}}


Output processes to a variable and Select-Object:
Get-Process notepad | Tee-Object -Variable {{proc}} | Select-Object processname,handles

Code Snippets

Output processes to a file and to the console

Get-Process | Tee-Object -FilePath {{path\to\file}}

Output processes to a variable and `Select-Object`

Get-Process notepad | Tee-Object -Variable {{proc}} | Select-Object processname,handles

Context

tldr-pages: windows/Tee-Object

Revisions (0)

No revisions yet.