PowerShell's Write-Debug won't output arrays, but Write-Output does. Is this on purpose?

Viewed 11693

Shown below, an array works fine as input for Write-Output but not for Write-Debug (I expected them to be more similar than that).

PS C:\> [string[]]$test = @("test1", "test2", "test3")
PS C:\> Write-Output $test
test1
test2
test3
PS C:\> $DebugPreference = "Inquire"
PS C:\> Write-Debug $test
Write-Debug : Cannot convert 'System.String[]' to the type 'System.String' required by parameter 'Message'. Specified method is not supported.
At line:1 char:12
+ Write-Debug <<<<  $test
    + CategoryInfo          : InvalidArgument: (:) [Write-Debug], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.WriteDebugCommand

PS C:\>

I'm thinking this is just an unfortunate design, but hoping for a sensible explanation. Am I using Write-Debug correctly? If so, anyone have a favorite simple workaround?

4 Answers
Related