.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
I am glad that you solve your issue with your self.
I request you to mark the helpful suggestion as an answer. This will help other people who face the same issue.
Thank you for understanding.
Regards,
Jalpa.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
29 Posts
Asp page is not running the Powershell script uisng Invoke-command (script Block)
Jun 01, 2019 03:01 PM|Manusan|LINK
please help if there is any other way i can use the Invoke-command with script block in ASP page
My powershell script contains , Invoke-command with Script block. It is not running when it executed by ASP page.
i have checked the permission and i am executing the asp page using admin access.
PS script working fine when i run manually and without Invoke-commad , ASP page is able to call powershell script.
My asp page
string sourceFile = Server.MapPath("/test1.ps1");
// create Powershell runspace
var shell = PowerShell.Create();
shell.Commands.AddScript(@"D:\Inetpub\wwwroot\test1.ps1");
var results = shell.Invoke();
My PS script looks like below
Invoke-Command -ComputerName $Computername -ScriptBlock {get-childitem IIS:\sites\* }
</div>
1616 Posts
Re: Asp page is not running the Powershell script uisng Invoke-command (script Block)
Jun 03, 2019 05:34 AM|Jalpa Panchal|LINK
Hi Manoj,
Did you run "Import-Module WebAdministration" command?
You could also try to run below command:
Regards,
Jalpa
29 Posts
Re: Asp page is not running the Powershell script uisng Invoke-command (script Block)
Jun 20, 2019 02:47 AM|Manusan|LINK
Issue fixed by changing IIS application pool identity.
1616 Posts
Re: Asp page is not running the Powershell script uisng Invoke-command (script Block)
Jun 20, 2019 05:49 AM|Jalpa Panchal|LINK
Hi,
I am glad that you solve your issue with your self.
I request you to mark the helpful suggestion as an answer. This will help other people who face the same issue.
Thank you for understanding.
Regards,
Jalpa.