Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions reference/5.1/Microsoft.PowerShell.Utility/Tee-Object.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 12/12/2022
ms.date: 09/17/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/tee-object?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
aliases:
Expand Down Expand Up @@ -37,10 +37,14 @@ Tee-Object [-InputObject <PSObject>] -Variable <String> [<CommonParameters>]

## 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.
The `Tee-Object` cmdlet write output in two directions. 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 in the console.

Internally, `Tee-Object` uses the `Set-Variable` and `Out-File` commands. These commands support the
**WhatIf** parameter. The `Tee-Object` command doesn't support the **WhatIf** parameter. However, if
you wrap `Tee-Object` in a script or function that support the **WhatIf** parameter, `Tee-Object`
passes the state of **WhatIf** to the `Set-Variable` and `Out-File` commands.

## EXAMPLES

Expand Down Expand Up @@ -99,6 +103,31 @@ drive. A pipeline operator (`|`) sends the list to `Tee-Object`, which appends t
AllSystemFiles.txt file and passes the list down the pipeline to the `Out-File` cmdlet, which saves
the list in the `NewSystemFiles.txt file`.

### Example 4: Use `Tee-Object` in a script with the **WhatIf** parameter

The `Tee-Object` command doesn't support the **WhatIf** parameter. However, if you wrap `Tee-Object`
in a script or function that support the **WhatIf** parameter, `Tee-Object` passes the state of
**WhatIf** to the `Set-Variable` and `Out-File` commands it uses internally.

```powershell
PS> function Test-Tee {
[Cmdletbinding(SupportsShouldProcess)]
Param()
$true|tee -Variable b
"Variable `$b is set to '$b'"
}

PS> Test-Tee

True
Variable $b is set to 'True'

PS> Test-Tee -WhatIf
True
What if: Performing the operation "Set variable" on target "Name: b Value: True".
Variable $b is set to ''
```

## PARAMETERS

### -Append
Expand Down
39 changes: 34 additions & 5 deletions reference/7.4/Microsoft.PowerShell.Utility/Tee-Object.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 04/25/2023
ms.date: 09/17/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/tee-object?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
aliases:
Expand Down Expand Up @@ -37,10 +37,14 @@ Tee-Object [-InputObject <PSObject>] -Variable <String> [<CommonParameters>]

## 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.
The `Tee-Object` cmdlet write output in two directions. 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 in the console.

Internally, `Tee-Object` uses the `Set-Variable` and `Out-File` commands. These commands support the
**WhatIf** parameter. The `Tee-Object` command doesn't support the **WhatIf** parameter. However, if
you wrap `Tee-Object` in a script or function that support the **WhatIf** parameter, `Tee-Object`
passes the state of **WhatIf** to the `Set-Variable` and `Out-File` commands.

## EXAMPLES

Expand Down Expand Up @@ -151,6 +155,31 @@ and comparing that string to `$frontMatterPattern`.
Finally, the example prints the names of the files in the folder that have a defined front matter
metadata block.

### Example 5: Use `Tee-Object` in a script with the **WhatIf** parameter

The `Tee-Object` command doesn't support the **WhatIf** parameter. However, if you wrap `Tee-Object`
in a script or function that support the **WhatIf** parameter, `Tee-Object` passes the state of
**WhatIf** to the `Set-Variable` and `Out-File` commands it uses internally.

```powershell
PS> function Test-Tee {
[Cmdletbinding(SupportsShouldProcess)]
Param()
$true|tee -Variable b
"Variable `$b is set to '$b'"
}

PS> Test-Tee

True
Variable $b is set to 'True'

PS> Test-Tee -WhatIf
True
What if: Performing the operation "Set variable" on target "Name: b Value: True".
Variable $b is set to ''
```

## PARAMETERS

### -Append
Expand Down
39 changes: 34 additions & 5 deletions reference/7.5/Microsoft.PowerShell.Utility/Tee-Object.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 04/25/2023
ms.date: 09/17/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/tee-object?view=powershell-7.5&WT.mc_id=ps-gethelp
schema: 2.0.0
aliases:
Expand Down Expand Up @@ -37,10 +37,14 @@ Tee-Object [-InputObject <PSObject>] -Variable <String> [<CommonParameters>]

## 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.
The `Tee-Object` cmdlet write output in two directions. 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 in the console.

Internally, `Tee-Object` uses the `Set-Variable` and `Out-File` commands. These commands support the
**WhatIf** parameter. The `Tee-Object` command doesn't support the **WhatIf** parameter. However, if
you wrap `Tee-Object` in a script or function that support the **WhatIf** parameter, `Tee-Object`
passes the state of **WhatIf** to the `Set-Variable` and `Out-File` commands.

## EXAMPLES

Expand Down Expand Up @@ -151,6 +155,31 @@ and comparing that string to `$frontMatterPattern`.
Finally, the example prints the names of the files in the folder that have a defined front matter
metadata block.

### Example 5: Use `Tee-Object` in a script with the **WhatIf** parameter

The `Tee-Object` command doesn't support the **WhatIf** parameter. However, if you wrap `Tee-Object`
in a script or function that support the **WhatIf** parameter, `Tee-Object` passes the state of
**WhatIf** to the `Set-Variable` and `Out-File` commands it uses internally.

```powershell
PS> function Test-Tee {
[Cmdletbinding(SupportsShouldProcess)]
Param()
$true|tee -Variable b
"Variable `$b is set to '$b'"
}

PS> Test-Tee

True
Variable $b is set to 'True'

PS> Test-Tee -WhatIf
True
What if: Performing the operation "Set variable" on target "Name: b Value: True".
Variable $b is set to ''
```

## PARAMETERS

### -Append
Expand Down
39 changes: 34 additions & 5 deletions reference/7.6/Microsoft.PowerShell.Utility/Tee-Object.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Utility
ms.date: 04/25/2023
ms.date: 09/17/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/tee-object?view=powershell-7.6&WT.mc_id=ps-gethelp
schema: 2.0.0
aliases:
Expand Down Expand Up @@ -37,10 +37,14 @@ Tee-Object [-InputObject <PSObject>] -Variable <String> [<CommonParameters>]

## 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.
The `Tee-Object` cmdlet write output in two directions. 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 in the console.

Internally, `Tee-Object` uses the `Set-Variable` and `Out-File` commands. These commands support the
**WhatIf** parameter. The `Tee-Object` command doesn't support the **WhatIf** parameter. However, if
you wrap `Tee-Object` in a script or function that support the **WhatIf** parameter, `Tee-Object`
passes the state of **WhatIf** to the `Set-Variable` and `Out-File` commands.

## EXAMPLES

Expand Down Expand Up @@ -151,6 +155,31 @@ and comparing that string to `$frontMatterPattern`.
Finally, the example prints the names of the files in the folder that have a defined front matter
metadata block.

### Example 5: Use `Tee-Object` in a script with the **WhatIf** parameter

The `Tee-Object` command doesn't support the **WhatIf** parameter. However, if you wrap `Tee-Object`
in a script or function that support the **WhatIf** parameter, `Tee-Object` passes the state of
**WhatIf** to the `Set-Variable` and `Out-File` commands it uses internally.

```powershell
PS> function Test-Tee {
[Cmdletbinding(SupportsShouldProcess)]
Param()
$true|tee -Variable b
"Variable `$b is set to '$b'"
}

PS> Test-Tee

True
Variable $b is set to 'True'

PS> Test-Tee -WhatIf
True
What if: Performing the operation "Set variable" on target "Name: b Value: True".
Variable $b is set to ''
```

## PARAMETERS

### -Append
Expand Down
Loading