The Most Important PowerShell Snippet You Will See Today
Don’t worry about what it does, just cut and paste it.
New-Item -ItemType directory -Path $homeDocumentsWindowsPowerShell Write-Output "Start-Transcript" | Out-File $PROFILE
Just kidding! This is a little snippet of PowerShell code that will set it up so that every time you launch PowerShell it will automatically create a transcript of the session. That way if something goes wrong or unexpectedly right you can look at the transcript later. It also means if a co-worker goes in and breaks stuff with PowerShell without telling you, there is a transcript of what they did.
Here is what it does:
New-Item -ItemType directory -Path $homeDocumentsWindowsPowerShell just creates a new directory in the users Documents folder called WindowsPowerShell.
Write-Output "Start-Transcript" | Out-File $PROFILE just writes the cmdlet Start-Transcript into a file named $PROFILE. PowerShell is hard wired to process this $PROFILE and run whatever commands are in it as a starts.
So that is it, easy but very useful.