1

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.

1
  • 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 Commented Oct 15, 2013 at 13:20

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.