Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a requirement to create a GUI that talks with sharepoint management shell and gives the output then and there.

i tried the solution given here

http://www.codeproject.com/Articles/18229/How-to-run-PowerShell-scripts-from-C

but this runs powershell commands and not spcommands. if i give for example get-spsite instead of get-process in the above code it throws me an error like this

Error in script : The term 'Get-spsite' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

i am using sharepoint 2010, .net 4.5, powershell 3.0(this is just FYI)

Any help is much appreciated.

share|improve this question
1  
FYI SharePoint 2010 doesn't play nice with Powershell 3.0, you may need to specifically target 2.0 - support.microsoft.com/kb/2796733 –  lgaud Oct 15 '13 at 13:20

1 Answer 1

To work with SharePoint using PowerShell you need to add this at the beggining of your script:

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0

Then commands will be available to use.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.