If you want to log all the commands executing through powershell to a text file, you can use “strat-transcript” cmdlet
Usage:
Start-Transcript c:your-folder-pathpslogging.txt
This starts logging all the commands you execute from powershell window to text file. This is very help when you are making critical changes.