SIGN UP MEMBER LOGIN:    
ARTICLE

How to Run a Power Shell Script in SharePoint 2010

Posted by Destin joy Articles | SharePoint October 27, 2010
In this article I am showing you how to execute power shell scripts.
Reader Level:

In this article I am showing you how to execute power shell scripts. It is useful if you want to do the same set of command regularly. You don't have to type the entire command again just run the script as I shown below

Here I am taking the example of creating a site collection using power shell I already have an article for it Please find the article url below


The command to create a site collection is

$template = Get-SPWebTemplate "STS#0"
New-SPSite -Url "your Site collection URL" -OwnerAlias "domain\user" -Template $template
  1. First step is to copy your script to a note pad and save as with .ps1 extension

  2. In my case I saved the script as SiteCollection.PS1 and saved in my D drive under the folder Script. Now we have to open the power shell.

  3. On the Start menu, click All Programs.

  4. Click Microsoft SharePoint 2010 Products.

  5. Click SharePoint 2010 Management Shell.

  6. At the Windows Power Shell command prompt type the following command: 

    1.gif

  7. You will get a Power shell command prompt like below

    2.gif

  8. The command to run Power shell script is 

    &"D:\Script\siteCollection.ps1"

  9. Please find below the script in action

    3.gif

Login to add your contents and source code to this article
share this article :
post comment
 

Yes it is

Posted by Destin joy Nov 08, 2010

Thankx for sharing this .It is easy to execute daily and repeated jobs

Posted by Ryan John Nov 08, 2010
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor