I have installed Invoke-Parallel module and trying to use for invoke-vmscript cmdlet on multiple vms at one time and collect the output but its failing with error that the InputObject is null.
Is it possible to construct a sample script using invoke-parallel
I used like this but its not working.
$hotfix = "KB4512517", "KB4512507", "KB452516", "KB4512501", "KB4511553", "KB4512508", "KB4511553", "KB4512506", "KB4512486", "KB4512488", "KB4512489", "KB4512482", "KB4512518"
$hotfixinfo = "No hotfix found!"
$fixes = Get-WmiObject -Class "win32_quickfixengineering" |
where{$hotfix -contains $_.HotFixID} |
Select -ExpandProperty HotFixID
if($fixes){
$hotfixinfo = "$($fixes -join ',') installed"
}
$hotfixinfo
'@
$result=@()
$vm = Get-ResourcePool 'Testpool' | Get-VM| Where-Object { $_.PowerState -eq "Poweredon" -and $_.ExtensionData.Config.GuestFullName -like "*Microsoft*" }
$result += Invoke-Parallel -InputObject $vm -ScriptBlock { Invoke-VMScript -VM $vm.Name -ScriptText $script -GuestUser 'Administrator' -GuestPassword 'Test123' -ScriptType Powershell
}
New-Object PSObject -Property (
[ordered]@{
Name = $vm.Name
OS = $vm.Guest.OSFullName
IP = $vm.Guest.IPAddress -join '|'
Result = $result
})
Can you provide the full error message you are getting?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is the output I received when i executed on one resourcepool.
Parts of PowerCLI are not thread-safe, see also Issue#22
Besides that C# bypass, I don't know of any other solution.
That is the main reason why I always opt for Start-Job.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ok.
so with start-job how collect the output when invoke-vmscript is initiated on multiple vms.
its really painful while executing on 7000 vms.
the above script is almost taking 3days approx to get the output result.
The same way you do in your earlier script, but you can use Receive-Job.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference