Aadi ch
Aadi ch

Reputation: 1

Facing error while executing the command in PowerShell 2.0 while working fine in PowerShell 3 adn above

I am executing following code but facing error in PowerShell 2.0 while code works fine in latest version, please help is there any Snapin to solve this or any other solution except updating the PowerShell. Thanks in advance.

Code:  
  Write-Output $a |Tee-Object -FilePath $fileName 
  Write-Output("Please wait components deletion is in progress")|Tee-Object -FilePath $fileName -Append 

Error:
    Tee-Object : A parameter cannot be found that matches parameter name 'Append'.
    At line:1 char:102
  + Write-Output("Please wait components deletion is in progress")|Tee- Object -FilePath $fileName -Append
+ CategoryInfo          : InvalidArgument: (:) [Tee-Object], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.TeeObjectCommand

Upvotes: 0

Views: 230

Answers (1)

Andrey Marchuk
Andrey Marchuk

Reputation: 13483

It's very simple. Tee-object has no -Append in PS 2.0. Even, MSDN page mentions this cmdlet as of PS 3.0: https://technet.microsoft.com/en-us/library/hh849937(v=wps.640).aspx

Upvotes: 1

Related Questions