PrepAway - Latest Free Exam Questions & Answers

How should you build the PowerShell script?

DRAG DROP
A company has a Widows Server 2008 R2 Hyper-V server environment. The environment is
managed by using Microsoft System a Mach.ne Manager (VMM) 2008 R2 on a server
named VMM01.contoso.com.
The company has requested a new virtual machine (VM) based on the following
requirements:
The VM must be deployed from a template named “Windows Server 2008 R2 Base.”
The VM must be deployed in a scripted manner by using Windows PowerShell.
The VM must be deployed onto the VMM01.contoso.com host.
The VM must be named WEB01.
You need to deploy the VM based on the company requirements.
How should you build the PowerShell script? (To answer, drag the approbate PowerShell
cmdlet from the list to the proper locations in the script)

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
(This question is open to discussion/correction)

VMware ESX (VMware ESX cmd)
Set-VMHost
To change the state of a VMHost
Set-VmHost -VmHost ESX01 -State ”Disconnected“
# Disconnect Host
Set-VmHost -VmHost (Get-VmHost -Name ”ESX01”) -State ”Maintenance“
# Enter Host
Connect Host or Exit Maintenance
Set-VmHost -VmHost (Get-VmHost -Name ”ESX01”) -State ”Connected“
Set-VMHost
Synopsis
Changes the configuration of the host.
Syntax
Set-VMHost [-VMHost] <VMHost> [[-State] <VMHostState>] [-VMSwapfilePolicy
<VMSwapfilePolicy>] [-VMSwapfileDatastore <Datastore>] [-Profile <VMHostProfile>] [-
Evacuate]
[-TimeZone <VMHostTimeZone>] [-Server <VIServer[]>] [-RunAsync] [-WhatIf] [-Confirm]
[<CommonParameters>]
http://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/Set-VMHost.html
VMware ESX (VMware ESX cmd)
Get-VMHost
To list all the VMware Infrastructure Servers (VMHost) on the connected
VI Server
Get-VMHost
Get all Hosts member of a Cluster
Get-Cluster Cluster01 | Get-VmHost
To remove a VMHost
Get-VMHost ESX01 | Remove-VmHost
Get-VMHost
Synopsis
Retrieves the hosts on a vSphere server.
Syntax
Get-VMHost [-Datastore <Datastore[]>] [-State <VMHostState[]>] [-Location <VIContainer[]>]
[[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>]
[<CommonParameters>]Get-VMHost [-VM <VirtualMachine[]>] [-ResourcePool
<ResourcePool[]>]
[-Datastore <Datastore[]>] [-Location<VIContainer[]>] [[-Name] <String[]>] [-Id <String[]>] [-
NoRecursion] [-Server <VIServer[]>][<CommonParameters>]
http://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/Get-VMHost.html
Get-Template
Synopsis
Retrieves the virtual machine templates available on a vSphere server.

Syntax
Get-Template [-Location <VIContainer[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion]
[-Server<VIServer[]>] [<CommonParameters>]
http://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/GetTemplate.html
Windows commands
Get-VMMServer (Windows cmd)
Connecting to the Virtual Machine Manager Server
Applies To: Virtual Machine Manager 2008, Virtual Machine Manager 2008 R2, Virtual
Machine Manager 2008 R2 SP1
You can display Help about System Center Virtual Machine Manager (VMM) cmdlets at any
time in the Windows PowerShell – Virtual Machine Manager command shell. However, you
can use the VMM cmdlets only after you connect to a VMM server.
Connecting to a VMM server retrieves the server object from the VMM database and gives
you access to all the other objects in the database. You retain access to the objects in the
database until you close the server connection, which you can do by closing the VMM
command shell.
To connect to the Virtual Machine Manager server
Type the following command, and then review the output. Replace the placeholders with
your own server and domain names:
Get-VMMServer –Computername “<YourVMMServerName>.<YourDomainName>.com”
When the command has successfully completed, the server object is returned. The
command shell displays information about the properties of the VMM server object. And, you
are connected to the VMM database that is provided by the VMM server.
If a command does not work in the command shell, run the command to connect to the VMM
server again. If you encounter problems, open the Services tool in Administrative Tools, and
then restart the VMM service. Or, restart the service in the command shell. For information
about how to restart a service in the command shell, type Get-Help Restart-Service –
detailed.
If you are working on the server on which VMM is installed, you can substitute “localhost” for
the fully qualified domain name (FQDN). You cannot do this if you are accessing the server
remotely.
To connect to Virtual Machine Manager if it is installed on the local host Type the following
command, and then review its output:
Get-VMMServer –Computername localhost
http://technet.microsoft.com/en-us/library/cc764276.aspx
Virtual Machines (Windows cmd)
Set-Vm Change the configuration of a VM
Set-VM -VM (Get-VM -Name ”Win XP SP1”) -Name ”Win XP SP2“ -GuestId
”winXPProGuest“
-Description ”My updatedWin XP virtual machine.“
The Set-VM cmdlet configures a virtual machine.
Examples
Example 1
Configures virtual machine TestVM to shut down when the Hyper-V host shuts down.
PS C:\> Set-VM –Name TestVM –AutomaticStopAction Shutdown
Example 2
Stops virtual machine TestVM, sets it to use dynamic memory, sets its maximum amount of
memory to 2GB, sets it to use 2 virtual processors, and starts it.
PS C:\> Stop-VM -Name TestVM -Passthru | Set-VM -ProcessorCount 2 -DynamicMemory –
MemoryMaximumBytes 2GB -Passthru | Start-VM

Provision VM (Windows cmd)
VI PowerScripter
To create a new VM (Windows cmd)
$esxhost = Get-VMHost ”ESXHost01 .mydomain.com“
New-VM -Name XPVM -VMHost $esxhost -DiskMB 4000 -MemoryMB 256
Creates a new virtual machine.
Examples
Example 1
Creates a new virtual machine named new 1 that has 512MB of memory.
PS C:\> New-VM –Name “new 1” –MemoryStartupBytes 512MB
Example 2
Creates a virtual machine named new 2 that has 1GB of memory and that is connected to a
new 40GB VHDX file.
PS C:\> New-VM –Name “new 2” –MemoryStartupBytes 1GB –NewVHDPath
d:\vhd\base.vhdx
Example 3
Creates a virtual machine named new 3 that has 1GB of memory and is connected to an
existing VHDX file.
PS C:\> New-VM –Name “new 3” –MemoryStartupBytes 1GB –VHDPath
d:\vhd\BaseImage.vhdx
To Remove a VM:
Remove-VM ( Get-VM “myVM” ) –DeleteFromDisk
Templates (Windows cmd)
$template = Get-Template -Name Templ* -Location (Get-Datacenter DC)
Remove-Template –
Template $template
New-Template -VM ( Get-VM XPVM ) -Name Template01 -Location (Get-Datacenter DC)
Set-Template -Template $template -ToVM
# convert Template to VM
How to Create a Virtual Machine Template
http://technet.microsoft.com/en-us/library/bb740832.aspx
Guest Customization Specification
$osspec = Get-OSCustomizationSpec WinXP
# reads Guest Customization Specification object
New-VM -Name MyVM2 -Template Template01 -VMHost ESX01 -OSCustomizationSpec
$osspec
other OS Customization CmdLets:
New-OSCustomizationSpec
Set-OSCustomizationSpec


Leave a Reply