On part two for PowerCLI cmdlets for handling virtual machine for VMware environment. We will start with some task and command associated with it. It will help to clear your basic handling for virtual machine and you can test some of cmdlets from below on your environment.
Listing
VMs, Hosts, Datastores, And Resource Pools.(Beginner)
|
Task
|
Solution
|
|
Connect to Virtual Center
|
Get-VC 10.0.0.2
|
|
Obtain a list of all VMs
|
Get-VM
|
|
Obtain a list of all Hosts
|
Get-VMHost
|
|
Obtain a list of all Datastores
|
Get-Datastore
|
|
Obtain a list of all Resource Pools
|
Get-Resourcepool
|
Creating a
VM.
|
Task
|
Solution
|
|
Create a VM called “MyFirst_VM” on ESX1. Give the VM 256 MB of RAM
and 1GB of disk
|
Get-VMHost ESX1 | New-VM -Name
”MyFirst_VM” -Memorymb 256 –diskmb 1024
–pool (Get-resourcepool sales-esx1) –location
(Get-folder sales)
|
|
Create a VM called “MySecond_VM” on ESX2. Give the VM 2 CPUs, and configure
it to host Windows 2008 as the guest operating system.
|
Get-VMHost ESX2 | New-VM –Name “MySecond_VM” –Memorymb 1024 –diskmb 2048
–guestif Win2008ServGuest –pool (Get-Resourcepool
sales-esx2) –location (Get-folder sales)
|
Basic VM
Modification
|
Task
|
Solution
|
|
Change the number of virtual CPUs configured for “Sales1” from 1 to 2
|
Get-VM “Sales1” | Set-VM –numcpu
2
|
|
Change the amount of RAM configured for “Sales1” from 256mb to 1024mb
|
Get-VM “Sales1” | Set-VM –memorymb 1024
|
|
Verify that your modifications were successful
|
Get-VM “Sales1”
|
Powering
VMs ON & OFF
|
Task
|
Solution
|
|
Determine the power status of all available VMs
|
Get-VM |ft name,powerstate
|
|
Power on the “Server1” virtual machine
|
Get-VM “Server1”| Start-VM
|
|
Reset the “Server1” virtual machine
|
Get-VM “Server1” | Stop-VM
|
|
Suspend the “Server1” virtual machine
|
Get-VM “Server1” | Suspend-VM
|
|
Resume the “Server1” virtual machine
|
Get-VM “Server1” | Start-VM
|
|
Power off the “Server1” virtual machine
|
Get-VM “Server1” | Stop-VM
|
No comments:
Post a Comment