Solved

Calling sharepoint powerhsell module from a PS1 file

Posted on 2011-03-09
5
770 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

813 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now