From a64d3c83af1667deab237ca0a2a775b32b6eba13 Mon Sep 17 00:00:00 2001 From: lksz Date: Sat, 8 May 2021 17:46:33 -0400 Subject: [PATCH] Updated Ansible scripts Cleaner output, with focus on last lines of output by default --- ansible/Invoke-ViaAnsible.ps1 | 2 +- ansible/Update-ViaAnsible.ps1 | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ansible/Invoke-ViaAnsible.ps1 b/ansible/Invoke-ViaAnsible.ps1 index c898e51..9d5936a 100644 --- a/ansible/Invoke-ViaAnsible.ps1 +++ b/ansible/Invoke-ViaAnsible.ps1 @@ -38,7 +38,7 @@ Invoke-Expression $expr | ForEach-Object { Machine = $res[0].Trim(); Status = @($res[1].Trim(), "$($res[2])".Trim()) RunTime = $sw.Elapsed - Output = "$($res[3])".Trim(); + Output = "$($res[3])".Trim() -split '\\n'; }) if( $res.Status -match '^\w+!:' ) { [Console]::ForegroundColor = [ConsoleColor]::Red diff --git a/ansible/Update-ViaAnsible.ps1 b/ansible/Update-ViaAnsible.ps1 index 805ed74..b6eeba2 100644 --- a/ansible/Update-ViaAnsible.ps1 +++ b/ansible/Update-ViaAnsible.ps1 @@ -1,6 +1,10 @@ [CmdletBinding()]param( [string[]]$Remotes = 'All', - [switch]$RawOutput + [switch]$RawOutput, + [switch]$PassThruOnly ) -Invoke-ViaAnsible -Command "Update-OSz -Mode Auto" -Remotes:$($Remotes.ToLower()) -RawOutput:$RawOutput +Invoke-ViaAnsible -Command "Update-OSz -Mode Auto" -Remotes:$($Remotes.ToLower()) -RawOutput:$RawOutput | ForEach-Object { + if( $PassThru ) { return $_ } + $_ | Select-Object Machine, RunTime, @{L='Output';E={$_.Output | Select-Object -last 4}} +}