Solved

Calling sharepoint powerhsell module from a PS1 file

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

The problems with reply email signatures

Do you wish that you could place an email signature under a reply? Well, unfortunately, you can't. That great Exchange/Office 365 signature you've created will just appear at the bottom of an email chain. What a pain! Is there really no way to solve this? Well, there might be...

Join & Write a Comment

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

757 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

19 Experts available now in Live!

Get 1:1 Help Now