c#.net remote powershell for iis -


hi have following bit of code

 //set exchange server name         var exchangesrv = "ex1.iah.ac.uk";           // initialize powershell engine         var shell = powershell.create();          // add script powershell object         shell.commands.addscript("invoke-command -computername hostname.example.com -scriptblock{get-alias}");          // execute script         var results = shell.invoke();           input.datasource = results;         input.databind(); 

so want invoke power shell command , "input" list box object populating

but when run on iis server not work, think because iis application not running account admin on remote server trying run command against. can 1 resolving this. how can webpage call invoke command right credentials?

edit
decided create profile on web server means when account using opens power-shell exchange module loaded. don't see loading when using following code

using (var powershell = powershell.create())         {             //powershell.runspace = runspace;               // add script powershell object             //powershell.addscript("get-alias");             powershell.addscript("get-dynamicdistributiongroup");               // execute script             var results = powershell.invoke();               input.datasource = results;             input.databind(); 

so should happening power shell runs locally on web server, need load profile cant see why not doing it. there command force load moduel.

in end impersonating , invoking did not trick (i have used invoke did not want credentials in code)

i found had change properties on application pool , worked fine.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -