Has anyone been able to complete something like this? This works perfectly in a plain PoSh window but running in a Start-Job it never gets past the connect-ciserver. The job shows running and HasMoreData .. but again, never completes.
I'm using PowerCLI 5.1 Update 2 and Powershell 3.0 which is supported under my PowerCLI version.
Start-Job -ScriptBlock {
# Add PSSnapins
Add-PSSnapin VMware.VimAutomation.Core
Add-PSSnapin VMware.VimAutomation.Vds
Add-PSSnapin VMware.VimAutomation.License
Add-PSSnapin VMware.DeployAutomation
Add-PSSnapin VMware.ImageBuilder
Add-PSSnapin VMware.VimAutomation.Cloud
Connect-CIServer -Server testcloud.cloud.com -User testuser -Password Test111
Get-CIVApp
}
I attempted to multi-thread with Start-Job a while back, but was unsuccessful. I gave somewhat of a detailed account in this thread: http://communities.vmware.com/thread/296805
It obviously has to do with adding the snap-in, so if you used raw REST calls you should be able to achieve world domination…
For instance, instead of using the Connect-CIServer and generating N number of sessions, you can re-use the same session token for each thread.
Cheers,
Jake
Jake,
Thanks for your response.... I'm not clear on exactly how you would do this. Any examples? I read through your post and couldn't come up with anything.
To attempt what you are saying I took the current session ID of my connect-ciserver and passed it to the start job as an argument.... still nothing.
Start-Job -RunAs32 -ScriptBlock {
# Add PSSnapins
Add-PSSnapin VMware.VimAutomation.Core
Add-PSSnapin VMware.VimAutomation.Vds
Add-PSSnapin VMware.VimAutomation.License
Add-PSSnapin VMware.DeployAutomation
Add-PSSnapin VMware.ImageBuilder
Add-PSSnapin VMware.VimAutomation.Cloud
Connect-VIServer testvc01
Get-PowerCLIConfiguration
Connect-CIServer testcloud.cloud.com -SessionId $args[0]
Get-CIVApp
} -ArgumentList @($session)
The connect-VIServer and the Get-PowerCLIConfiguration process... but the script stops at Connect-CIServer
Bumping this... anyone?
Hi,
I don't use jobs yet and I don't know how they work. But I got this to work as expected (I think):
Start-Job -ScriptBlock {
# Add PSSnapins
Add-PSSnapin VMware.VimAutomation.Core
Add-PSSnapin VMware.VimAutomation.Vds
Add-PSSnapin VMware.VimAutomation.License
Add-PSSnapin VMware.DeployAutomation
Add-PSSnapin VMware.ImageBuilder
Add-PSSnapin VMware.VimAutomation.Cloud
$task = Connect-CIServer YOURSERVER -user USERNAME -password PASSWORD -wa 0 -ea 0
Get-CIvApp "Test CIvApp"
exit
}
Then I waited for it to finish:
Get-Job 23 | fl
Once I saw:
JobStateInfo : Completed
Finished : System.Threading.ManualResetEvent
InstanceId : 905c99b0-3771-4ea0-9711-f14db2009916
Id : 23
Name : Job23
ChildJobs : {Job24}
I ran this: Get-Job 23 | Receive-Job
Name Enabled InMaintenanceMode Owner
---- ------- ----------------- -----
Test CIvAPP True False system
Do you get the same result? I also got Get-CIvApp "Test CIvApp" | get-civm "MachineName" to return the info.
Cheers,
DeanH
I attempted setting it to a $task variable along with your extra switches and no luck... never does the connect.
Any other ideas?
Again this works in both a powercli window and a plain posh window but will not work in a start-job. A connect-viserver in a start job works fine.
It seems PoSH 3.0 is the culprit here... uninstalling that let me proceed with the job.
However, I need 3.0 installed for some of the added benefit. Any way to get around this?
adding a -psversion 2.0 at the end of my start-job corrected it for me!