Click here to Skip to main content
15,878,945 members
Home / Discussions / ASP.NET
   

ASP.NET

 
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 
SuggestionRe: server side editor Pin
Richard MacCutchan25-Jul-12 22:42
mveRichard MacCutchan25-Jul-12 22:42 
GeneralRe: server side editor Pin
dcof26-Jul-12 6:07
dcof26-Jul-12 6:07 
GeneralRe: server side editor Pin
Richard MacCutchan26-Jul-12 6:23
mveRichard MacCutchan26-Jul-12 6:23 
Questionprevent to copy my web pge Pin
Elham M24-Jul-12 21:28
Elham M24-Jul-12 21:28 
AnswerRe: prevent to copy my web pge Pin
Bernhard Hiller24-Jul-12 21:36
Bernhard Hiller24-Jul-12 21:36 
GeneralRe: prevent to copy my web pge Pin
Elham M24-Jul-12 21:51
Elham M24-Jul-12 21:51 
AnswerRe: prevent to copy my web pge Pin
StianSandberg24-Jul-12 23:36
StianSandberg24-Jul-12 23:36 
GeneralRe: prevent to copy my web pge Pin
Elham M25-Jul-12 22:21
Elham M25-Jul-12 22:21 
GeneralRe: prevent to copy my web pge Pin
StianSandberg25-Jul-12 22:31
StianSandberg25-Jul-12 22:31 
GeneralRe: prevent to copy my web pge Pin
Elham M26-Jul-12 1:18
Elham M26-Jul-12 1:18 
AnswerRe: prevent to copy my web pge Pin
StianSandberg26-Jul-12 1:52
StianSandberg26-Jul-12 1:52 
GeneralRe: prevent to copy my web pge Pin
RamShankarMCA26-Jul-12 2:12
RamShankarMCA26-Jul-12 2:12 
GeneralRe: prevent to copy my web pge Pin
Elham M26-Jul-12 2:55
Elham M26-Jul-12 2:55 
GeneralRe: prevent to copy my web pge Pin
Pete O'Hanlon26-Jul-12 3:00
mvePete O'Hanlon26-Jul-12 3:00 
QuestionGetting "Index was out of range" error.. Pin
Diana Tsilidi24-Jul-12 9:06
Diana Tsilidi24-Jul-12 9:06 
AnswerRe: Getting "Index was out of range" error.. Pin
jkirkerx24-Jul-12 10:20
professionaljkirkerx24-Jul-12 10:20 

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.