Solved

Calling sharepoint powerhsell module from a PS1 file

Posted on 2011-03-09
5
781 Views
Last Modified: 2012-05-11
I have created a ps1 file that i want to use to automate the creation of sharepoint 2010 sites etc. The commands themselves work fine when entered through the sharepoint powershell management module, however when i save my commands as a PS1 file and try to execute them I get errors that the commands dont exist.

I know this is due to the differences between the standard powershell and the sharepoint powershell modules. I think I need to call the sharepoint module at the beginning of my PS1 script but I dont know how to do this.

0
Comment
Question by:Joseph Daly
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
daveTechSearch earned 500 total points
ID: 35084903
Have you tried using the Management Shell?.... The Sharepoint module(s) will already be available here:

To access the SharePoint 2010 Management Shell
1.On the Start menu, click All Programs.

2.Click Microsoft SharePoint 2010 Products.

3.Click SharePoint 2010 Management Shell.


http://technet.microsoft.com/en-us/library/ee806878.aspx
0
 
LVL 35

Author Comment

by:Joseph Daly
ID: 35084915
Thanks, I understand that however I am trying to save this as a PS1 script. So when you double click on it it will load the modules necessary.
0
 
LVL 5

Expert Comment

by:daveTechSearch
ID: 35084960
makes sense.

Try adding this to the beginning of your script:

Add-PSSNapin Microsoft.SharePoint.PowerShell
0
 
LVL 35

Author Comment

by:Joseph Daly
ID: 35085014
I think that did it. Thanks
0
 
LVL 35

Author Closing Comment

by:Joseph Daly
ID: 35085021
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question