Solved

Calling sharepoint powerhsell module from a PS1 file

Posted on 2011-03-09
5
785 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

This article explains how to install and use the NTBackup utility that comes with Windows Server.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

734 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