Powershell Break:未切换到下一个语句/方法

时间:2018-03-20 18:27:33

标签: powershell break

有人可以帮助我,因为我在第一种方法执行休息后无法调用第二种方法。

Function First ()
{


write-host "I am in First method"
break;
}

Function Second ()
{

write-host "I am in second method"

}


First
Second

1 个答案:

答案 0 :(得分:0)

我建议不要使用*-Host函数,除非出于特殊原因需要它们,并使用经批准的动词 - 名词命名约定(Get-Verb)。 break是一个关键字,旨在打破摆脱循环(foreachforwhile等。)

重新写为:

Function Get-First
{
    'I am the First function.'
    # equivalent to: Write-Output 'I am the First function.'
}
Function Get-Second
{
    'I am the Second function.'
}
Get-First
Get-Second