Link to home
Create AccountLog in
Avatar of Joseph Daly
Joseph DalyFlag for United States of America

asked on

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.

ASKER CERTIFIED SOLUTION
Avatar of daveTechSearch
daveTechSearch
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Joseph Daly

ASKER

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.
makes sense.

Try adding this to the beginning of your script:

Add-PSSNapin Microsoft.SharePoint.PowerShell
I think that did it. Thanks
Thanks