Best Practices


Using PowerShell in vWire

by Steve  | June 23rd, 2009

Since we launched vWire at the beginning of the month I have been asked a few times how to help people get their PowerShell scripts to work with vWire.  This post is going to answer that question and give examples that you will need to make this happen. The first thing that you need to know is that vWire works by pipelining the information to PowerShell.  PowerShell will accept this input in the form of the variable $input.  Let me give you a quick example that should help make better sense of this.   Let’s look at the code to start virtual machines.

Foreach ($vm in (get-vm))
{
Start-VM -VM $vm  -confirm:$false
}

In this example I use a foreach loop to get all the names of the virtual machines that the command “get-vm” returns and puts it in the $vm variable.  Each different virtual machine name is looped through the Start-VM command until all virtual machines have been started.  The -confirm:$false switch is so that we do not get prompted to confirm we want to perform this action or start the virtual machines.

Now let’s look at the same code that would work in vWire

 

Notice that the object type is set to “Virtual Machine.” This lets vWire know what object this action or script will be used against. If you wrote an action for the hosts then the object type would be Hosts. You have the choice to select:

 

1.DataCenter 

2.Cluster

3.Host

4.VM

5. Snapshots

6. Resource Pool

7. Cluster Objects (i.e. affinity rules)

8. Device Objects (i.e. vCDROM, vNic ect)

9. Management Objects (i.e. VC Folders ect)

10. Storage Objects (SCSI LUN)

11. VM Object (Current Snapshots)

 

This should give you enough information to get started and take a peek at the power you have with vWire. For more information on vWire you can check out the vWire Community and to also share content with others in the community.

Time to sharpen your skills with vWire because I have heard rumors there might be a contest coming up.


Tags , , , , ,

This entry was posted on Tuesday, June 23rd, 2009 at 11:14 am and is filed under Virtual Tech. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Add a Comment

x

Subscribe to The Virtual Black Hole RSS Feed Email Notification

Enter your email address:

Delivered by FeedBurner