0

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Then what would be the solution to run it on PowerShell 2.o ?
Change the code so that append will not be necessary, or use other cmdlet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.