아래 PowerShell을 에서 차단 잠을 구현하기위한 것입니다 기능이 얻을 수 Start-Sleep
cmdlet를 실행 다음과 같은 오류 :.파워 쉘 함수에서 cmdlet으로 변수를 전달
"매개 변수 '초'에 인수를 확인할 수 없습니다를 인수가 null이거나 비어 있거나 인수 컬렉션의 요소에 Null 값이 포함되어 있습니다. "
에코가 올바른 인수 값을 인쇄하지만 인수가 cmdlet으로 전달되지 않습니다. 동일한 결과를 가진 로컬 변수를 시도했습니다. 그것을 문자열이나 정수로 캐스팅하려고했는데 아무 쓸모가 없습니다. 숫자가 하드 코딩 된 경우에만 작동하는 유일한 방법
function BlockedSleep($numSecs)
{
echo "Sleeping $($numSecs) seconds"
$job = Start-Job {Start-Sleep -s $numSecs }
Wait-Job $job >$null #this supresses job output to console
Receive-Job $job
}
가'[한 번 봐 가져 오기를-도움말 당신이 중 하나는 스크립트 블록에 인수로 변수를 포함 할 수 있습니다 about_Remote_Variables'] (https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_remote_variables) 및 ['Get-Help about_Scopes'] (https : // msdn. microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_scopes). [이 StackOverflow 질문] (http://stackoverflow.com/questions/24996816/powershell-remoting-using-variable-scope)도 유용 할 것입니다. –