Wednesday, September 24, 2014

How to setup Powershell in SharePoint 2010 ?

Setting up PowerShell for SharePoint :

PowerShell is setup by default. You will not be able to run a script right off the bat.

Because Microsoft set the default security level to not allow this behavior. 

This is useful because it helps to prevent security issues, and in general practice, it limits the possibility that a beginner makes a serious mistake. 

PowerShell can be very unforgiving. Once a process is started, it is all but impossible to stop it. So be sure to test everything you write thoroughly before executing in a production environment.

If you want to download PowerShell, you can download it from below link:

Microsoft's new name for PowerShell bundled with Windows Remote Management (WinRM) 2.0 and Background Intelligent Transfer Service (BITS) 4.0, is called.

Now, you will be able to run a script, you will need to explicitly allow them, run the following command;
get-executionpolicy

You should see that the policy is set to "restricted". If not then other user has already used your PowerShell.

So to set the policy, you guessed it. Run below command:
set-executionpolicy

Here you can find some choices as listed below with using Powershell :
  • Restricted: Does not load configuration files or run scripts. "Restricted" is the default.
  • AllSigned: Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.
  • RemoteSigned: Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.
  • Unrestricted: Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.
  • Bypass: Nothing is blocked and there are no warnings or prompts.
  • Undefined: Removes the currently assigned execution policy from the current scope. This parameter will not remove an execution policy that is set in a Group Policy scope.