none
C# invoke powershell script in web service RRS feed

  • Question

  • Hi,

    we need to invoke Powershell script from C# code, if we try from Console App it's working, but if we try from Web Service method it's not working and not seeing any error. 

    Can you please suggest on this.

    Regards,

    Mani

    Monday, August 10, 2020 4:06 PM

All replies

  • Hi smanif123,

    I think that since you are running a web service the security context is different and deny certain action, it depend on the what you are using to host your service, is it IIS or self hosted, also I suggest using a messaging mechanism lets say msmq just as example you can make your web service handles request by sending a message to the queue, in the background you can have a Windows Process processing the queues messages.

    hope it helps!

    Best Regards,

    Mouad.


    Monday, August 10, 2020 7:06 PM
  • Hi smanif123,

    Thank you for posting here.

    IIS doesn't seem to allow anonymous users to run Powershell scripts.

    Someone solved the problem by enabling Windows authentication for the web service, but I'm not sure if it works for you.

    Running Powershell scripts for Exchange in web services

    If this method is useless to you, you can post your question on the ASP.NET forum to get better support about Web services.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, August 11, 2020 1:58 AM
  • Hi,

    Has your issue been resolved?

    If so, please click on the "Mark as answer" option of the reply that solved your question, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 4, 2020 8:58 AM