I’m sure there’s a cleaner way to capture the output from Write-Host, Write-Verbose, etc. However, I’m just going to “go caveman” in the words of a coworker and just hack around with the Verb-Transcript cmdlets. Without further ado: function Get-MisbehavingCmdletOutput
{
param (
[System.Management.Automation.Scriptblock]$ScriptBlock = $null,
[string]$Path = "$env:temp\$([System.IO.Path]::GetRandomFileName())"
);
if (!$ScriptBlock)
{
write-host "$($MyInvocation.MyCommand...(read more)
↧