Book Image

Learning PowerCLI for VMware VSphere

By : Robert van den Nieuwendijk
Book Image

Learning PowerCLI for VMware VSphere

By: Robert van den Nieuwendijk

Overview of this book

Table of Contents (17 chapters)
Learning PowerCLI
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Starting and stopping a virtual machine


You have created your virtual machine but it is still powered off. In this section, you will learn how to start, suspend, and stop a virtual machine using PowerCLI.

Starting a virtual machine

To start a virtual machine, you can use the Start-VM cmdlet. This cmdlet has the following syntax:

Start-VM [-RunAsync] [-VM] <VirtualMachine[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

The –VM parameter is required to start a virtual machine.

In the first example, we will start the virtual machine VM2 using the following command:

PowerCLI C:\> Start-VM –VM VM2

The output to the preceding command is as follows:

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
VM2                  PoweredOn  1        1.000

To start all of your virtual machines that are powered off, you can pipe the output of the Get-VM cmdlet with a where filter to select only those virtual machines that...