Click here to Skip to main content
15,912,457 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionSQL QUERY Pin
rock_monu26-Jul-12 20:04
rock_monu26-Jul-12 20:04 
AnswerRe: SQL QUERY Pin
Sandeep Mewara26-Jul-12 21:14
mveSandeep Mewara26-Jul-12 21:14 
AnswerRe: SQL QUERY Pin
vvashishta1-Aug-12 3:38
vvashishta1-Aug-12 3:38 
AnswerRe: SQL QUERY Pin
Vijay Selvaraj27-Aug-12 0:23
Vijay Selvaraj27-Aug-12 0:23 
QuestionIntelligencia.UrlRewriter Pin
Jassim Rahma26-Jul-12 10:43
Jassim Rahma26-Jul-12 10:43 
AnswerRe: Intelligencia.UrlRewriter Pin
Deflinek30-Jul-12 4:53
Deflinek30-Jul-12 4:53 
Questionbest way to url rewrite Pin
Jassim Rahma26-Jul-12 8:25
Jassim Rahma26-Jul-12 8:25 
AnswerRe: best way to url rewrite PinPopular
fjdiewornncalwe26-Jul-12 9:12
professionalfjdiewornncalwe26-Jul-12 9:12 
GeneralRe: best way to url rewrite Pin
Jassim Rahma26-Jul-12 9:35
Jassim Rahma26-Jul-12 9:35 
GeneralRe: best way to url rewrite Pin
jkirkerx26-Jul-12 12:35
professionaljkirkerx26-Jul-12 12:35 
Questionconboxbox in formview control Pin
rachel_m26-Jul-12 6:45
rachel_m26-Jul-12 6:45 
Questionjavascript in web app Pin
rachel_m26-Jul-12 6:42
rachel_m26-Jul-12 6:42 
GeneralRe: javascript in web app Pin
R. Giskard Reventlov26-Jul-12 7:12
R. Giskard Reventlov26-Jul-12 7:12 
GeneralRe: javascript in web app Pin
Paul Conrad13-Sep-12 9:09
professionalPaul Conrad13-Sep-12 9:09 
Questionrange validator 2010 Pin
dcof26-Jul-12 6:07
dcof26-Jul-12 6:07 
GeneralRe: range validator 2010 Pin
jkirkerx26-Jul-12 12:44
professionaljkirkerx26-Jul-12 12:44 
Questionajax calendar control only render sundays Pin
amit sahu2026-Jul-12 0:08
amit sahu2026-Jul-12 0:08 
QuestionSQL query result sent to aspx page to be used by Jquery Pin
zapovjednik25-Jul-12 21:59
zapovjednik25-Jul-12 21:59 
AnswerRe: SQL query result sent to aspx page to be used by Jquery Pin
ashjassi17-Aug-12 2:50
ashjassi17-Aug-12 2:50 
AnswerRe: SQL query result sent to aspx page to be used by Jquery Pin
ashjassi17-Aug-12 2:51
ashjassi17-Aug-12 2:51 
QuestionHow to user Update Progress Bar in Master page and in aspx page Pin
sandeep_ravula25-Jul-12 21:11
sandeep_ravula25-Jul-12 21:11 
AnswerRe: How to user Update Progress Bar in Master page and in aspx page Pin
Vani Kulkarni26-Jul-12 3:11
professionalVani Kulkarni26-Jul-12 3:11 
GeneralRe: How to user Update Progress Bar in Master page and in aspx page Pin
sandeep_ravula19-Aug-12 3:10
sandeep_ravula19-Aug-12 3:10 
GeneralSome PowerShell scripts fail when executed from ASP.NET site Pin
Tyson326425-Jul-12 20:19
Tyson326425-Jul-12 20:19 
Hello,
I was wondering if anyone has any input or guidance in why some PS cmdlets won't work on remote computers when executing a script file from an ASP.NET site.

These scripts work from PS console on server1 to the Spooler service on server2 and also work if the script is run via ASP.NET on itself.

Invoke-Command -ComputerName "Server2" -scriptblock {Stop-Service -Name "Spooler" -Force}


However, through the ASP.NET site it doesn't work. There are no errors or any output that I can see.
I was able to get around this by using the -Credential switch. But this requires me to hard code the credentials which I do not want to do.

$username = Get-Content "C:\inetpub\wwwroot\Scripts\_un.txt"
$password = Get-Content "C:\inetpub\wwwroot\Scripts\_pw.txt"
$password = $password | ConvertTo-SecureString -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password

Invoke-Command  -ComputerName "Server2" -Credential $cred -scriptblock {gwmi win32_service -filter "Name='Spooler'" | Stop-Service -Force}

Invoke-Command  -ComputerName "Server2" -Credential $cred -scriptblock {Stop-Service -Name "Spooler" -Force}


This is how I'm executing the PS scripts in ASP.NET C#.
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
var shell = PowerShell.Create();
string filePath = Server.MapPath("PS/StopSpooler.ps1");
StreamReader reader = File.OpenText(filePath);
string powerShellCode = reader.ReadToEnd();
reader.Close();
shell.Commands.AddScript(powerShellCode);
var results = shell.Invoke();



My site is very basic and is using Windows authentication. It is also being launched while logged in as a domain administrator.

Thanks!

modified 26-Jul-12 3:07am.

Questionserver side editor Pin
dcof25-Jul-12 17:53
dcof25-Jul-12 17:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.