Today, I was writing a script that showed a lot of output in the screen. I then decided that it was a good idea to just save the output to a file as this output will be sent to people via email. I didn't want to use Out-File on every single Write-Output that I wrote. I ended up using Start-Transcript and Stop-Transcript instead. I think it actually worked well.
This is what I used.
Start-Transcript -Path $outputFile -UseMinimalHeader
....
Stop-Transcript
The output file would look like this.
**********************
PowerShell transcript start
Start time: 20240808083029
**********************
Transcript started, output file is C:\Users\WindowsUserID\Downloads\DB_Users_and_Permissions_DBNAME_20240808.txt
....
**********************
PowerShell transcript end
End time: 20240808083033
**********************