any idea why tis is not working?
$code = {
param(
[string]$Server,
[string]$SessionId,
[string]$vmname
)
Import-Module VMware.VimAutomation.Core
Set-PowerCLIConfiguration -DisplayDeprecationWarnings $false -Confirm:$false | Out-Null
Connect-VIServer -Server $Server -Session $SessionId
get-vm -name $vmname | select Name
}
$jobs = Get-Content -Path .\vms.txt |
ForEach-Object -Process {
Start-Job -Name test -ScriptBlock $code -ArgumentList $global:defaultviserver.Name, $global:DefaultVIServer.SessionId, $_
}
Get-Job | Wait-Job
Get-Job | Receive-Job | Out-GridView
What exactly is not working?
When you cancel the script, does one or more of the jobs show a status of "Failed"?
And does the job output contain
The process cannot access the file 'C:\Users\lucd\AppData\Roaming\VMware\PowerCLI\PowerCLI_Settings.xml' because it is being used by another process.
+ CategoryInfo : NotSpecified: (:) [Set-PowerCLIConfiguration], IOException
+ FullyQualifiedErrorId : System.IO.IOException,VMware.VimAutomation.ViCore.Cmdlets.Commands.SetVIToolkitConfiguration
+ PSComputerName : localhost
If yes, try adding a sleep to the loop
Start-Job -Name test -ScriptBlock $code -ArgumentList $global:defaultviserver.Name, $global:DefaultVIServer.SessionId, $_
sleep 1
}
This is a known issue with PowerCLI when you try to set configuration settings in multiple background jobs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD Is there a work around available to this error
WARNING: The process cannot access the file 'C:\Users\a615182\AppData\Roaming\VMware\PowerCLI\RecentServerList.xml' because it is being used by another process.
Not with the current PowerCLI version.
If you don't mind not having a list of recently connected vSphere servers, you can safely ignore this warning.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am using
PowerCLI Version
----------------
VMware PowerCLI 12.0.0 build 15947286
---------------
Component Versions
---------------
VMware Common PowerCLI Component 12.0 build 15939652
VMware Cis Core PowerCLI Component PowerCLI Component 12.0 build 15939657
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 12.0 build 15939655
LucD
I am currently running. Is the issue fixed in this version.
PowerCLI Version
----------------
VMware PowerCLI 12.0.0 build 15947286
---------------
Component Versions
---------------
VMware Common PowerCLI Component 12.0 build 15939652
VMware Cis Core PowerCLI Component PowerCLI Component 12.0 build 15939657
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 12.0 build 15939655
No, still there
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference