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.

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, privacy policy and cookie policy

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