0

I am attempting to call a Powershell function from another Powershell function. The function I am calling has a lot of verbose output and I need to capture them to a file. Since I am calling said function multiple times, I need the verbose outputs appended to the end of the file.

I attempted the following

Invoke-TeardownWorkflow -WorkflowID $i -PostTeardownAction=@{$IPList[$i]="Reconnect-PrimaryNetwork"} 9 >>C:\TeardownLog.log

However, the code didn't work as expected and kept repeating

A positional parameter cannot be found that accepts argument '9'.

The function is source-controlled (so, I can't touch the function.). Also these functions are all part of PSM1 files. The Teardown.log file has some entries prior to the execution of the code mentioned above.

3
  • 1
    ...Well, what is the 9 doing there? Commented Nov 28, 2014 at 11:16
  • try using * instead of 9. @arco444 9 is supposed to be the combined output, allthough i can´t find this in about_redirection (maybe its from an older version?) Commented Nov 28, 2014 at 11:24
  • 9 was accepted in v2, and has been replaced by * in more recent versions. Commented Nov 28, 2014 at 15:36

1 Answer 1

1

You can use 4>

Invoke-TeardownWorkflow -WorkflowID $i -PostTeardownAction=@{$IPList[$i]="Reconnect-PrimaryNetwork"} 4>C:\TeardownLog.log

More about redirection here, here is an extract:

4>        Sends verbose output to    Import-Module * -Verbose 4> Verbose.txt
          the specified file.

4>>       Appends verbose output     Import-Module * -Verbose 4>> Save-Verbose.txt
          to the contents of the 
          specified file.
Sign up to request clarification or add additional context in comments.

3 Comments

Do you have an error? Is the file created? Did you try alternatives such as *>?
Yeah, the error was the same as for with 9 and * - A positional parameter cannot be found that accepts argument '4'. or A positional parameter cannot be found that accepts argument '*'.
Did you put a space between 4 and >? You shouldn't.

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.