I am working on an ASP.NET Core
project which automatically publishesASP.NET Core
sites with PowerShell script. I need to stop and startIIS Application pools
of the projects that my website publishes on a Windows Server 2012 R2, this PowerShell script works locally on my computer and works fine also under IIS on my computer, but doesn't work on the server under IIS:
Start powershell -verb runas -ArgumentList"-file $stopScriptPath -poolName $poolName"
Here $stopScriptPath
is Stop-WebAppPool
which works only when run as admin:
Start-WebAppPool-Name$poolName.
I know it works with invoke-command with windows default admin credentials, but I can't have default admin password and Web Administration module does not work on other admin accounts.
Is there any other way I can do it?