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

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s