Sunday, 26 January 2014

Redirect Powershell Output To A File - PS1

Powershell scripts can be saved in files with extension ".ps1". Double-click them and the OS will run them in Powershell.

But what if you have a script that outputs a lot of information to the screen and you want it in a more usable form such as a text file that you can send to others?

In DOS, there is a command ">" that let's you do this. There is something similar in Powershell.

Let's say your script is called script.ps1 then you can do:

powershell.exe -File c:\script.ps1 >> C:\outputfile.txt

and it will spit out the output and put into the file called outputfile.txt.

I will show you an example in my next blog post.

No comments:

Post a Comment

Popular Posts