Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Function Error {
Param([string]$message)
return @{
Type = [ResultType]::Error
Message = $message
}
}
Function Success {
return @{
Type = [ResultType]::Success
}
}
Function Warning {
Param([string]$message)
return @{
Type = [ResultType]::Warning
Message = $message
}
}
Function HandleResult {
Param(
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Hashtable]$result
)
Process {
if ($result.Type -eq [ResultType]::Success) {
Write-Host "Done!" -ForegroundColor Cyan
}
if ($result.Type -eq [ResultType]::Warning) {
Write-Host $result.Message -ForegroundColor Yellow
}
if ($result.Type -eq [ResultType]::Error) {
Write-Host $result.Message -ForegroundColor Red
throw "Deployment can't continue..."
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.