I have the below code to map network adapter for 300+ VMs, when runasync its state not complete and always running. please advice.
$NetworkReg = @()
$vms= import-csv vmlist.csv
foreach($vm in $vms)
$VMadapters = Get-VM "$vm.name" | Get-NetworkAdapter
$PortGroup = Get-VirtualPortGroup -Name "$vm.portgroup"
$NetworkReg += Set-NetworkAdapter -NetworkAdapter $VMadapter -Portgroup $PortGroup -RunAsync -Confirm:$false
Name State % Complete Start Time Finish Time
---- ----- ---------- ---------- -----------
ReconfigVM_Task Running 6 03:18:20 PM
there is no prompt on the console it just returns it to console after the result.
PS C:> $PortGroup = Get-virtualportgroup -name 'Test'
im checking the $NetworkReg which is assigned for runasync task. it return always running state. but the task already completed in VC. Set-NetworkAdapter cant use runasync?
can you share the example which is working from your side? i just want to runasync for Set-NetworkAdapter task .