Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 1.0 » Tee-Object

Tee-Object - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.

Tee-Object

Description
Send input objects to two places

Usage


Options
-inputObject psobject
       The object to tee.
       Enter a variable, command or expression that gets the objects.
	  
   -filePath string
       Save the input object(s) to a file named string.

   -variable string
       Assign the input object(s) to a variable named string.

   CommonParameters:
      -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Example(s)
Get a list of the processes running and send to a file and also the console:

PS C:\>get-process | tee-object -filepath C:\fileA.txt

Get a list of the processes running and send to two files at once:

PS C:\>get-process | tee-object -filepath C:\fileA.txt | out-file C:\fileB.txt

Save a list of processes to a variable (myprocs) then use Tee-Object to save the myprocs to file and also display on the console:

PS C:\>$myprocs = Get-Process |Select-Object processname,handles
PS C:\>Tee-Object -inputObject $myprocs -filepath C:\fileC.txt