Archive for July, 2014

Powershell script to change printer IP address


netprintA question was posted in Powershell.org Q&A forum:

I have a weird question. Can you modify object properties. the command
Get-PrinterPort 192.* | fl *
prints out all the attributes of the printer port. but I can’t modify them. I don’t want to create a new port and start from scratch, just modify the existing object. Or maybe export the export and then import it, modified, into the new one.

This script does just that. It can be downloaded from the Microsoft Script Center Repository.

The reason we cannot modify the existing printer port object is that the Get-Printer commandlet uses the MSFT_TCPIpPrinterPort class. This class has the 2 properties we want to change (HostAddress and Name) but they’re read-only.

Even if we try to use the Win32_TCPIpPrinterPort class, as in:

$OldIP = “192.168.0.95”
$NewIP = “192.168.0.99”
$objPrinterPort = Get-WmiObject -Class Win32_TCPIpPrinterPort | Where-Object {$_.Name -eq “IP_$OldIP”}
$objPrinterPort.psbase.scope.options.EnablePrivileges = $true
$objPrinterPort.HostAddress = $NewIP
$objPrinterPort.Name = “IP_$NewIP”
$objPrinterPort.Put()

This does not modify the existing Printer Port, it creates a new one..

Example script usage:

.\Change-PrinterIP.ps1 192.168.0.95 192.168.0.99

Script output looks like:

Change-PrinterIP

 


Test-Disk powershell script to test disk IO performance


disk-io-performanceThis script tests disk IO performance by creating random files on the target disk and measuring IO performance. The script can be downloaded from the Microsoft Script Center Repository.  It leaves 2 files in the WorkFolder:
A log file that lists script progress, and
a CSV file that has a record for each testing cycle.

Warning:

This script will delete all subfolders in the work-folder. Make sure to run it in a new folder.

For help type in;

help .\Test-Disk.ps1 -full

Example   .\Test-Disk.ps1 “i:\support” 3GB
This example tests the i: drive, generates files under i:\support, uses a maximum of 3GB disk space on i: drive.   It runs a single thread, runs for 3 cycles, uses largest file = 100MB (1 order of magnitude below 3GB entered), smallest file = 10MB (1 order of magnitude below largest file)

Example   .\Test-Disk.ps1 “i:\support” 11GB 8 5 4
This example tests the i: drive, generates files under i:\support, uses a maximum of 11GB disk space on i: drive, uses a maximum of 8 threads, runs for 5 cycles, and uses SamllestFile 100MB.

Script output looks like:

Test-Disk



Powershell script to generate HTML report on files in given folders with specific extensions and size


11/03/2014 – v1.2

Added ‘Report run time’ at the bottom
Fixed bug when no files are found that match criteria
Turned into function
Bundled with EnhancvedHTML2
Added SizeUnit parameter

Screen output will look like:

ROF1

The HTML report will look like:

ROF2


A question was posted a few days ago on the Powershell.org Q&A forum:

I’m trying to get people to clean up old files. Never an easy job. To help them out, I want to generate reports of their department folders. One report would list their Powerpoint files, another PDFs and a third, zip files.

Many of us have been in this situation where data sprawl goes a bit out of control. This script helps produce HTML reports that can be customized to report on:

  • Files in several folders,
  • With specific file extensions,
  • Greater than a specific file size,
  • File properties reported on can also be customized

The script can be downloaded from the Microsoft Script Center Repository.

Sam Boutros (left) and Don Jones (right) - TechEd 2014 - Houston

Sam Boutros (left) and Don Jones (right) – TechEd 2014 – Houston

The script uses EnahncedHTML2 module which is written by Don Jones in 9/2013. I first met Don at TechEd 2014 in Houston where he delivered several sessions that I attended and enjoyed.  In spite of being one of the leading experts on Microsoft business technologies, he’s a down to earth guy who would take the time to answer a question or help out when needed.

To install EnhancedHTML2 module:

  1. Download it from the Powershell.org public OneDrive. Look under the Creating HTML Reports folder.
  2. Check your Powershell Module Path. Run $env:PSModulePath.Split(“;”) for example:ModPath
  3. Create a folder named “EnhancedHTML2” under any of the listed paths like c:\Program Files\WindowsPowerShell\Modules\EnhancedHTML2
  4. Copy the 2 files EnhancedHTML2.psd1 and EnhancedHTML2.psm1 to this folder (part of the downloaded files from #1 above)
  5. Finally run Import-Module EnahncedHTML2


Get-Busy.ps1 powershell script to create files on many PCs and collect metrics


This script uses Busy.ps1 which is a script that I posted earlier. This script can be downloaded from the Microsoft TechNet Gallery. To use this script you need to edit the 4 data entry lines on top:

GetBusy

  • $WorkFolder = “e:\support” # Folder on each VM where test files will be created
  • $MaxSpaceToUseOnDisk = 20GB # Maximum amount of disk space to be used on each VM’s $WorkFolder during testing
  • $VMPrefix = “V-2012R2-LAB” # We’ll use that to scope this script (only running VMs with name matching this Prefix will be processed)
  • $LocalAdmin = “administrator” # This is the local admin account on the VMs. You can also use a domain account here if you like.

The script requires 1 positional parameter to indicate whether you wish to start the testing on the VMs or stop it. For example to start:

.\get-busy.ps1 start

GS-017e40

 To end the testing, use:

 .\get-busy.ps1 stop

The script will reach out to the VMs being tested and stop the busy.ps1 script, collect the test results, and cleanup the $Workfolder on each VM.

The script generates 2 log files:

  • A general log file that contains the messages displayed on the screen about each action attempted.
  • A CSV file that contains the compiled test results from all the CSV files generated by each busy.ps1 script on each of the tested VMs

Here’s an example of the compiled CSV file Get-busy_20140714_071428PM.csv


Powershell script to generate file read/write activity to test storage performance


This script generates file read/write activity to test storage performance. Set the $WorkFolder and $MaxSpaceToUseOnDisk variables on top to indicate the folder where test files will be created and maximum amount of disk space to be used on $WorkFolder during testing respectively.

The script can be run with the -verbose switch to show more information during processing, like:

.\busy2.ps1 -verbose

As the $WorkFolder exceed 90% of the capacity indicated by the $MaxSpaceToUseOnDisk variable, the scripts deletes all test files and starts a new cycle. the script can be stopped by clicking CTRL-C or setting the registry key HKLM:\Software\Microsoft\Busy to 0

The script includes a recursive function to generate seed files of (decimal) exponential sizes to be used for file copy activities.

The script generates 2 log files. The first one has details on the files created. The second one is a CSV file that has a record for every cycle the script goes through, including cycle duration, sum of generated file sizes, number of files generated on this cycle, average file size, disk throughput, IOPS,…

Here’s an example CSV file output:

Cycle # Duration (sec) Files (GB) # of Files Avg. File (MB) Throughput (MB/s) IOPS (K) Machine Name Start Time End Time
1 337.67 95.35 19 5138.85 289.15 4.63 HV-LAB-05 07/10/2014 19:54 07/10/2014 20:00

The script can be downloaded from the Microsoft TechNet Gallery.

Busy2


7/15/2014:

Version 1.2 is here

The script displays output to the screen like:

It also logs the same to a text file like Busy_HV-LAB-05.txt and enters the statistics in a CSV file like Busy_HV-LAB-05.csv


Powershell script to live migrate all running VMs including storage from one host to another


Powershell Script to live migrate all running VMs; including storage; from one host to another. Enter the source and destination host names (or IPs) in lines 4 and 5. Enter the drive letters of the destination host where you wish to live migrate the source host VMs to in line 6.

Moveall2

You can download this script from the Microsoft TechNet Gallery.

The script live migrates the VMs:

Moveall1

It also leaves 2 files on the folder where it runs:

– A log file that shows different information about the source and destination hosts, and the VMs being migrated.

– A CSV file that shows one record per migrated VM listing the source path of each of its disks. This may be useful for failback..


Powershell script to setup NFS share on Server 2012 R2


The following script sets up NFS share on Server 2012 R2:

NFS1

# Script to setup NFS share on Server 2012 R2
# Sam Boutros – 7/7/2014
# References: http://technet.microsoft.com/en-us/library/jj603081.aspx,
# http://technet.microsoft.com/en-us/library/jj574143.aspx#BKMK_deploy
#
$NFSFolder = “d:\shares\NFS1” # Tye in the path to the folder to be shared via NFS
$NFSShare = “nfs1” # Type in the share name you wish to use
# End Data entry section
#
Import-Module ServerManager
Add-WindowsFeature FS-NFS-Service
Import-Module NFS
if (!(Test-Path $NFSFolder)) {New-Item -ItemType directory -Path $NFSFolder}
New-NfsShare -name $NFSShare -Path $NFSFolder
$ShareName = $env:COMPUTERNAME + “:/” + $NFSShare
Write-Output “NFS share has been created: $ShareName”

You can see the new share in Server Manager under File and Storage Services:

NFS7

The default NFS share properties are:

NFS2

NFS3

Under Share Permissions, I clicked Add, entered the IP address (or name) of the Linux host that needs to connect to this 2012 R2 NFS share, and selected the desired access (read/write):

NFS4

No changes to NTFS permissions:

NFS5

Finally, I enabled the following firewall rule to allow me to ping this server:NFS8

Next, I setup a Red Hat 6.5 VM to test with.  I picked v6.5 because

  1. It comes with the Hyper-V integration built in – no need for manual RTM installation,
  2. The Hyper-V integration server for 6.5 kernel allows for Host-based VSS backup – no need for guest agent inside the Linux machine. We get crash consistent backup (not application consistent backup), but that’s a big improvement from Hyper-V integration service for kernel version 6.4 and older,
  3. The Hyper-V integration service supports dynamic RAM. Again, with kernel versions 6.4 and older, we can only use static RAM with Linux guests

I downloaded the media ISO Boot and DVD files from Red Hat,

created VM with 2 DVDs so that I can mount both media during setup, followed the simple installation steps, rebooted

Next, I used the console (and later on Putty to SSH) to the new Red Hat machine, logged in as root,

NFS9

I ran the following commands:

ifconfig -a => show interfaces
ifconfig eth0 10.5.19.36 netmask 255.255.255.0 => to setup IP address and mask
ping 10.5.19.38 => confirm connection to NFS server (enabled ping rule in Windows firewall)
mount -t ext4 => to show partitions formatted with ext4 file system
mkdir /pub => to create local mount point directory /pub
mount 10.5.19.38:/nfs1 /pub (must have added 10.5.19.36/RW permission on NFS share on Server 2012)
cd /pub => to change directory to /pub
ls => to see files on remote NFS share
echo hello >test1.txt => to test creating a text file named test1

You might want to edit /etc/fstab and modify the following line to match your configuration. For example:

10.5.19.38:/nfs1 /pub nfs defaults 0 0

The files were visible also on the 2012 R2 server.

 


Powershell script to rename many computers and join them to AD domain


This script will go through all VMs on the current Hyper-V host, select those that match a given name pattern, rename them to match the VM Name (in Hyper-V), and join them to the domain.

CVM3

The script can be downloaded from the Microsoft TechNet Gallery.

The script leaves a log file in the folder where it runs that shows details of actions performed and their success/failure status.

In the V1.1 update, I added code to initialize and format VM disks..

The VMs can be created in bulk as shown in this post.

This script needs a running VM acting as DC and DHCP server as shown in this post.

 


Using Powershell to create many Hyper-V Virtual Machines on many LUNs asynchronously


In a prior post I put out a powershell script to create many Hyper-V virtual machines on multiple LUNs using the Create-VM.ps1 script. That script ran in a single thread creating one VM before moving on to the next. In another post I manually ran 8 scripts to achieve the goal of running multiple jobs at the same time. In this script I use Start-Job with ScriptBlock and -ArgumentList to run multiple jobs at the same time.

GS-015j

The script can be downloaded from the Microsoft TechNet Gallery.

Hardware:

Compute node (Hyper-V host): 2x Xeon E5-2430L CPUs at 2 GHz with 6 cores each (12 Logical processors each) and 15 MB L3 cache, 96 GB RAM, 2x 10Gbps NICs that are not RDMA capable, setup in a NIC team (Teaming mode: Switch Independent, Load balancing mode: Hyper-V Port). Storage is 4x LUNs from a 3-node Gridstore array. Each LUN is configured as IOPS 2+1 LUN. Each Gridstore storage node has  1x Xeon E5-2403 processor at 1.8GHz with 4 cores (no hyper-threading) and 10 MB L3 cache, 32GB DDR3 1333 MHz DIMM, 4x 3TB 7200 RPM SAS disks, a 550GB PCIe Flash card, and 2x 10Gbps NICs that are not RDMA capable, setup in a NIC team (Broadcom Smart Load Balancing and Failover = switch-independent, no LACP support needed on switch).

The script took 9 minutes and 45 seconds to create the 40 VMs. During that time the Hyper-V host resource monitor showed:

GS-015a

GS-015b

GridControl snap-in showed:

GS-015c

GS-015d

GS-015e

I cal also see script logs piling up during script execution:

GS-015f

I started the 40 VMs manually after the script finished:

GS-015g

This excel file is based on the script output summary CSV file.

GS-015h

GS-015i


Conclusion and important points to note:

  • Hyper-V performance summary: No CPU or memory bottleneck observed during the test.
  • Array performance summary:
    • Files copies: 40
    • File size: 8.93GB
    • Concurrent operations: 4 copy operations at the same time
    • Total vLUNs used: 4
    • Average file copy duration: 10.18 seconds
    • Average throughput: 902.86 MB/s (6 Gbps)
    • Using the formula IOPS = BytesPerSec / TransferSizeInBytes
      LUNs are formatted as 64 KB blocks
      Average IOPS = (902.86*1024)/64 = 14.45k IOPS
  • Although 20 Gbps aggregate bandwidth is available to each of the compute node and the 3 storage nodes, I have not been able to produce network traffic above 10 Gbps.
  • CPU on the storage nodes was around 90% during the copy. The storage nodes can benefit from additional processing capacity.

Setting up Hyper-V lab using Powershell


In this post I setup a Hyper-V lab to test VM performance on Gridstore enterprise storage array.

Hardware: Compute node (Hyper-V host): 2x Xeon E5-2430L CPUs at 2 GHz with 6 cores each (12 Logical processors) and 15 MB L3 cache, 96 GB RAM, 2x 10Gbps NICs that are not RDMA capable. Storage is 8x LUNs from a 6-node Gridstore array detailed in this post.

I have Hyper-V role installed on this server. Next I setup NIC team and a vSwitch using this script:

GS-vSwitch

# Script to create NIC team, vSwitch
# Sam Boutros
# 6/28/2014
#
$PhysicalNICs = “NIC1,NIC2” # Get these names from Get-NetAdapter command
$NICTeamName = “Team1”
$vSwitchName = “My_vSwitch” # Pick a name for your vSwitch
$ParentPartitionvNICName = “My_vNIC” # Pick a name for your PP vNIC
$VLAN = 19
# End Data Entry section
#
# Create NIC Team
New-NetLbfoTeam -Name $NICTeamName -TeamMembers $PhysicalNICs -LoadBalancingAlgorithm HyperVPort -TeamingMode SwitchIndependent
# Create vSwitch
New-VMSwitch -Name $vSwitchName -NetAdapterName $NICTeamName -AllowManagementOS $False -MinimumBandwidthMode Weight
Set-VMSwitch $vSwitchName -DefaultFlowMinimumBandwidthWeight 50
# Create vNIC on this new vSwitch for the parent partition (Hyper-V host OS)
Add-VMNetworkAdapter -ManagementOS -Name $ParentPartitionvNICName -SwitchName $vSwitchName
# Comment out the following line if you’re not using VLANs
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName $ParentPartitionvNICName -Access -VlanId $VLAN

Using a previously sys-prepped server 2012 R2 VHDX file (golden image), I manually create a VM to be used as DC for new lab test domain and DHCP server.

Install Active Directory Domain Services, DNS server, and DHCP server roles.

Configure Active Directory: new forest, new domain, forest level and domain level: 2012 R2, reboot.

Authorize DHCP server:

GS-010b

Create, configure, and activate new DHCP scope:

GS-010c

GS-010d

I got/set the MAC addresses to be given out by my Hyper-V host:

GS-010e

I added an Allow Filter to ensure that this DHCP server gives out IPs to the VMs of this host only and not any other machine in VLAN 19:

GS-010f

Now we’re ready to spin some VMs!

See this post for a script to create many VMs in bulk.

And this post for renaming them and joining them to the domain.


Using Powershell to create many Hyper-V Virtual Machines in parallel on Gridstore array


In a prior post I put out a powershell script to create many Hyper-V virtual machines on multiple LUNs using the Create-VM.ps1 script. That script ran in a single thread creating one VM before moving on to the next. In this test of the Gridstore array I ran 8 scripts at the same time in parallel.

GS-013a

# Script to create 8 test VMs on a specific LUN on current HyperV Host at a fixed point in time.
# Uses Create-VM.ps1 from https://superwidgets.wordpress.com/category/powershell/
# Sam Boutros – 7/1/2014
#
$GoTime = 40 # minute
$VMPrefix = “V-2012R2-LABk”
$VMrootPath = “k:\VMs”
$NumberofVMs = 8 # Per target LUN
#
# Common variables
$VMG = 2
$VMMemoryType = “Dynamic”
$VMStartupRAM = 1GB
$VMminRAM = 512MB
$VMmaxRAM = 1GB
$vSwitch = “Gridstore_vSwitch”
$VMCores = 2
$VLAN = 19
$AdditionalDisksTotal = 2
$AdditionalDisksSize = 1TB
$GoldenImageDiskPath = “E:\Golden\V-2012R2-3-C.VHDX”
$CSV = (Get-Location).path + “\IOPS_” + (Get-Date -format yyyyMMdd_hhmmsstt) + “.csv”
#
Write-Output “Waiting to start at the $GoTime minute”
do {start-sleep 1} until ((Get-Date).Minute -eq $GoTime) # Wait until GoTime
For ($j=1; $j -lt $NumberofVMs+1; $j++) {
$VMName = $VMPrefix + $j
$VMFolder = $VMRootPath + “\” + $VMName
.\Create-VM.ps1 -VMName $VMName -VMFolder $VMFolder -VMG $VMG -VMMemoryType $VMMemoryType -VMStartupRAM $VMStartupRAM -VMminRAM $VMminRAM -VMmaxRAM $VMmaxRAM -vSwitch $vSwitch -VMCores $VMCores -VLAN $VLAN -AdditionalDisksTotal $AdditionalDisksTotal -AdditionalDisksSize $AdditionalDisksSize -GoldenImageDiskPath $GoldenImageDiskPath -CSV $CSV
Start-VM -Name $VMName
}

The other 7 scripts were identical, except for the last letter of the $VMPrefix and the drive letter of the $VMRootPath.

The line do {start-sleep 1} until ((Get-Date).Minute -eq $GoTime) ensures that all 8 scripts kick off within 1 second of each other, essentially starting at the same time.

GS-013b

GS-013c

The Hyper-V host was clearly stressed:

GS-013d

GS-013e

GS-013f

The GridControl snap-in showed CPU utilization on the Gridstore storage nodes was holding around 60%:

GS-013g

Write process on the storage nodes hits all 6 nodes:

GS-013h

Read requests hit 4 storage nodes:

GS-013i

Here’s a copy of the metrics summary script output.

One of the 8 scripts had an error:

GS-013j

GS-013k

The error was that the script tried to create VM too fast. The interesting thing here is the magenta error message in this screen shot. It’s from an error handling code in the Create-VM.ps1 script. The script log file Create-VM_V-2012R2-LABk2_20140701_034214PM.txt showed:

2014.07.01 03:42:14 PM: Starting with paramters:
2014.07.01 03:42:14 PM:
2014.07.01 03:42:14 PM: VMName: V-2012R2-LABk2
2014.07.01 03:42:14 PM: VMFolder: k:\VMs\V-2012R2-LABk2
2014.07.01 03:42:14 PM: vSwitch: Gridstore_vSwitch
2014.07.01 03:42:14 PM: GoldenImageDiskPath: E:\Golden\V-2012R2-3-C.VHDX
2014.07.01 03:42:14 PM: VMG: 2
2014.07.01 03:42:14 PM: VMMemoryType: Dynamic
2014.07.01 03:42:14 PM: VMStartupRAM: 1073741824 – VMStartupRAM (calculated):
2014.07.01 03:42:14 PM: VMminRAM: 536870912 – VMminRAM (calculated):
2014.07.01 03:42:14 PM: VMmaxRAM: 1073741824 – VMmaxRAM (calculated):
2014.07.01 03:42:14 PM: VMCores: 2 – VMCores (calculated):
2014.07.01 03:42:14 PM: VLAN: 19 – VLAN (Calculated):
2014.07.01 03:42:14 PM: AdditionalDisksTotal: 2 – AdditionalDisksTotal (calculated):
2014.07.01 03:42:14 PM: AdditionalDisksSize: 1099511627776 – AdditionalDisksSize (Calculated): 1099511627776
2014.07.01 03:42:14 PM: .
2014.07.01 03:42:14 PM: Creating VM with the following paramters:
2014.07.01 03:42:14 PM: VM Name: ‘V-2012R2-LABk2’
2014.07.01 03:42:14 PM: VM Folder: ‘k:\VMs\V-2012R2-LABk2’
2014.07.01 03:42:14 PM: VM Generation: ‘2’
2014.07.01 03:42:14 PM: VM Memory: Dynamic, Startup memory: 1,024 MB, Minimum memory: 512 MB, Maximum memory: 1,024 MB
2014.07.01 03:42:14 PM: vSwitch Name: ‘Gridstore_vSwitch’
2014.07.01 03:42:14 PM: VM CPU Cores: ‘2’
2014.07.01 03:42:14 PM: Copying disk image k:\VMs\V-2012R2-LABk2\V-2012R2-LABk2-C.VHDX from goldem image E:\Golden\V-2012R2-3-C.VHDX
2014.07.01 03:42:41 PM: Copy time = 0 : 27 : 762 (Minutes:Seconds:Milliseconds) – 00:00:26.7623983 Milliseconds
2014.07.01 03:42:41 PM: File k:\VMs\V-2012R2-LABk2\V-2012R2-LABk2-C.VHDX size: 9,148 MB (9592373248 bytes)
2014.07.01 03:42:41 PM: Throughput: 342 MB/s (341.822877660408 MB/s)
2014.07.01 03:42:41 PM: or: 2,735 Mbps (2734.58302128326 Mbps)
2014.07.01 03:43:32 PM:
2014.07.01 03:43:32 PM: Error: Failed to create VM ‘V-2012R2-LABk2’.. stopping
2014.07.01 03:43:32 PM: Error details: The operation cannot be performed while the virtual machine is in its current state.[The operation cannot be performed while the virtual machine is in its current state..count-1]

Windows event viewer search showed:

GS-013l

So it appears that this “k” script working to create 8 VMs on drive “K” sent New-VM request at 3:43:32 (line 303 of CreateVM.ps1). That request took 11 seconds to complete as shown in event ID 13002 above. In the mean time, the script’s subsequent error checking lines 304, 305 detected that the VM has not bean created and aborted execution as designed.

On another note, I’m sure there are better ways to run powershell commands or scripts in parallel. I’ve looked into The [RunspaceFactory] and [PowerShell] Accelerators while running powershell in Multithreaded Apartment (powerhsell.exe -mta). I’ve also tried Updated Type Accelerator functions for PowerShell 3.0 and 4.0. I have tried the Start-Job/Get-Job cmdlets with script blocks, but had hard time passing parameters to Create-VM.ps1 with $ScriptBlock and -ArgumentList. I’ve also looked into ForEach-Parallel powershell workflow command. I simply needed to get this testing done quickly and did not have time to find a better way to run tasks in parallel in powershell. I welcome any comments or suggestions on better ways to run powershell scripts in parallel.


Conclusion and important points to note:

  • This set of scripts ran tasks that attempted to create 64 VMs on 8 Gridstore vLUNs. It did so by running 8 scripts in parallel, each script attempted to create 8 VMs on a different vLUN. 55 VMs were created successfully. Script failures were tracked down to busy/overwhelmed physical host.
  • Similar to the last test, each of the 8 vLUNs is configured as an IOPS (2+1) LUN
  • Network bandwidth utilization was completely maxed out on the testing Hyper-V host (10 Gbps Ethernet) I will use NIC teams to provide 20 Gbps Ethernet bandwidth
  • Storage nodes’ CPU utilization was at around 60% in this test, which is not a bottleneck.
  • This test is essentially a disk copy test as well and not a Hyper-V virtual machine performance test.
  • Summary comparison between this and the last test:

GS-013m

The throughput values under Gbps and GB/Min. are meant to compare parallel versus serial execution testing and not as metrics for the storage array, because they include time to create and configure virtual machines in addition to time taken by disk operations.


Using Powershell to create 64 Hyper-V Virtual Machines on Gridstore array


This script uses another script Create-VM.PS1 from a prior post. It creates 64 Hyper-V virtual machines on 8 different LUNs. It creates them synchronously (one after the other). The 8 LUNs are on a 6 node GridStore array using H-nodes. Details of the Gridstore array setup are in this post.

GS-012i

# Script to create 64 test VMs on 8 diffent LUNs on current HyperV Host
# Uses Create-VM.ps1 from https://superwidgets.wordpress.com/category/powershell/
# Sam Boutros – 7/1/2014
#
$VMPrefix = “V-2012R2-LAB”
$VMG = 2
$VMMemoryType = “Dynamic”
$VMStartupRAM = 1GB
$VMminRAM = 512MB
$VMmaxRAM = 1GB
$vSwitch = “Gridstore_vSwitch”
$VMCores = 2
$VLAN = 19
$AdditionalDisksTotal = 2
$AdditionalDisksSize = 1TB
$GoldenImageDiskPath = “E:\Golden\V-2012R2-3-C.VHDX”
$CSV = (Get-Location).path + “\IOPS_” + (Get-Date -format yyyyMMdd_hhmmsstt) + “.csv”
$VMFirstNumber = 1 # Starting number
$TargetLUNs = @(“e”,”g”,”h”,”i”,”j”,”k”,”l”,”m”)
$NumberofVMs = 8 # Per target LUN
#
foreach ($LUN in $TargetLUNs) {
$VMrootPath = $LUN + “:\VMs”
For ($j=$VMFirstNumber; $j -lt $NumberofVMs+$VMFirstNumber; $j++) {
$VMName = $VMPrefix + $j
$VMFolder = $VMRootPath + “\” + $VMName
.\Create-VM.ps1 -VMName $VMName -VMFolder $VMFolder -VMG $VMG -VMMemoryType $VMMemoryType -VMStartupRAM $VMStartupRAM -VMminRAM $VMminRAM -VMmaxRAM $VMmaxRAM -vSwitch $vSwitch -VMCores $VMCores -VLAN $VLAN -AdditionalDisksTotal $AdditionalDisksTotal -AdditionalDisksSize $AdditionalDisksSize -GoldenImageDiskPath $GoldenImageDiskPath -CSV $CSV
Start-VM -Name $VMName
}
$VMFirstNumber += $NumberofVMs
}

During the script execution the Hyper-V resource monitor showed the following:

GS-012a

GS-012b

The GridControl snap-in showed:

GS-012c

GS-012d

GS-012e

I can also see the VMs popping up in Hyper-V Manager:

GS-012f

and their files in the file system:

GS-012g

GS-012h

This file is derived from the script’s CSV file output.. It shows:

GS-012j
9 GB file average copy time: 10.83 seconds
GS-012k

9 GB file copy average throughput 852.5 MB/s

GS-012l

9 GB file copy average throughput 6,820.1 Gbps


Conclusion and important points to note:

  • Script ran in serial, creating 1 VM on 1 LUN, and after that’s done moving on to the next VM on the same LUN, then moving on to the next LUN.
  • Each LUN is configured as an IOPS (2+1) LUN. So, every write process is writing to 3 disks out of the array 24 total disks (whereas a read process reads from 2 disks in the LUN). Additional throughput is likely to be achieved by testing scenarios where we’re writing to all 8 LUNs simultaneously hitting 18 of the array disks at the same time.  
  • Network bandwidth utilization is at about 68.2% capacity of the 10 Gbps Ethernet used in this test. for the next test (in parallel) I will use NIC teams to provide 20 Gbps Ethernet bandwidth
  • Storage nodes’ CPU utilization was at around 50% in this test, which is not a bottleneck.
  • This test is essentially a disk copy test and not a Hyper-V virtual machine performance test. Hyper-V testing with Gridstore will be shown in a future post.
  • Using the formula IOPS = BytesPerSec / TransferSizeInBytes
    LUNs are formatted as 64 KB blocks
    Average IOPS = (852.5*1024)/64 = 13.64k IOPS