Click here to Skip to main content
15,849,494 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Is it possible to execute a PowerShell command on the Server-Side in ASP.net?
Posted
Comments
Sergey Alexandrovich Kryukov 16-Jul-15 18:13pm    
Why? Really, why? I'm just curious.
—SA

1 solution

I doubt it. The server and Web applications are normally executed in a sandboxed environment which blocks the access to the server host's system beyond what is normally needed for Web operation; even the access to the file system is limited by the root directory set up for the site.

For that matter, even normal execution of .ps1 scrip files by a privileged user is by default limited, one would need to load the PowerShell IDE and interactively issue the command granting this permission. This is not related to Web operations but tells the tale.

After all, think at this: PowerShell is, well… powerful. Imagine how huge would be your security threat if you expose its operation to the Web application user. I would strongly advise you just to forget about the thought.

Perhaps is you share with us your ideas and your ultimate goals, you can get more positive advice. For example, if you just need to use WMI, you could simply use using System.Management.Automation;… and… then directly deal with the permissions and possible permission exceptions.

—SA
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900