ukkaapie
asked on
Running powershell scripts from ASP.NET
Hi,
I am trying to run a powershell script from an ASP.NET page.
I have configured the application pool to run under a doman account identity but the powershell script appears to be running under the machine account.
When I add $env:username to the powershell script, it returns computername$
Any ideas where I am going wrong?
I am trying to run a powershell script from an ASP.NET page.
I have configured the application pool to run under a doman account identity but the powershell script appears to be running under the machine account.
When I add $env:username to the powershell script, it returns computername$
Any ideas where I am going wrong?
Under what account is you AppPool running?
As Shaun is pointing out.. the scripts are going to run in the context of the AppPool that is running the website. I'm not an IIS expert, (I have some experience with it).. I believe you might be able to request credentials from the user and use those in your powershell scripts. I'm not sure how or if you could capture any kind of passthrough authentication.
Coralon
Coralon
This is do-able as per the example C# WinForm article below states... should be similar for ASP.NET.
Links:
1. https://blogs.msdn.microsoft.com/zainnab/2008/07/26/calling-a-powershell-script-from-your-net-code/
2. http://jeffmurr.com/blog/?p=142
The important thing to do is use the System.Management.Automati on name space instead of calling a command.
Dan
Links:
1. https://blogs.msdn.microsoft.com/zainnab/2008/07/26/calling-a-powershell-script-from-your-net-code/
2. http://jeffmurr.com/blog/?p=142
The important thing to do is use the System.Management.Automati
Dan
ASKER
@Shaun - The application pool is running under a domain account.
@Dan - That namespace is being used to call the script and not a command.
@Dan - That namespace is being used to call the script and not a command.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dan...
Thanks heaps for that. Completely forgot but I had to do that for a website belonging to someone else.
Excellent... all working great now...
Shane
Thanks heaps for that. Completely forgot but I had to do that for a website belonging to someone else.
Excellent... all working great now...
Shane