I'm switching from Psake build tool to Cake (https://cakebuild.net/). I'm creating a scripts for quite big solution (30+ projects) with (currently) 9 different deploys. In Psake it was trivial to call PowerShell commands, since entire script has been running in powershell.
But now I have a problem. I have to call some commands that are running in PS, but I can't find a way to execute them.
Some examples:
taskkill /IM iisexpress.exe
Invoke-Command -ComputerName <testing server> -ScriptBlock {import-module WebAdministration; Stop-Website <'name of website'>}
Invoke-Command -ComputerName <testing server> -ScriptBlock {import-module WebAdministration; Start-Website <'name of website'>}
I've tried with StartAndReturnProcess (example: StartAndReturnProcess("taskkill /IM iisexpress.exe");), but without success. I've also found Cake.IIS plugin, which would probbably solve my issues with starting and stopping IIS, but there are also smoe other PS commands that I'd like to invoke.
Is it possible to simple call a PowerShell command from Task? Something like this:
Task("DoSomeMagic")
.Does(() =>
{
ExecutePowerShellCommad("taskkill /IM iisexpress.exe");
ExecutePowerShellCommad("Invoke-Command -ComputerName <testing server> -ScriptBlock {import-module WebAdministration; Stop-Website <'name of website'>}");
//ToDo: other magic
});
Thanx for any answer and best regards, Martin