有没有办法从返回值的 PowerShell 函数将调试消息打印到控制台?
例子:
function A
{
$output = 0
# Start of awesome algorithm
WriteDebug # Magic function that prints debug messages to the console
#...
# End of awesome algorithm
return $output
}
# Script body
$result = A
Write-Output "Result=" $result
是否有符合此描述的 PowerShell 函数?
我知道Write-Output和 Write-*,但是在我所有的测试中,在上述函数中使用任何这些函数都不会写入任何调试消息。我也知道只调用函数而不使用返回值确实会导致函数编写调试消息。