문제

I'm calling a powershell script thus:

function checkUrlOnSites([string[]]$urls) {
    #1
    Write-Verbose $urls.count
    $results=invoke-command -computername $computerName -ea silentlycontinue 
               -ev errRemote -scriptblock ${function:checkUrlOnSite} -args $urls
}


function checkUrlOnSite([string[]]$urls)
{
    #2
    Write-Verbose $urls.count
}

The first Write-Verbose writes 2 the second writes 1? what am I missing here? Where's my other string disappearing to??

도움이 되었습니까?

해결책

change in this way:

$results=invoke-command -computername $computerName -ea silentlycontinue `
               -ev errRemote -scriptblock ${function:checkUrlOnSite} -argumentlist (,$urls)

You need to force the argument as an array with the comma notation (,$urls)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top