Automation

 View Only

Problem with PowerCli in Multi-threading

  • 1.  Problem with PowerCli in Multi-threading

    Posted Jun 13, 2014 08:54 AM

    Hi,

    Sorry for my little English,

    I would like use PowerCli in Multi-threading, But my problem is at Data recovery. i haven't recovery all data of my variable when i execute my command

    For Example,
    if i execute the command "Get-cluster -Name "My_Cluser" | Get-View)"
    I recov the data to the root and root + 1, but it not shows me the rest

    i don't know how...
    if someone at a idea..

    Thank you

    and Sorry for my little English !!!

    My Code :

    $IPvCenter = "IP_VCENTER"
    Add-PSSnapin -Name "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue

    Connect-VIServer $IPvCenter


    $SessionId= ($defaultviserver | select SessionId).sessionId
    $functions = {

          Add-PSSnapin -Name "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue

          $Connect = Connect-VIServer $args[0] -Session $args[1]

          $ClusterInfo = (Get-cluster  -Name "My_Cluster" | Get-View) | select *
          return $ClusterInfo
    }
    $SessionId= ($defaultviserver | select SessionId).sessionId
    $Result = Start-Job -ScriptBlock $functions -argumentlist @($IPvCenter,$SessionId) | Wait-Job| Receive-Job

    # Example

         # Good
    $Result[1]

         # Bad

    $Result[1].ConfigurationEx