Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Will these powercli commands wait to happen or will they execute at the same time?

Posted on 2013-01-30
2
Medium Priority
?
318 Views
Last Modified: 2013-02-01
I have a simple script to move (Svmotion) some VMs - eg;

Get-VM “MyVM1“ |Move-VM -datastore (Get-datastore “MyDatastore1“)
Get-VM “MyVM2“ |Move-VM -datastore (Get-datastore “MyDatastore2“)
Get-VM “MyVM3“ |Move-VM -datastore (Get-datastore “MyDatastore3“)
Get-VM “MyVM4“ |Move-VM -datastore (Get-datastore “MyDatastore4“)

Open in new window


Will these powercli commands wait to happen or will they execute at the same time? What would I do to get them to execute at the same time?
0
Comment
Question by:Thaidog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 2000 total points
ID: 38837383
use background jobs:
$vm_list = "vm1","vm2","vm3"
$ds_list = "ds1","ds2","ds3"

for($i=0;$i<$vm.list.Length;$i++)
  # Define what each job does
  $ScriptBlock = {
Get-VM $vm_list[$i] |Move-VM -datastore (Get-datastore $ds_list[$i])
Start-Sleep 60
  }

  # Execute the jobs in parallel
  Start-Job $ScriptBlock
}

Get-Job

# Wait for it all to complete
While (Get-Job -State "Running")
{
  Start-Sleep 10
}

# Getting the information back from the jobs
Get-Job | Receive-Job

Open in new window

0
 
LVL 5

Expert Comment

by:coraxal
ID: 38837432
@sedgwick - when you work with jobs, are those jobs processed by the local machine, or the remote machines? If by remote machines, do they have to have powershell? same version of powershell?
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question