[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 808
  • Last Modified:

Calling sharepoint powerhsell module from a PS1 file

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
Joseph Daly
Asked:
Joseph Daly
  • 3
  • 2
1 Solution
 
daveTechSearchCommented:
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
 
Joseph DalyAuthor Commented:
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
 
daveTechSearchCommented:
makes sense.

Try adding this to the beginning of your script:

Add-PSSNapin Microsoft.SharePoint.PowerShell
0
 
Joseph DalyAuthor Commented:
I think that did it. Thanks
0
 
Joseph DalyAuthor Commented:
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

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now