Created
March 30, 2016 07:44
-
-
Save msnelling/751d5dfbb8f360b40f9fa7d621295a4f to your computer and use it in GitHub Desktop.
Strip ANSI codes from Terraform output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Remove-ANSICodes | |
{ | |
param([string][Parameter(ValueFromPipeline=$true)]$String) | |
$String -replace '\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]', '' | |
} | |
function Run-Command | |
{ | |
param([string]$Command) | |
Get-RemoteSettings | |
Write-Output "Running $Command..." | |
$Cmd = "terraform $Command" | |
& ([ScriptBlock]::Create($Cmd)) | Out-String | Remove-ANSICodes | |
if ($LASTEXITCODE -ne 0) | |
{ | |
throw "Error executing command: $Cmd" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment