返回函数多个返回值

一个PowerShell函数可以有多个返回值。要接收这些返回值,只需要将返回值赋给多个变量:

function Get-DateTimeInfo
{
# Value 1
Get-Date -Format 'dddd'
# Value 2
Get-Date -Format 'MMMM'
# Value 3
Get-Date -Format 'HH:mm:ss'
}
$day, $month, $time = Get-DateTimeInfo
"Today is $day, the month is $month, and it is $time"

from:http://blog.vichamp.com/powershell/tip/2013/09/09/returning-multiple-values/

 

 

 

posted on 2014-05-20 10:46  momingliu11  阅读(666)  评论(0编辑  收藏  举报