The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,468 other followers

“A parameter cannot be found that matches parameter name ‘PassThru'” – likely your powershell version is too old

Posted by jpluimers on 2021/09/07

If you get [WayBack] “A parameter cannot be found that matches parameter name ‘PassThru'” as PowerShell error, then likely the PowerShell version is too old to support -PassThru, which likely means you have are running pre-Windows 10 version.

PowerShell 3 (introduced in 2012) added the -PassThru parameter that allowed to chain multiple commands from one list pipe.

Another reason for the error might be that the command you use does not support the -PassThru parameter.

To check which commandlets support -PassThru, use the below command (the output is from a Windows 8.1 machine running PowerShell 4.0).

PS C:\bin> Get-Command -CommandType 8 | ? {$_.Definition -match 'PassThru'}

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Cmdlet          Add-Computer                                       Microsoft.PowerShell.Management
Cmdlet          Add-Content                                        Microsoft.PowerShell.Management
Cmdlet          Add-History                                        Microsoft.PowerShell.Core
Cmdlet          Add-Member                                         Microsoft.PowerShell.Utility
Cmdlet          Add-PSSnapin                                       Microsoft.PowerShell.Core
Cmdlet          Add-Type                                           Microsoft.PowerShell.Utility
Cmdlet          Clear-ItemProperty                                 Microsoft.PowerShell.Management
Cmdlet          Clear-Variable                                     Microsoft.PowerShell.Utility
Cmdlet          Compare-Object                                     Microsoft.PowerShell.Utility
Cmdlet          Copy-Item                                          Microsoft.PowerShell.Management
Cmdlet          Copy-ItemProperty                                  Microsoft.PowerShell.Management
Cmdlet          Disable-PSBreakpoint                               Microsoft.PowerShell.Utility
Cmdlet          Enable-PSBreakpoint                                Microsoft.PowerShell.Utility
Cmdlet          Export-Alias                                       Microsoft.PowerShell.Utility
Cmdlet          Import-Alias                                       Microsoft.PowerShell.Utility
Cmdlet          Import-Module                                      Microsoft.PowerShell.Core
Cmdlet          Invoke-RestMethod                                  Microsoft.PowerShell.Utility
Cmdlet          Invoke-WebRequest                                  Microsoft.PowerShell.Utility
Cmdlet          Move-Item                                          Microsoft.PowerShell.Management
Cmdlet          Move-ItemProperty                                  Microsoft.PowerShell.Management
Cmdlet          New-Alias                                          Microsoft.PowerShell.Utility
Cmdlet          New-ModuleManifest                                 Microsoft.PowerShell.Core
Cmdlet          New-Variable                                       Microsoft.PowerShell.Utility
Cmdlet          Out-GridView                                       Microsoft.PowerShell.Utility
Cmdlet          Pop-Location                                       Microsoft.PowerShell.Management
Cmdlet          Push-Location                                      Microsoft.PowerShell.Management
Cmdlet          Remove-Computer                                    Microsoft.PowerShell.Management
Cmdlet          Remove-PSSnapin                                    Microsoft.PowerShell.Core
Cmdlet          Rename-Computer                                    Microsoft.PowerShell.Management
Cmdlet          Rename-Item                                        Microsoft.PowerShell.Management
Cmdlet          Rename-ItemProperty                                Microsoft.PowerShell.Management
Cmdlet          Restart-Service                                    Microsoft.PowerShell.Management
Cmdlet          Resume-Service                                     Microsoft.PowerShell.Management
Cmdlet          Set-Alias                                          Microsoft.PowerShell.Utility
Cmdlet          Set-Content                                        Microsoft.PowerShell.Management
Cmdlet          Set-Item                                           Microsoft.PowerShell.Management
Cmdlet          Set-ItemProperty                                   Microsoft.PowerShell.Management
Cmdlet          Set-Location                                       Microsoft.PowerShell.Management
Cmdlet          Set-Service                                        Microsoft.PowerShell.Management
Cmdlet          Set-TraceSource                                    Microsoft.PowerShell.Utility
Cmdlet          Set-Variable                                       Microsoft.PowerShell.Utility
Cmdlet          Show-Command                                       Microsoft.PowerShell.Utility
Cmdlet          Start-Process                                      Microsoft.PowerShell.Management
Cmdlet          Start-Service                                      Microsoft.PowerShell.Management
Cmdlet          Stop-Job                                           Microsoft.PowerShell.Core
Cmdlet          Stop-Process                                       Microsoft.PowerShell.Management
Cmdlet          Stop-Service                                       Microsoft.PowerShell.Management
Cmdlet          Suspend-Service                                    Microsoft.PowerShell.Management

After choco install powershell --yes installs PowerShell 5.1, only addes the Set-TimeZone command:

PS C:\bin> Get-Command -CommandType 8 | ? {$_.Definition -match 'PassThru'}

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Add-Computer                                       3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Add-Content                                        3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Add-History                                        3.0.0.0    Microsoft.PowerShell.Core
Cmdlet          Add-Member                                         3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Add-PSSnapin                                       3.0.0.0    Microsoft.PowerShell.Core
Cmdlet          Add-Type                                           3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Clear-ItemProperty                                 3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Clear-Variable                                     3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Compare-Object                                     3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Copy-Item                                          3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Copy-ItemProperty                                  3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Disable-PSBreakpoint                               3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Enable-PSBreakpoint                                3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Export-Alias                                       3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Import-Alias                                       3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Import-Module                                      3.0.0.0    Microsoft.PowerShell.Core
Cmdlet          Invoke-RestMethod                                  3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Invoke-WebRequest                                  3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Move-Item                                          3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Move-ItemProperty                                  3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          New-Alias                                          3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          New-ModuleManifest                                 3.0.0.0    Microsoft.PowerShell.Core
Cmdlet          New-Variable                                       3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Out-GridView                                       3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Pop-Location                                       3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Push-Location                                      3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Remove-Computer                                    3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Remove-PSSnapin                                    3.0.0.0    Microsoft.PowerShell.Core
Cmdlet          Rename-Computer                                    3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Rename-Item                                        3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Rename-ItemProperty                                3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Restart-Service                                    3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Resume-Service                                     3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Set-Alias                                          3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Set-Content                                        3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Set-Item                                           3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Set-ItemProperty                                   3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Set-Location                                       3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Set-Service                                        3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Set-TimeZone                                       3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Set-TraceSource                                    3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Set-Variable                                       3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Show-Command                                       3.1.0.0    Microsoft.PowerShell.Utility
Cmdlet          Start-Process                                      3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Start-Service                                      3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Stop-Job                                           3.0.0.0    Microsoft.PowerShell.Core
Cmdlet          Stop-Process                                       3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Stop-Service                                       3.1.0.0    Microsoft.PowerShell.Management
Cmdlet          Suspend-Service                                    3.1.0.0    Microsoft.PowerShell.Management

Related:

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: