Sunday, September 29, 2013

Powershell Introduction

Windows PowerShell is a scripting language which can be used to manage/administer SharePoint server environment.

PowerShell contains variables, assignments, code-blocks, if-statements, loops, functions, etc

Powershell supports the .NET framework.
 

It enables you to pipe anything to anything without having to parse text. You can provide the output of one command as an input to the new set and thus can solve the complex tasks.

A PowerGui Script editor available to create, manage the powershell scripts.It has features like color syntax highlighting, intillisense.

A powershell file has an extension of .ps1

Before you execute any command, you need to enable PowerShell to execute command. You can get the current execution policy by running the following command:

Set-ExecutionPolicy RemoteSigned

Go to Programs -> Microsoft SharePoint 2010 Products -> SharePoint 2010 Management Shell
or Run cmd.exe > type powershell
 

Load the SharePoint snap-in using Add-PSSnapin
 
Add-PSSnapin "Microsoft.SharePoint.PowerShell"

If you are new to powershell, Use Get-Help command. It displays information about PowerShell commands and concepts

You can prepare a ps1 file to perform necessary tasks. Once you prepare the script, you can the run script as below to get the ouput:

Execute the script:

PS> .\test_script.ps1 (enter)


 

No comments:

Post a Comment