Cake-Build addin that extends Cake with Powershell commands
- Implemented functionality
- Continuous integration
- Referencing
- Usage
- Example
- TroubleShooting
- Plays well with
- License
- Share the love
- Local / remote scripts
- Script files
- Download and run remote script file
- Script parameters
- Outputting to the cake console
Build server | Platform | Build status |
---|---|---|
AppVeyor | Windows | |
Travis | Linux / MacOS |
Cake.Powershell is available as a nuget package from the package manager console:
Install-Package Cake.Powershell
or directly in your build script via a cake addin directive:
#addin "Cake.Powershell"
#addin "Cake.Powershell"
Task("Powershell-Script")
.Description("Run an example powershell command with parameters")
.Does(() =>
{
StartPowershellScript("Write-Host", args =>
{
args.AppendQuoted("Testing...");
});
});
Task("Powershell-Script-Settings")
.Description("Run an example powershell command with settings and parameters")
.Does(() =>
{
StartPowershellScript("Get-Process", new PowershellSettings()
.SetFormatOutput()
.SetLogOutput()
.WithArguments(args =>
{
args.AppendQuoted("svchost");
}));
});
Task("Powershell-File")
.Description("Run an example powershell script file with parameters")
.Does(() =>
{
StartPowershellFile("../Scripts/Install.ps1", args =>
{
args.Append("Username", "admin")
.AppendSecret("Password", "pass1");
});
});
Task("Powershell-File-Settings")
.Description("Run an example powershell script file with settings and parameters")
.Does(() =>
{
StartPowershellFile("../Scripts/sql.ps1", new PowershellSettings()
.WithModule("sqlps")
.WithArguments(args =>
{
args.Append("Username", "admin")
.AppendSecret("Password", "pass1");
}));
});
Task("Powershell-Remote-Script")
.Description("Run an example powershell command remotely")
.Does(() =>
{
StartPowershellScript("Get-Services", new PowershellSettings()
{
ComputerName = "remote-location",
Username = "admin",
Password = "pass1",
FormatOutput = true,
LogOutput = true
});
});
Task("Powershell-Remote-File")
.Description("Run an example powershell file remotely")
.Does(() =>
{
StartPowershellFile("C:/Scripts/sql.ps1", new PowershellSettings()
{
ComputerName = "remote-location",
Username = "admin",
Password = "pass1",
FormatOutput = true,
LogOutput = true
}.WithArguments(args =>
{
args.Append("task", "do-what-i-say");
}));
});
Task("Powershell-Download")
.Description("Run an example powershell script file after downloading its contents to a local directory")
.Does(() =>
{
StartPowershellDownload("https://chocolatey.org/install.ps1", "C:/Temp/install.ps1", new PowershellSettings());
});
RunTarget("Powershell-Script");
A complete Cake example can be found here.
- Please be aware of the breaking changes that occurred with the release of Cake v0.22.0, you will need to upgrade Cake in order to use Cake.Powershell v0.4.0 or above.
A few pointers for correctly enabling powershell scripting can be found here.
If your looking for a way to trigger cake tasks based on windows events or at scheduled intervals then check out CakeBoss.
Copyright (c) 2015 - 2016 Phillip Sharpe
Cake.Powershell is provided as-is under the MIT license. For more information see LICENSE.
If this project helps you in anyway then please ⭐ the repository.