PowerShell Logo Small

Tee-Object



This is the built-in help made by Microsoft for the command 'Tee-Object', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Saves command output in a file or variable and also sends it down the pipeline.

SYNTAX


Tee-Object [-FilePath] <String> [-Append] [-InputObject <PSObject>] [<CommonParameters>]
Tee-Object [-InputObject <PSObject>] -LiteralPath <String> [<CommonParameters>]
Tee-Object [-InputObject <PSObject>] -Variable <String> [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Tee-Object cmdlet redirects output, that is, it sends the output of a command in two directions (like the letter "T"). It stores the
output in a file or variable and also sends it down the pipeline. If Tee-Object is the last command in the pipeline, the command output is
displayed at the prompt.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkID=113417
Select-Object
about_Redirection

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>get-process | tee-object -filepath C:\Test1\testfile2.txt
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
83 4 2300 4520 39 0.30 4032 00THotkey
272 6 1400 3944 34 0.06 3088 alg
81 3 804 3284 21 2.45 148 ApntEx
81 4 2008 5808 38 0.75 3684 Apoint
...



This command gets a list of the processes running on the computer and sends the result to a file. Because a second path is not specified, the
processes are also displayed in the console.








-------------------------- EXAMPLE 2 --------------------------

PS C:\>get-process notepad | tee-object -variable proc | select-object processname,handles
ProcessName Handles
----------- -------
notepad 43
notepad 37
notepad 38
notepad 38



This command gets a list of the processes running on the computer and sends the result to a variable named "proc". It then pipes the resulting
objects along to Select-Object, which selects the ProcessName and Handles property. Note that the $proc variable includes the default
information returned by Get-Process.








-------------------------- EXAMPLE 3 --------------------------

PS C:\>get-childitem –path D: –file –system –recurse | tee-object –file c:\test\AllSystemFiles.txt –append | out-file
c:\test\NewSystemFiles.txt



This command saves a list of system files in a two log files, a cumulative file and a current file.

The command uses the Get-ChildItem cmdlet to do a recursive search for system files on the D: drive. A pipeline operator (|) sends the list to
Tee-Object, which appends the list to the AllSystemFiles.txt file and passes the list down the pipeline to the Out-File cmdlet, which saves
the list in the NewSystemFiles.txt file.