Summary: Cloud & Datacenter Management MVP, Thomas Rayner, shows how to easily send data to the output of a script.
How can I use Windows PowerShell to send the same data that I’m writing to a file to the standard output of my script?
In Windows PowerShell 5.0, use Tee-Object, for example:
PS C:\WINDOWS\system32> Tee-Object -InputObject ‘Some text’ -FilePath ‘C:\temp\some file.txt’
Some text
PS C:\WINDOWS\system32> Get-Content -Path ‘C:\temp\some file.txt’
Some text
0 comments