B. Nice to know:
1. How to search for a VM guest based on its IP or MAC address:
Get-Vm |Get-VirtualNetworkAdapter |Where {$_.IPv4Addresses -like "192.168.123*"} | Select Name, IPv4Addresses
Get-Vm |Get-VirtualNetworkAdapter |Where {$_.MACAddress -like "00:15:5D:*"} | Select Name, MACAddress
It seems not to be possible to search for VM guests based on theyr IP address ussing the graphical user interface in VMM.
And getting host names based on MAC address:
Get-VMHost | %{ get-scvmhostnetworkadapter -VMHost $_ | where-object {$_.PhysicalAddress -like "00:25:B5*" }} | Select VMHost, PhysicalAddress
2. How register an existing Hyper-V virtual machine on to a Hyper-V host:
$VMHost = Get-SCVMHost -ComputerName "HyperVHostName"
Register-SCVirtualMachine -VMHost $VMHost -Path "C:\ClusterStorage\MyVM"
It seems not to be possible to search for VM guests based on theyr IP address ussing the graphical user interface in VMM.
3. How to set the first boot device(here the CD-ROM) on Generation 2 VM guests:
4. How to create NIC on VM and also set static IP-adress from a static IP-Pool defined in VMM:
$VMNetwork = Get-SCVMNetwork -VMMServer vmmServerFQDN -Name "VLAN 127 Network"
$VMSubnet = Get-SCVMSubnet -VMMServer vmmServerFQDN -Name "VLAN 127 Network_Subnet"
New-SCVirtualNetworkAdapter -VM "VMNameHere" -MACAddress "00:00:00:00:00:00" -MACAddressType Static `
-Synthetic -EnableVMNetworkOptimization $false -EnableMACAddressSpoofing $false `
-EnableGuestIPNetworkVirtualizationUpdates $false -IPv4AddressType Static -IPv6AddressType Dynamic `
-VMSubnet $VMSubnet -VMNetwork $VMNetwork
#Then choose either alternative 1 or alternative 2:
#Alternative 1:
$IPPool = Get-SCStaticIPAddressPool | where-object {$_.VMSubnet.name -eq $VMSubnet.Name}
Grant-SCIPAddress -StaticIPAddressPool $IPPool -GrantToObjectType VirtualNetworkAdapter `
-GrantToObjectID ((Get-SCVirtualNetworkAdapter -VM "VMNameHere"))[0].ID
#Alternative 2:
$Adapter =(Get-SCVirtualNetworkAdapter -VM "VMNameHere" | where {$_.VLanID -eq "127"})
Set-SCVirtualNetworkAdapter -IPv4AddressType Static -VirtualNetworkAdapter $Adapter -IPv4Addresses "IPv4 Adresse Her"
#In alternative 2 VMM will automatically findthe IP pool for $VMNetwork if it exists
5. How to find addresses in a IP-Pool:
Find used/assigned addresses:
Get-SCIPAddress -Assigned -StaticIPAddressPool (Get-SCStaticIPAddressPool -Name "AddressPoolName")
Find all assigned addresses that are not in use any more:
Get-SCIPAddress -UnAssigned -StaticIPAddressPool (Get-SCStaticIPAddressPool -Name "AddressPoolName")
Unassigne all IP's from a IP-pool:
Revoke-SCIPAddress -AllocatedIPAddress (Get-SCIPAddress -Assigned -StaticIPAddressPool (Get-SCStaticIPAddressPool -Name "IP Pool Name"))
6. How to get the fillingdegree on a datastore:
The same thing can also be done in Failover Cluster Manager:
7. How to find what VM's are running on a datastore:
Get-Cluster "ClusterName" | Get-ClusterNode | Foreach {Get-VM -ComputerName $_.Name | Where {$_.Path -match "Volume1"}}
8. How to find orphaned disks:
Paste the following into a ps1 file and run it after switching "ClusterNameHere" with the correct name of the cluster.
[CmdletBinding(ConfirmImpact='High',SupportsShouldProcess=$true)]
PARAM (
[string]$ClusterName = "ClusterNameHere",
[string]$LocalClusterStoragePath = "C:\\ClusterStorage",
[string]$ClusterStorageUNCTail = "C$\ClusterStorage",
[string[]]$Extensions = @( '*.vhdx', '*.vhd', '*.iso' )
)
BEGIN {
#Get all disks registered in Hyper-V:
if ($host.Name -eq "ConsoleHost") {Write-Host -Foregroundcolor Yellow "Using the following parameters: "}
$baseHost = (get-VMHostGroup | % {$_.AllChildClusters | where-object {$_.ClusterName -eq $ClusterName} `
| get-vmhost})[0];
if ($host.Name -eq "ConsoleHost") {Write-Host -Foregroundcolor Yellow " baseHost: $baseHost"}
$baseHostname = $baseHost.Name.Split(".")[0];
if ($host.Name -eq "ConsoleHost") {Write-Host -Foregroundcolor Yellow " baseHostname: $baseHostname"}
$baseCluster = (get-VMHostGroup | % {$_.AllChildClusters | where-object {$_.ClusterName -eq $ClusterName}});
if ($host.Name -eq "ConsoleHost") {Write-Host -Foregroundcolor Yellow " baseCluster: $baseCluster"}
$uncBase = [string]$("\\"+$baseHostname+"\"+$ClusterStorageUNCTail);
if ($host.Name -eq "ConsoleHost") {Write-Host -Foregroundcolor Yellow " uncBase: $uncBase"}
$disks = $baseCluster | get-vmhost | Get-Vm | `
Foreach-Object {$_.virtualdiskdrives | % {[String]($_.VirtualHardDisk.Location) `
-replace $LocalClusterStoragePath, $uncBase}}
$List = @($Extensions | ForEach-Object {
$extension = $_;
if ($host.Name -eq "ConsoleHost") {Write-Host -Foregroundcolor Yellow "- Filtering extension: $extension"}
dir -Path $uncBase | % {
dir -Path $uncBase\$_ | %{
dir -Path $($uncBase+"\"+($_).Parent.Name+"\"+$_) -Filter $extension | `
Select-Object -ExpandProperty FullName
}
}
}) | Where-Object {
$_ -notin $disks
} | Select-Object -Unique
if ($host.Name -eq "ConsoleHost") {Write-Host -Foregroundcolor Yellow $("`n**Found " + $List.count + " files..")}
$List
}
9. Hyper-V equivalents to SDRS and DRS in VMWare:
Distributed Resource Scheduler in VMWare os "Dynamic Optimization" in System Center Virtual Machine Manager 2012 R2.
Choose the fabric pane in VMM and right click the site where yoiu want to adjust the settings, and choose properties.
10. Access rights in VMM:
Requires to create a Tenant Administrator or Application Administrator in a Private Cloud.
1. Settings -> Create User Role:
2. Attach the role to a Private Cloud and delegate what objects can be administrated.
11. Hyper-V vs VMWare vSphere:
Drawbacks with Hyper-V compared to VMWare vSphere:
It is not possible to list what virtual machines are on a storage device via the GUI.
A virtual guest has to be powered off so that a NIC can be added to it.
The IP-addresses of the hosts are not shown in VMM. Powershell has to be used.
The handeling of access rights is not as granulated and straight forward to handle as in VMWare.
VMWare vSphere has more GUI options for doing various administrative tasks easily.
Hyper-V and SCVMM do not have a full equivalent to VMware's Storage DRS.
Live migrations of storage in SCVMM seems to way too often not to be able to clean up after itself, resulting in orphaned files.
Benefits with Hyper-V in regards to VMWare:
Licenses and costs
Hyper-V has a practical networking model(see 'System Center VMM Networking' below)
12. More on Hyper-V and VMM:
|