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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Describes the parameters that can be used with any cmdlet.
Locale: en-US
ms.date: 07/02/2024
ms.date: 04/24/2025
no-loc: [Debug, Verbose, Confirm]
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
Expand Down Expand Up @@ -471,6 +471,64 @@ At line:1 char:1
+ FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.GetVariableCommand
```

> [!CAUTION]
> There are two known issues with using the **PipelineVariable** parameter in a
> pipeline that includes CimCmdlets or CDXML cmdlets. In the following
> examples, `Get-Partition` is a CDXML function and `Get-CimInstance` is a
> CimCmdlet.

1. CDXML functions use `[CmdletBinding()]`, which allows the
**PipelineVariable** parameter.

```powershell
Get-Partition -pv pvar
```

However, when you use **PipelineVariable** in Windows PowerShell v5.1, you
receive the following error.

```Output
Get-Partition : Cannot retrieve the dynamic parameters for the cmdlet.
Object reference not set to an instance of an object.

At line:1 char:1
+ get-partition -PipelineVariable pvar
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Partition], ParameterBindingException
+ FullyQualifiedErrorId : GetDynamicParametersException,Get-Partition
```

1. When the preceding command is _not_ a CDXML command and the downstream
contains either command type, the **PipelineVariable** remains as the last
accumulated object.

```powershell
Get-CimInstance Win32_DiskDrive -pv pvar |
ForEach-Object {
Write-Host "Before: $($pvar.Index)"
[pscustomobject]@{ DiskNumber = $_.Index }
} |
Get-Partition |
ForEach-Object {
Write-Host "After: $($pvar.Index)"
}
```

Notice that the value of `$pvar` set to the last object in the pipeline for
the second `ForEach-Object` command.

```Output
Before: 1
Before: 2
Before: 0
After: 0
After: 0
After: 0
After: 0
After: 0
After: 0
```

### -ProgressAction

Determines how PowerShell responds to progress updates generated by a script,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Describes the parameters that can be used with any cmdlet.
Locale: en-US
ms.date: 07/02/2024
ms.date: 04/24/2025
no-loc: [Debug, Verbose, Confirm]
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
Expand Down Expand Up @@ -459,6 +459,77 @@ Name Value
temp
```

> [!CAUTION]
> There are two known issues with using the **PipelineVariable** parameter in a
> pipeline that includes CimCmdlets or CDXML cmdlets. In the following
> examples, `Get-Partition` is a CDXML function and `Get-CimInstance` is a
> CimCmdlet.

1. When the first command is a CDXML function and downstream contains either a
CimCmdlet cmdlet or CDXML function, **PipelineVariable** is reset to
`$null`.

```powershell
Get-Partition -pv pvar |
ForEach-Object {
Write-Host "Before: $($pvar.PartitionNumber)"
[pscustomobject]@{Filter = "Index = $($_.DiskNumber)"}
} |
Get-CimInstance Win32_DiskDrive |
ForEach-Object {
Write-Host "After: $($pvar.PartitionNumber)"
}
```

Notice that the value of `$pvar` set to `$null` in the pipeline for the
second `ForEach-Object` command.

```Output
Before: 1
Before: 1
Before: 2
Before: 3
Before: 4
Before: 1
After:
After:
After:
After:
After:
After:
```

1. When the preceding command is _not_ a CDXML command and the downstream
contains either command type, the **PipelineVariable** remains as the last
accumulated object.

```powershell
Get-CimInstance Win32_DiskDrive -pv pvar |
ForEach-Object {
Write-Host "Before: $($pvar.Index)"
[pscustomobject]@{ DiskNumber = $_.Index }
} |
Get-Partition |
ForEach-Object {
Write-Host "After: $($pvar.Index)"
}
```

Notice that the value of `$pvar` set to the last object in the pipeline for
the second `ForEach-Object` command.

```Output
Before: 1
Before: 2
Before: 0
After: 0
After: 0
After: 0
After: 0
After: 0
After: 0
```

### -ProgressAction

Determines how PowerShell responds to progress updates generated by a script,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Describes the parameters that can be used with any cmdlet.
Locale: en-US
ms.date: 07/02/2024
ms.date: 04/24/2025
no-loc: [Debug, Verbose, Confirm]
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.5&WT.mc_id=ps-gethelp
schema: 2.0.0
Expand Down Expand Up @@ -459,6 +459,77 @@ Name Value
temp
```

> [!CAUTION]
> There are two known issues with using the **PipelineVariable** parameter in a
> pipeline that includes CimCmdlets or CDXML cmdlets. In the following
> examples, `Get-Partition` is a CDXML function and `Get-CimInstance` is a
> CimCmdlet.

1. When the first command is a CDXML function and downstream contains either a
CimCmdlet cmdlet or CDXML function, **PipelineVariable** is reset to
`$null`.

```powershell
Get-Partition -pv pvar |
ForEach-Object {
Write-Host "Before: $($pvar.PartitionNumber)"
[pscustomobject]@{Filter = "Index = $($_.DiskNumber)"}
} |
Get-CimInstance Win32_DiskDrive |
ForEach-Object {
Write-Host "After: $($pvar.PartitionNumber)"
}
```

Notice that the value of `$pvar` set to `$null` in the pipeline for the
second `ForEach-Object` command.

```Output
Before: 1
Before: 1
Before: 2
Before: 3
Before: 4
Before: 1
After:
After:
After:
After:
After:
After:
```

1. When the preceding command is _not_ a CDXML command and the downstream
contains either command type, the **PipelineVariable** remains as the last
accumulated object.

```powershell
Get-CimInstance Win32_DiskDrive -pv pvar |
ForEach-Object {
Write-Host "Before: $($pvar.Index)"
[pscustomobject]@{ DiskNumber = $_.Index }
} |
Get-Partition |
ForEach-Object {
Write-Host "After: $($pvar.Index)"
}
```

Notice that the value of `$pvar` set to the last object in the pipeline for
the second `ForEach-Object` command.

```Output
Before: 1
Before: 2
Before: 0
After: 0
After: 0
After: 0
After: 0
After: 0
After: 0
```

### -ProgressAction

Determines how PowerShell responds to progress updates generated by a script,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Describes the parameters that can be used with any cmdlet.
Locale: en-US
ms.date: 07/02/2024
ms.date: 04/24/2025
no-loc: [Debug, Verbose, Confirm]
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters?view=powershell-7.6&WT.mc_id=ps-gethelp
schema: 2.0.0
Expand Down Expand Up @@ -459,6 +459,77 @@ Name Value
temp
```

> [!CAUTION]
> There are two known issues with using the **PipelineVariable** parameter in a
> pipeline that includes CimCmdlets or CDXML cmdlets. In the following
> examples, `Get-Partition` is a CDXML function and `Get-CimInstance` is a
> CimCmdlet.

1. When the first command is a CDXML function and downstream contains either a
CimCmdlet cmdlet or CDXML function, **PipelineVariable** is reset to
`$null`.

```powershell
Get-Partition -pv pvar |
ForEach-Object {
Write-Host "Before: $($pvar.PartitionNumber)"
[pscustomobject]@{Filter = "Index = $($_.DiskNumber)"}
} |
Get-CimInstance Win32_DiskDrive |
ForEach-Object {
Write-Host "After: $($pvar.PartitionNumber)"
}
```

Notice that the value of `$pvar` set to `$null` in the pipeline for the
second `ForEach-Object` command.

```Output
Before: 1
Before: 1
Before: 2
Before: 3
Before: 4
Before: 1
After:
After:
After:
After:
After:
After:
```

1. When the preceding command is _not_ a CDXML command and the downstream
contains either command type, the **PipelineVariable** remains as the last
accumulated object.

```powershell
Get-CimInstance Win32_DiskDrive -pv pvar |
ForEach-Object {
Write-Host "Before: $($pvar.Index)"
[pscustomobject]@{ DiskNumber = $_.Index }
} |
Get-Partition |
ForEach-Object {
Write-Host "After: $($pvar.Index)"
}
```

Notice that the value of `$pvar` set to the last object in the pipeline for
the second `ForEach-Object` command.

```Output
Before: 1
Before: 2
Before: 0
After: 0
After: 0
After: 0
After: 0
After: 0
After: 0
```

### -ProgressAction

Determines how PowerShell responds to progress updates generated by a script,
Expand Down