diff --git a/ansible/Invoke-ViaAnsible.ps1 b/ansible/Invoke-ViaAnsible.ps1 index 9d5936a..4a95f87 100644 --- a/ansible/Invoke-ViaAnsible.ps1 +++ b/ansible/Invoke-ViaAnsible.ps1 @@ -40,11 +40,14 @@ Invoke-Expression $expr | ForEach-Object { RunTime = $sw.Elapsed Output = "$($res[3])".Trim() -split '\\n'; }) + $res.PSObject.TypeNames.Insert(0,"AnsibleOutput") if( $res.Status -match '^\w+!:' ) { [Console]::ForegroundColor = [ConsoleColor]::Red } else { [Console]::ForegroundColor = [ConsoleColor]::Yellow } + $res } + [Console]::ForegroundColor = $SaveConsoleColor diff --git a/ansible/Update-ViaAnsible.ps1 b/ansible/Update-ViaAnsible.ps1 index b6eeba2..257b4cc 100644 --- a/ansible/Update-ViaAnsible.ps1 +++ b/ansible/Update-ViaAnsible.ps1 @@ -4,7 +4,4 @@ [switch]$PassThruOnly ) -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}} -} +Invoke-ViaAnsible -Command "Update-OSz -Mode Auto" -Remotes:$($Remotes.ToLower()) -RawOutput:$RawOutput diff --git a/ansible/profile.d/TypeData.ps1 b/ansible/profile.d/TypeData.ps1 new file mode 100644 index 0000000..60d136b --- /dev/null +++ b/ansible/profile.d/TypeData.ps1 @@ -0,0 +1,3 @@ +Update-TypeData -TypeName "AnsibleOutput" -DefaultDisplayPropertySet 'Machine','Runtime','Output(Last 4 Lines)' -Force +Update-TypeData -TypeName "AnsibleOutput" -MemberType ScriptProperty -MemberName 'Output(Last 4 Lines)' -Value {$_.Output | Select-Object -Last 4 } -Force +