Powershell: Transcript (Log)
A transcript logs all action of a Powershell session to a text file; good for documenting and archiving.
With Start-Transcript
, you begin a record of the current Powershell session.
After quitting the Powershell session, the recording stops, but you can also stop the recording manually by running Stop-Transcript
.
You can also modify your Powershell profile to start recording automatically every time when you start a Powershell session by adding something similar like this to it:
$LogFolder = "$Home\Documents\WindowsPowerShell\Logs"
Get-Item -Path "$LogFolder\Log-*.txt" | Where {$_.LastWriteTime -lt ((Get-Date).AddDays(-90))} | Remove-Item
Start-Transcript -NoClobber -Append -Path $LogFolder\Log-$(Get-Date -Format yyyy-MM-dd).txt
# ...
# Stop-Transcript
A few words abou the parameters:
- -Path specifies another destination and filename.
- -OutputDirectory specifies the path to a folder(!) in which the transcript is being saved. In this case, the name of the file will automatically be chosen by Powershell.
- -NoClobber indicates that this cmdlet will not overwrite an existing file.
- -Append indicates that the new transcript will be added to the end of an existing file with the specified name.
- -IncludeInvocationHeader indicates that this cmdlet logs the time stamp when commands are run.
Categories
Development (77)Film & Television (54)
How To (63)
Journal (17)
Miscellaneous (4)
News & Announcements (21)
On Software (12)
Projects (26)
Tags
Bluetooth (1)
C++ (11)
Citrix (1)
Clang (1)
CMake (10)
Code (3)
DE (8)
Doxygen (1)
EN (175)
Excel (1)
Filezilla (1)
Firefox (1)
GeSHi (1)
Git (2)
Hugo (2)
JSON (2)
Lua (3)
Mercurial (5)
MTP (2)
Notepad++ (3)
Powershell (23)
PuTTY (1)
Python (5)
Qt (11)
RandFill (15)
RegEx (1)
Remi (2)
RSS (1)
SCons (1)
SIMInfo (7)
Site (2)
SSH (1)
TinyTinyRSS (1)
Using C++ With Lua (2)
Visual Studio (10)
Win32 (2)
Windows (22)
Windows Registry (1)
WordPress (3)
WPD (3)
WPDLib (2)
WPF (1)
XAML (1)
YouTube (1)