powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Set-VM



NAME
Set-VM

SYNOPSIS
Changes the configuration of the virtual machine.

SYNTAX
Set-VM [-VM] [-Name ] [-Version ] [-MemoryMB ] [-NumCpu ] [-Gue
stId ] [-AlternateGuestName ] [-OSCustomizationSpec ] [-HARestartPriority estartPriority>] [-HAIsolationResponse ] [-DrsAutomationLevel ] [-Server <
VIServer[]>] [-RunAsync] [-VMSwapFilePolicy ] [-Description ] [-WhatIf] [-Confirm] [ onParameters>]

Set-VM [-VM] [-Name ] [-Snapshot ] [-OSCustomizationSpec
] [-HARestartPriority ] [-HAIsolationResponse ] [-DrsAutomationLevel tomationLevel>] [-Server ] [-RunAsync] [-VMSwapFilePolicy ] [-WhatIf] [-Confirm] [ mmonParameters>]

Set-VM [-VM] [-Name ] [-Server ] [-RunAsync] [-ToTemplate] [-WhatIf] [-Confi
rm] []


DESCRIPTION
Changes the configuration of the virtual machine. If the OSCustomizationSpec parameter is used, the cmdlet customiz
es the virtual machine according to the specification. In addition, the cmdlet allows you to revert a virtual machi
ne to a snapshot and convert a virtual machine to a template.


PARAMETERS
-VM
Specify the virtual machine you want to configure.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? true

-Name
Specify a new name for the virtual machine.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Version
Specify the version to which you want to upgrade the virtual machine. The valid values are v4, v7, and v8. You
cannot downgrade to an older version.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-MemoryMB
Specify the memory size in MB.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-NumCpu
Specify the number of virtual CPUs.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-GuestId
Specify the guest operating system of the virtual machine. The valid values for specific ESX versions are liste
d in the description of the VirtualMachineGuestOsIdentifier enumeration type in the vSphere API Reference avail
able at http://www.vmware.com/support/developer/vc-sdk/. Depending on the hardware configuration of the host, s
ome of the guest operating systems might be inapplicable.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-AlternateGuestName
Specify the full name of the guest OS for the virtual machine if the value of the GuestID parameter is set to o
therGuest or otherGuest64.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-OSCustomizationSpec
Specify a customization specification you want to apply to the virtual machine. This works only in 32-bit mode.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-HARestartPriority
Specify the virtual machine HA restart priority. The valid values are Disabled, Low, Medium, High, and ClusterR
estartPriority. VMware HA is a feature that detects failed virtual machines and automatically restarts them on
alternative ESX hosts. Passing values to this parameter through a pipeline is deprecated and will be disabled i
n a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. O
therwise, an error is generated.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-HAIsolationResponse
Indicate whether the virtual machine should be powered off if a host determines that it is isolated from the re
st of the compute resource. The valid values are AsSpecifiedByCluster, PowerOff, and DoNothing. Passing values
to this parameter through a pipeline is deprecated and will be disabled in a future release. Specifying this pa
rameter is only supported when the virtual machine is inside a cluster. Otherwise, an error is generated.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-DrsAutomationLevel
Specify a DRS (Distributed Resource Scheduler) automation level. The valid values are FullyAutomated, Manual, a
nd PartiallyAutomated, AsSpecifiedByCluster, and Disabled. Passing values to this parameter through a pipeline
is deprecated and will be disabled in a future release. Specifying this parameter is only supported when the vi
rtual machine is inside a cluster. Otherwise, an error is generated.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Server
Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the co
mmand runs on the default servers. For more information about default servers, see the description of Connect-V
IServer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-RunAsync
Indicate that the command returns immediately without waiting for the task to complete. In this mode, the outpu
t of the cmdlet is a Task object. For more information about the -RunAsync parameter run " help About_RunAsync"
in the vSphere PowerCLI console.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-VMSwapFilePolicy
Specify the swapfile placement policy. The following values are valid:

InHostDataStore - Store the swapfile in the datastore specified by the VMSwapfileDatastoreID property of the vi
rtual machine host. If the VMSwapfileDatastoreID property is not set or indicates a datastore with insufficient
free space, the swapfile is stored in the same directory as the virtual machine. This setting might degrade th
e VMotion performance.

WithVM - Store the swapfile in the same directory as the virtual machine.

This parameter is supported only on vCenter Server 2.5 and ESX 3.5 servers, or later versions.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Description
Provide a description of the virtual machine. The alias of this parameter is Notes.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modi
fied.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Confirm
If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false,
the cmdlet runs without asking for user confirmation.

Required? false
Position? named
Default value $true
Accept pipeline input? false
Accept wildcard characters? false

-Snapshot
Specify a snapshot whose state you want to apply to the virtual machine.

Required? false
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

-ToTemplate
Indicate that you want to convert the virtual machine to a template.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS



OUTPUTS
VirtualMachine or Snapshot


NOTES


Applying customization specs works only in 32-bit mode.

-------------- Example 1 --------------

C:\PS>$template = Get-VM VM | Set-VM -ToTemplate -Name VMTemplate


Converts the VM virtual machine to a template and stores the template in the $template variable.





-------------- Example 2 --------------

C:\PS>Get-VM -Location ResourcePool01 | Set-VM -MemoryMB 2048 -NumCPU 2


Upgrades the memory and CPU count of the virtual machines in ResourcePool01.





-------------- Example 3 --------------

C:\PS>Set-VM -VM VM -Version v7


Upgrades the virtual hardware version of the VM machine.





-------------- Example 4 --------------

C:\PS>$snapshot = Get-Snapshot -VM $vm -Name "Initial state"

Set-VM -VM $vm -Snapshot $snapshot


Revert the VM virtual machine to the "Initial state" snapshot.





-------------- Example 5 --------------

C:\PS>$spec = Get-OSCustomizationSpec -Name FinanceDepartmentSpec;

Set-VM -VM $vm -OSCustomizationSpec $spec


Apply a customization specification on the specified virtual machines.





-------------- Example 6 --------------

C:\PS>Set-VM $vm -Name "Web Server" -GuestID winNetStandardGuest -Description "Company's web server"


Changes the name, description, and guest ID of the specified virtual machine.






RELATED LINKS
Online version: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Set-VM.html
Get-VM
Move-VM
New-VM
Remove-VM
Start-VM
Stop-VM
Suspend-VM