PowerShell – few tips and tricks


PowerShell 3.0.0 requires .Net framework 3.5.1 otherwise you will encounter error but it will appear like a problem with the script.

  • Install .Net framework 3.5.1 from the server manager.
  • Always run PowerShell as run as administrator.
  • By default, we cannot execute scripts in PowerShell. For the first time, we have to enable Script execution through below command:
set-executionpolicy remotesigned
  • Resolve STA error

STA error

Warning: ThisĀ  script must be run in PowerShell started using -STA switch!

Script will attempt to open PowerShell in STA and run re-run script.

To resolve this issue, issue the below command and then execute the command you want to:

powershell -STA