6

Is there a way to invoke and execute a .ps1 file using REST/JSOM?

I am hoping to deploy a SharePoint Hosted App that runs a powershell script on the server.

  • dont think so, but you can call a custom service which will execute the csom code to deploy sharepoint hosted app – Gautam Sheth Jul 4 '17 at 8:52
  • @GautamSheth the sp hosted app should have the provision to invoke and run powershell scripts. So, the options with me are Rest and JSOM. Can you please elaborate? – Swayam Siddha Jul 4 '17 at 8:53
  • i dont think its possible to execute ps1 script from REST/JSOM. You can create a custom webservice(web api) on azure. This service will deploy the sp hosted app using CSOM code. – Gautam Sheth Jul 4 '17 at 9:19
  • did the above mentioned solution work with SharePoint App? – Poornima Aug 8 '17 at 14:39
  • @Poornima with slight alteration, it should – Swayam Siddha Aug 10 '17 at 4:47
4

Yes, You can call your executable powershell scripts *.ps1 using REST api as HTTP GET is supported by all programming language (javascript in your case).

This msdn blog will help you:

Simple HTTP api for Executing PowerShell Scripts

  • Thanks, DvG. Looks promising. I am trying this. Will choose this as answer if it works :) – Swayam Siddha Jul 4 '17 at 9:59

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.