Reply to Message

View discussion in a popup

Replying to:
pizzim13
Contributor
Contributor

As mentioned earlier, if $vm is an array of vm objects (the array I am testing has 20 vms in it), the cmdlet will run multiple times without issue. But if I change the code to run with a foreach-object:

while ($VM -ne $null) {$VM |% {$_ | Invoke-VMScript -GuestCredential $PCCreds -ScriptType Bat -ScriptText 'whoami'; Start-Sleep -Seconds 10}}

I will receive the same error after the 1st or 2nd vm.

Reply
0 Kudos