0

Have the same issue as here: Run PowerShell script from ASP.NET I am trying to run powershell scripts on the server through an asp.net webpage. It works on the local server but does not work remotely. Remotely it returns nothing as if the script worked.

I tried modifying the permissions with icacls.exe

icalc.exe c:\test.ps1 /grant "IIS AppPool\DefaultAppPool:(OI)(CI)F"

This had no effect. When I read what the permissions are:

icalcs c:\test.ps1
    NT AUTHORITY\Authenticated Users:(I)(M)
    NT AUTHORITY\SYSTEM:(I)(F)
    BUILTIN\Administrators:(I)(F)
    BUILTIN\Users:(I)(RX)

I always get the same return even after I try and modify it. Where is IIS AppPool\DefaultAppPool?

Update I have been using a script that just opens notepad for testing. When I run this locally notepad pops up. Remotely nothing seems to happen, but then I noticed in task manager there were tons of instances of notepad running. So it would seem that it is working but not how I expected. The end function I am trying accomplish is to add minimal remote capabilities. I also play movies off of my webserver and it would be nice to be able to remote some functions through my existing web interface. So the scripts would have to run on the current user. I suppose this may be better suited using WCF or another type of architecture, but it would be nice just to use my web interface for everything.

Community
  • 1
  • 1
shredder
  • 11
  • 3
  • Any help? http://msdn.microsoft.com/en-us/library/aa291350(v=vs.71).aspx – mjolinor Feb 07 '14 at 22:42
  • @mjolinor: any chance you can find a newer version of that page? That's a decade old, and readers who follow links within that page will find themselves stuck in the year 2003. – John Saunders Feb 07 '14 at 23:00
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Feb 07 '14 at 23:01
  • What exact OS are you using? – Marco Shaw Feb 08 '14 at 02:33
  • OK, so the editing seems a big wonky with IE11 - check this - http://www.iis.net/learn/manage/configuring-security/application-pool-identities – Marco Shaw Feb 08 '14 at 02:34
  • I am using Windows 7 64-bit. Thanks for the articles, but I am still have some issues please see update. – shredder Feb 10 '14 at 14:17

1 Answers1

0

Make sure that PowerShell script execution has been updated on the remote server to allow script execution. If the web server runs as 32-bit then fire up an x86 PowerShell console on the machine in elevated (admin) mode and execute:

Set-ExecutionPolicy RemoteSigned

If the web page runs as 64-bit then do the same using a 64-bit elevated PowerShell console.

Keith Hill
  • 194,368
  • 42
  • 353
  • 369