The second day of the Windows Server 2008 R2 course is almost over. I’m over all very please with the day, I had a good talk with Mikael Nyström (the tutor) of the course about how to potential (re)build a complete lab environment all script-based with Hyper-V and MDT2010. In theory it shouldn’t be that hard.
What thoughts did I get during this talk ? Well I had someone to bounce some basic ideas with, like there should be some basic building blocks, one core foundation with a DC / DNS / DHCP etc. And you should basically be able to start from a clean Hyper-V box and generate the complete env. from scratch.
When I got home I started to mess with this, the first step was to get a basic powershell script that created some virtual machines. After searching around the net, I stumbled upon Scripting VM Creation with Hyper-V and thought that my problem where solved. Unfortunately Ben hadn’t explained how to handle or populate the new virtual machine, the script only where a skeleton for creating a completely empty machine, without disks and nics or anything.
My search continued and finally I stumbled upon the “PowerShell Management Library for Hyper-V” on Codeplex, this library where just updated to support the new import-module command-let in PowerShell v2. A quick tour in the documentation got me up and running quickly, and the library looks awesome!
Install is a braise, just download and extract the HyperV-install.zip and place it under your modules folder. The default is located under Documents > microsoftPowershell > modules. When the new directory is in place just type:
Import-Module HyperV.psd1
To get a simple list of the new imported commands that you can use to “play” with your virtual-machines type the following in the PS window that you just have imported the Hyper-V module.
Get-Command -module HyperV | ft -property "Name"
The list of the output is listed below, impressive functions without installing the VMM 2008 R2 which provide similar command-lets. Now it’s time to hit the sack and recharge my batteries for the final day tomorrow at LabCenter, and I will continue the project with the scripted lab-environment during the upcoming weeks.
I have already started to think about how to utilize the AD scripts that Dalle published a couple a weeks ago to populate some basic AD structure with users and groups. But that’s another story…
Name
----
Add-NewVMHardDisk
Add-VMDisk
Add-VMDrive
Add-VMFloppyDisk
Add-VMKVP
Add-VMNewHardDisk
Add-VMNIC
Add-VMPassThrough
Add-VMRASD
Add-VMSCSIController
Add-ZIPContent
Apply-Snapshot
Choose-List
Choose-Tree
Choose-VM
Choose-VMExternalEthernet
Choose-VMNIC
Choose-VMPhysicalDisk
Choose-VMSnapshot
Choose-VMSwitch
compact-VHD
Compress-VHD
Connect-VHDParent
Convert-DiskIDtoDrive
ConvertTo-Enum
Convert-VHD
Convert-VMState
Copy-ZipContent
Dismount-VHD
Expand-VHD
Export-VM
Get-FirstAvailableDriveLetter
Get-VHD
Get-VhdDefaultPath
Get-VHDInfo
Get-VHDMountPoint
Get-VM
Get-VMBuildScript
Get-VMByMACAddress
Get-VMClusterGroup
Get-VMCPUCount
Get-VMDisk
Get-VMDiskByDrive
Get-VMDiskController
Get-VMDriveByController
Get-VMFloppyDisk
Get-VMHost
Get-VMIntegrationComponent
Get-VMKVP
Get-VMLiveMigrationNetwork
Get-VMMemory
Get-VMNIC
Get-VMNICport
Get-VMNICSwitch
Get-VMNICVLAN
Get-VMProcessor
Get-VMSerialPort
Get-VMSettingData
Get-VMSnapshot
Get-VMSnapshotTree
Get-VMState
Get-VMSummary
Get-VMSwitch
Get-VMThumbnail
Get-ZIPContent
Import-VM
Invoke-VMShutdown
List-VMState
Merge-VHD
Mount-VHD
Move-VM
New-VFD
New-VHD
New-VM
New-VMConnectSession
New-VMExternalSwitch
New-VMInternalSwitch
New-VMPrivateSwitch
New-VMRASD
New-VMSnapshot
New-VMSwitchPort
New-Zip
Out-Tree
Ping-VM
Remove-VM
Remove-VMDrive
Remove-VMFloppyDisk
Remove-VMKVP
Remove-VMNIC
Remove-VMRASD
Remove-VMSCSIController
Remove-VMSnapshot
Remove-VMSwitch
Remove-VMSwitchNIC
Rename-VMSnapshot
Restore-VMSnapshot
Save-VM
Select-ClusterSharedVolume
Select-EnumType
Select-Item
Select-List
Select-Tree
Select-VM
Select-VMExternalEthernet
Select-VMLiveMigrationNetwork
Select-VMNIC
Select-VMPhysicalDisk
Select-VMSnapshot
Select-VMSwitch
Set-VM
Set-VMCPUCount
Set-VMDisk
Set-VMHost
Set-VMIntegrationComponent
Set-VMMemory
Set-VMNICAddress
Set-VMNICSwitch
Set-VMNICVLAN
Set-VMRASD
Set-VMSerialPort
Set-VMSettings
Set-VMState
Show-HypervMenu
Show-VHDMenu
Show-VMDiskMenu
Show-VMMenu
Shutdown-vm
Start-VM
Stop-VM
Suspend-vm
Sync-VMClusterConfig
Test-Admin
Test-VHD
Test-VMHeartBeat
Test-WMIJob
Test-WMIResult
Update-VMSnapshot
Wait-ForDisk