How to return one and only one value from a PowerShell function?

前端 未结 10 933
暖寄归人
暖寄归人 2020-12-24 01:17

I\'ve learned from this Stack Overflow question, that PowerShell return semantics are different, let\'s say, from C#\'s return semantics. Quote from the aforementioned quest

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-24 02:05

    You could replace echo (alias of Write-Output) with Write-Host:

    PS> function test{ Write-Host "foo";"bar"} 
    PS> $a = test                                    
    test                                          
    PS >$a                                         
    bar
    

提交回复
热议问题