假设我有这个简单的PowerShell函数:
function testit() {
return $true > $null
}
Write-Host "testing"
$thistest = testit
Write-Host "value = $thistest"
当我在PowerShell脚本中使用它时,我希望在脚本中接收该值,但不想在控制台中显示它。
如何将返回值保留在管道中,但只隐藏它不显示在控制台中?
如果我使用
> $null
,则会完全抑制输出 - 我只是不想在控制台中显示它,但仍然需要该值。
return $true
或者只是$true
有什么问题? - user4003407function test { $true }; $x = test
没有屏幕输出,并将返回值保留在$x
中。 - TessellatingHecklerreturn $true
在控制台中显示为True
。 - bgmCoder