Hello
When running a PowerShell script using Start-Transcript with in the script, is it possible stop the console output once Start-Transcript is running.
I cannot use powershell.exe -file myfile.ps1 2> C:\logfile.txt
or
powershell.exe -file myfile.ps1 2>&1 C:\logfile.txt
As the name of the log file is created witin myscript.ps1 and is different everytime.
I have gotten around the issue thus far by creating a little function like so, then sending output to the function for logging.
function log {Param($message)
$message | out-file -FilePath $logfilename -append
{
log $(
"Some text"
get-service
$Disk = [wmi]'Win32_LogicalDisk="c:"'
$Disk.FreeSpace
)
However this is a bit tedious and I simply wanted a Start and Stop Transcript at the start and end of the script file with no console output.
Any Advice most welcome
Thanks all
Ernie