I am writing a PowerShell script to gather general information on our servers. I wrote the script so that it outputs to a file called output.txt via PowerShells Start-Transcript cmdlet. Output works fine. However I just want the output in the file and not displayed on the console.
I have been looking and attempting to see if Start-Transcription can suppress the console output but I have not found anything.
This is a very cut down version of the code I am using-
Start-Transcript -path "Path\To\Output\File.txt"
$servers = Get-Content -path "Path\To\Servers\List\file.txt"
foreach ($server in $servers)
{
net view
net use
net session
}
Stop-Transcript
It all outputs to the file correctly but I just would like it to NOT display the script/command results in the console. If that is possible.
Start-Transcriptcmdlet is not designed to suppress output to the screen. [grin] if you want things quiet, then assign them to a $Var. then, instead of the transcript cmdlets, simply save it to a file directly.Add-Content, but that is a personal pref. ///// as an aside, have you tried using the built in powershell cmdlets to get the info as objects instead of raw, semi-structured text? try looking atGet-Help *net*for some ideas.