Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Add this to your Powershell profile, which is a PS1 file located at "C:\Users\{username}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"
- # Each time you exit Powershell, the commands you used will be saved in a PS1 file.
- # Change C:\path\to\file to wherever you want the PS1 file to be saved.
- # The Register-EngineEvent and Get-History lines must each be on a single line.
- Register-EngineEvent PowerShell.Exiting {$timestamp = Get-Date -Format o | foreach {$_ -replace ":", "."}
- Get-History | Foreach-Object { $_. CommandLine } > C:\path\to\file\$timestamp.ps1}
Advertisement
Add Comment
Please, Sign In to add comment