Hyper-V

Deploying StorSimple On-Premises Virtual Array (OVA) via GUI tools


The StorSimple model 1200 OVA (On-Premises Virtual Array) is available as VHD/VHDX or VMDK file to be deployed on local Hyper-V or VMWare hypervisor.

Note that the StorSimple OVA model 1200 is incompatible with the StorSimple 8k series physical and virtual devices (8100, 8600, 8010, 8020). This means we cannot recover volumes from 8k device to a 1200 OVA device or vice versa.

1. Deploy ‘Virtual Device Series’ StorSimple Manager:

You cannot deploy an OVA under your ‘Physical Device Series’ StorSimple Manager service. To deploy a ‘Virtual Device Series’ StorSimple Manager follow these steps in the classic portal:

ova01

Uncheck the box at the bottom to create a Storage Account.

Note that OVA is available on the following Azure regions as of 20 October 2016:

  • Australia East
  • Australia Southeast
  • Brazil South
  • East Asia
  • Southeast Asia
  • East US
  • West US
  • Japan East
  • Japan West
  • North Europe
  • West Europe

Enter a name for your StorSimple Manager service.

2. Create a Storage Account

I prefer to manually create a Storage Account instead of having one created automatically, to be able to give it a name that makes sense for the deployment, and becomes easy to identify and recognize later on.

ova04

Make sure the Storage Account is in the same Azure region as the StorSimple Manager service.

3. Download the OVA image file

Under the new StorSimple Manager service/devices/create virtual device:

ova02

You’ll see a page like:

ova03

Click the link under item #1 that corresponds to your hypervisor to download the OVA file. Copy the Registration Key at the bottom. It will be used later in step x to register the OVA with the StorSimple Manager service.

Extract the .ZIP file

ova05

4. Provision a VM for the OVA:

I’m using Hyper-V on Server 2012 R2 in this example. Minimum VM specs: 4 cores, 8 GB of RAM, 500 GB disk space for drive c: (system disk).

ova06

Gen 2 is supported and recommended when using VHDX image on Server 2012 R2

ova07

According to Microsoft, dynamic memory is not supported 😦ova08

Connect to the Hyper-V switch of your choice. Use the downloaded disk:

ova09

Click Next and Finish. Go back the VM settings/Processor, and select to use 4 cores:

ova10

Add a second disk to the VM under the SCSI controller. Set it as 500 GB dynamically expanding disk.

ova11

Start the VM and login to it. This takes several minutes. The default user is StorSimpleAdmin and the default password is Password1. Login and change the password (8 character minimum). The OVA image has a Core version of Server 2012 R2, and if DHCP server is available it picks up an IP address:

ova12

An extremely limited set of commands is available:

ova13

However, Microsoft has made the support mode available without the need for a decryption tool:

ova25

This exposes the entire PowerShell capabilities for admins to manage the device.

ova26

This is really a good decision on Microsoft’s part. The current local web interface has many idiosyncrasies that can be frustrating for a device admin. Having the option to manage the device via PowerShell goes a long way towards faster device adoption and customer satisfaction in my opinion and experience.

Although not required, I recommend using a static MAC address for the OVA VM. To do so shut down the VM from Hyper-V Manager, then under settings\network\advanced, select static MAC:

ova14

Start the VM.

5. Configure the OVA via the local web interface

Browse to the OVA IP address, and bypass the local certificate warning in the browser. Login with the new password you created in the prior step.

ova15

Under configuration/network settings, I recommend using a static IPv4 address

ova18

Notes:

  • By default, the OVA will attempt to get IP address if there’s DHCP server in the environment.
  • To view/change the IP address configuration in the local web interface, if you try to change the DNS server IP it will error out. A work around is to change it back to DHCP, apply, browse to the DHCP IP, login, change it back to static IP and make all the needed changes in one step. In other words, you must change IP address and DNS server address in one step or it fails to accept the changes’
  • There’s no way to remove IPv6 information in the local web interface

Browse to the new IP address to continue. For this post I’m using the device as an iSCSI SAN. I settled on leaving the device in ‘workgroup’:

ova19

Note:

I was unable to join an on-premises AD domain:

ova17

and entered credentials as:

ova21

But got the error message “Domain does not exist”!!??

ova20

I attempted to use the NetBIOS names (sam1 domain and sam1\administrator user) but got the same error.

I verified connectivity between the DC and the OVA, running these commands on the DC:

ova22

I also verified that the DC is responding to DNS queries. I ran the following command from a 3rd computer:

ova23


I skipped Proxy settings, since I’m not using a proxy to get to the Internet in this environment.

Interestingly enough, Time Server settings accepted the local DC with no problem:

ova24

Finally, I registered the device with the StorSimple Manager Service by entering the Service Registration Key. This was my first device on this StorSimple Manager Service, so I recorded the Service Data Encryption Key received upon successful registration.

Notes:

  • If this is not the first device to be registered with this StorSimple Manager service, you’ll need the Service Data Encryption Key as well to be able to register the device
  • You must have 3 green check marks at the Network, Device, and Time settings to be able to register the device under Cloud setting

ova27

6. Complete OVA configuration in Azure

In the classic portal (24 October 2016), click on your StorSimple Manager Service/Devices link and you should see the newly registered OVA

ova27

Click on that and click Complete Device Configuration

ova28

In the next screen, select a Storage Account. I recommend checking the box to Enable Cloud Storage Encryption, and entering a 32 character seed for at-rest encryption of data blocks that the device sends to the Azure Storage Account:

ova29

StorSimple Manager Services completes the following tasks:

ova30

 

Advertisements

Running Powershell script functions


Many of the scripts I write contain reusable code as functions. For example, the Merge-VMDisks.PS1 script contains Merge-VMDisks function. To use these functions, you must load them first into memory in the current Powershell session. Running the PS1 file will do just that; load the function in memory. It will NOT run the function.

Powershell stores a list of the currently available functions in the function: drive. To see available drives type:

Get-PSDrive

You will get a result similar to:

Function1To explore the contents of a PS drive, we can use the Get-Item cmdlet like:

Get-Item -Path function:

You will get a result similar to:

Function2In this example, to use the Merge-VMDisks function we need to load it into memory first in the current PS session by running the PS1 file:

E:\Install\Scripts\Merge-VMDisks.ps1
Get-Item -Path function:

Now running the Get-Item cmdlet shows 3 new functions loaded – that we got form the Merge-VMDisks.ps1 script:

Function3

Now that we have the function in memory, we can use it by invoking the function as we do any PS cmdlet. For example:

Merge-VMDisks -VMName ‘MyVM’

 

 

 


Powershell Script to move VHD(x) from one Hyper-V VM to another


This script will detach a VHD(x) disk from one Hyper-V VM and attach it to another. If the guest OS is Windows 2012 or above, this is safe to do directly (obviously not with system\boot partition). Older guest Windows OS’s will blue-screen if a disk is yanked without off-lining it first in the guest OS. The script can be downloaded from the Microsoft Script Center Repository.

For example:

Move-VHD -SourceVM vHost22 -TargetVM v-2012R2-G2a -VHDX ‘vHost01d(Web)-D.vhdx’ -Verbose

Will detach the VHDx disk ‘vHost01d(Web)-D.vhdx’ from vHost22 VM and attach it to v-2012R2-G2a VM

RegexSafe5

 This script uses the RegexSafe Powershell function described here.


Function/tool to return Regex-safe version of input string


Some of Powershell comparison operators use Regular Expressions, such as -match, -notmatch, and -replace operators. This poses a problem when trying to match against a string that contains Regex metacharacters. This function tools solves this issue by accepting an input string as input and returning a Regex-safe version of the same string where every Regex metacharacter in the input string is escaped.

The script can be downloaded from the Microsoft Script Center Repository. To use this function download it, unblock the file, and run it to load the function.

Example:

Imagine you wish to make a PS script to detach a VHD(X) disk from one Hyper-V VM and attach it to another. The script may start like this:

# Input:
$SourceVM = ‘v-2012R2-G2a’
$TargetVM = ‘vHost22’
$VHDX = ‘vHost01d(Web)-D.vhdx’

This next section will show current attached disks:

“Before:”
Get-VMHardDiskDrive -VMName $SourceVM
Get-VMHardDiskDrive -VMName $TargetVM

RegexSafe2

At this point, if we try to identify the disk that needs to be detached from one VM and attached to another using the input data:

Get-VMHardDiskDrive -VMName $SourceVM | Where { $_.Path -match $VHDX }

This cmdlet returns no matches. This is because the string we’re comparing to ‘vHost01d(Web)-D.vhdx’ contains 3 Regex metacharacters, namely ‘().’

This issue can be remedied by the use of this RegexSafe function:

Get-VMHardDiskDrive -VMName $SourceVM | Where { $_.Path -match (RegexSafe $VHDX) }

RegexSafe3

The full script to move a VHD(x) disk from one VM to another can be found here.


Get-VMMetering script to collect and reset VM Metering data, report to CSV


This script can be downloaded from the Microsoft Script Center Repository. It can be set as a scheduled task on one of the Hyper-V hosts in the environment, not all of them.

Set the schedule of the scheduled task to run as often as you’d like to have the VM metering data collected and reset.

Edit the top 3 lines to match your environment details:

  • $CSV = “d:\sandbox\MeteringReports”
    • Edit this line to enter the path to the folder to save CSV files. This can be a UNC path like “\\server\share\folder”
  • $HVHosts = @(“Host1″,”Host2”)
    • Edit this line to list Hyper-V hosts in your environment
  • $Sort = “AvgCPU”
    • Edit this line to change the report sort order. Options include: AvgCPU, AvgRAM, MaxRAM, MinRAM, TotalDisk, NetworkInbound, NetworkOutbound, VMName, ComputerName

Report data and output will look like:

Metering1


Powershell script to merge Hyper-V Virtual Machine disks


In some situations you might find a VM disk to be part of a series of differencing disks. Take this example:

Merge4

If this was the result of VM Checkpoints, the fix would be easy: simply delete the checkpoints which merges the disks. But his is not the case. Hyper-V Manager shows no checkpoints:

Merge9

Powershell confirms (notice no output):

Merge10

This script shuts down the VM and merges its disks. It uses the Get-ParentPath function.

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

To use this script, download it, run it as administrator, then use the function.

To see help:

Merge11

For example:
Merge-VMDisks -VMName ‘MyVM’
Merge1
This may take some time depending on disk sizes and underlying storage system speed.
Merge3
The script leaves a log file shows the same steps on the console.
This is the picture after the merge is done:
Merge5
Merge6
If the script is run on a VM that has no disks to be merged, no changes are made:
Merge8
The script prompts for confirmation before shutting down the VM:
Merge7
This can be bypassed by using the -Confirm parameter as shown above.
Script help output looks like:
NAME
    Merge-VMDisks
    
SYNOPSIS
    Function to merge VM disks
    
SYNTAX
    Merge-VMDisks [-VMName]  [[-LogFile] ] [-WhatIf] [-Confirm] []
    
DESCRIPTION
    Function/script to merge VM disks. The script will power down the VM in the process.

PARAMETERS
    -VMName 
        Name of the VM whose VHD(x) disks are to be merged
        
        Required?                    true
        Position?                    1
        Default value                
        Accept pipeline input?       true (ByValue, ByPropertyName)
        Accept wildcard characters?  false
        
    -LogFile 
        Name and path of the file where the script will log its steps and progress
        
        Required?                    false
        Position?                    2
        Default value                ".\Merge-VMDisks_$(Get-Date -format yyyyMMdd_hhmmsstt).txt"
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -WhatIf []
        
        Required?                    false
        Position?                    named
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
        
    -Confirm []
        
        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, PipelineVariable, and OutVariable. For more information, see 
        about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 
    
NOTES
    
        Function by Sam Boutros
        v1.0 - 11/01/2014
    
    -------------------------- EXAMPLE 1 --------------------------
    
    C:\PS>Merge-VMDisks -VMName 'v-2012R2-VBR1'
    
RELATED LINKS
    https://superwidgets.wordpress.com/category/powershell/


Powershell script to get parent disk/path tree of VHD(x) file


In some situations you might find a VM disk to be part of a series of differencing disks. Take this example:

PPath1

If this was the result of VM Checkpoints, the fix would be easy: simply delete the checkpoints which merges the disks. But his is not the case. Hyper-V Manager shows no checkpoints:

PPath2

Powershell confirms (notice no output):

PPath3

This script is the first step to a fix. It lists the disk parent tree. The script can be downloaded from the Microsoft Script Center Repository.

To use this script, download it, run it as administrator, then use the function. To see help:

PPath5

You will see output like:

NAME
 Get-ParentPath
 
SYNOPSIS
 Function to get parent disk/path tree of VHD(x) file
 
SYNTAX
 Get-ParentPath [-VHDPath] <String> [[-ComputerName] <String>] [-WhatIf] [-Confirm] 
[<CommonParameters>]
 
DESCRIPTION
 Function to get parent disk/path tree of VHD(x) file
 
PARAMETERS
 -VHDPath <String>
 Full path to the VHD(x) file.
 For example: 
"I:\VMs\v-2012R2-G2a\v-2012R2-G2a-C_55DB25B0-EFA9-415F-A5D1-738A62742B4E.avhdx"
 
 Required? true
 Position? 1
 Default value 
 Accept pipeline input? true (ByValue, ByPropertyName)
 Accept wildcard characters? false
 
 -ComputerName <String>
 Name of Hyper-V host where the VHD(x) file resides
 If absent, defaults to localhost
 
 Required? false
 Position? 2
 Default value .
 Accept pipeline input? false
 Accept wildcard characters? false
 
 -WhatIf [<SwitchParameter>]
 
 Required? false
 Position? named
 Default value 
 Accept pipeline input? false
 Accept wildcard characters? false
 
 -Confirm [<SwitchParameter>]
 
 Required? false
 Position? named
 Default value 
 Accept pipeline input? false
 Accept wildcard characters? false
 
 <CommonParameters>
 This cmdlet supports the common parameters: Verbose, Debug,
 ErrorAction, ErrorVariable, WarningAction, WarningVariable,
 OutBuffer, PipelineVariable, and OutVariable. For more information, see 
 about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 
 
INPUTS
 
OUTPUTS
 
NOTES
 Function by Sam Boutros
 v1.0 - 11/01/2014
 
 -------------------------- EXAMPLE 1 --------------------------
 
 Get-ParentPath -VHDPath 
"I:\VMs\v-2012R2-G2a\v-2012R2-G2a-C_55DB25B0-EFA9-415F-A5D1-738A62742B4E.avhdx" 
-ComputerName "xhost16"
 
 Retunrs an array of the disk path and all its parents paths
 
 -------------------------- EXAMPLE 2 --------------------------
 
 $VMName = "v-2012R2-G2a"
 $HVName = "xHost16"
 $VMDisks=Invoke-Command -ComputerName $HVName -ArgumentList $VMName -ScriptBlock { 
     Param($VMName)
     Get-VMHardDiskDrive -VMName $VMName
 }
 ($VMDisks.Path | Where { $_ -match ":" }) | % {
     Get-ParentPath -VHDPath $_ -ComputerName $HVName
 }
 
 Retunrs an array for each disk attached to the VM $VMName, containing the disk tree.

 Sample output:
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-C_55DB25B0-EFA9-415F-A5D1-738A62742B4E.avhdx
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-C_0020A6D3-0371-48E3-B67D-DE2ADF0BEDF1.avhdx
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-C_C2BA8DE5-8FE6-49AD-B12B-789853306524.avhdx
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-C_79E7AFEB-F867-4068-A3DA-6BF64F49E819.avhdx
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-C_232D8FD8-5855-4518-800C-2659385521FA.avhdx
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-C.VHDX
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-D_C492420D-011D-42F4-862A-A04A7222B7FC.avhdx
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-D_7B0A54C4-36E5-4229-9746-49566B0566AF.avhdx
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-D_460EDAAF-F30A-4744-8396-87449EAF1A8C.avhdx
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-D_9D3805B2-79F5-4E5F-865D-D69620E31B6A.avhdx
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-D_F37513BE-AD00-41FD-B24E-CBB3E0BDEFC4.avhdx
 I:\VMs\v-2012R2-G2a\v-2012R2-G2a-D.vhdx
 
RELATED LINKS
 https://superwidgets.wordpress.com/category/powershell/

Powershell script/function to expand system/boot disk on Windows XP/2003 VMs


In Windows 7 and Server 2008 virtual machines and above, expanding the boot/system disk is a simple matter of expanding it in the hypervisor, then expanding it in the guest OS in the Computer Management/Disk Management GUI. In Windows XP/Server 2003 guest VMs, expanding the boot/dystem disk is not available via native Windows tools.

This script leverages Server 2012 R2 hypervisor capabilities to expand boot/system disk on a guest VM running Windows XP/2003 OS. The script leaves a log file behind listing steps taken. The script can be downloaded from the Microsoft Script Center Repository.

To use it: Download the attached file, unblock it, adjust PS execution policy as needed, run the script to load the function in memory, then use this line to get detailed help and examples as shown below:

expand1

Note: The script will shutdown the VM during this process.

For example, if you down the VM, and expand the disk in Hyper-V Manager GUI:

Diskc10

In the VM, you cannot expand the boot/system partition with native Windows 2003/XP tools:

Diskc11

You can do that with this script. On the Hyper-V host where the VM is running, run:

Expand-C -VMName MyVM1 -Size 17GB -BackupPath "d:\save"

The script will

  • Backup the VHDX file before expanding it if the ‘BackupPath’ is used
  • Convert the file from VHD to VHDX format if it was a VHD file. In this case you’ll need to delete the old .vhd file manually.
    Diskc3
  • Down the VM (gracefully)
    Diskc7
  • Expand the VHDX file
  • Expand the partition
  • Re-attach the C: drive disk file to the VM
  • Start the VM Diskc8
  • Leave a log file listing the steps taken Diskc9

 

 


Windows 10 Technical Preview – Hyper-V Integration


After installing Windows 10 Technical Preview on Windows Server 2012 R2, I checked the integration service. In Hyper-V Manager on the 2012 R2 host, all looked normal:

Win10a29

Running the following Powershell command on the 2012 R2 Hyper-V server showed that the Windows 10 Technical Preview VM comes with Integration Service version 6.4.9841

Win10a28

 

This command shows more details:

Win10a30

Running this comparison between Integration services for the this Windows 10 VM and a Server 2012 R2 VM:

Compare-Object -ReferenceObject (Get-VMIntegrationService -VMName v-Win10a | select *) -DifferenceObject (Get-VMIntegrationService -VMName v-2012R2-G2a | select *)

showed no difference (This does not show or compare integration service version.)


Create simultaneous checkpoints of a group of related Virtual Machines


In some cases you may need to checkpoint a group of related VMs at exactly the time, such as a SharePoint farm, or a multi-tiered application. The process includes pausing, saving the VMs, creating checkpoints, restrating, and eventually restoring back to original state. Powershell can help automate the process:

1. Pause and Save:

# Input
$HVHost = “xHost16”
$VMs = “SSTest1″,”V-2012R2-Test1″,”v-2012R2-TW01”

# Pause and Save
Stop-VM -Name $VMs -Save
# Confirm
Get-VM -ComputerName $HVHost -Name $VMs | Select VMName,State,ComputerName | FT -AutoSize

SimulCheck1

2. Checkpoint:

# Checkpoint
Checkpoint-VM -ComputerName $HVHost -Name $VMs
# Confirm
Get-VMSnapshot -ComputerName $HVHost -VMName $VMs | Select VMName, Name, ComputerName | FT -AutoSize

SimulCheck2

3. Restart:

# Restart
Start-VM -ComputerName $HVHost -Name $VMs
# Confirm
Get-VM -ComputerName $HVHost -Name $VMs | Select VMName, State, ComputerName | FT -AutoSize

SimulCheck3

Eventually, when it’s time to restore the group of VMs to their original state:

4. Remove all checkpoints:

# Later on, to remove all checkpoints:
Remove-VMSnapshot -ComputerName $HVHost -VMName $VMs -IncludeAllChildSnapshots
# Confirm
Get-VMSnapshot -ComputerName $HVHost -VMName $VMs | Select VMName, Name, ComputerName | FT -AutoSize

< no output>..

SimulCheck4