Introduction
In a virtualization environment like Hyper-V, Integration Services play a crucial role. Integration Services are a collection of drivers and services that enhance the performance and functionality of virtual machines (VMs) running on Hyper-V. They provide essential tools that enable VMs to work seamlessly within the virtualization environment.
Visit My Previous Blog About – How to configure Hyper-V Using PowerShell
Hyper-V Setting
Integration Service
Integration Services in Hyper-V settings refer to a set of drivers and services that improve the functionality and performance of virtual machines (VMs) running on Hyper-V. In simple terms, Integration Services are tools that help virtual machines work better within the virtualization environment.
Get-VMIntergrationService -ComputerName hyperv1 -VMName vm1
This command retrieves information about the integration services installed on a virtual machine named “vm1” running on the computer “hyperv1”.
Enable-VMIntergrationService
This command enables a specific integration service on a virtual machine.
Enter-PSSession vm1
This command establishes a PowerShell session with a virtual machine named “vm1”.
Get-ItemProperty
This command retrieves the properties of an item, such as files, folders, or registry keys, within the current PowerShell session.
Static Memory
Static memory refers to a fixed amount of memory assigned to a virtual machine in Hyper-V. When you allocate static memory to a virtual machine, that specific amount of memory is reserved exclusively for that virtual machine.
get-counter -listset memoryget-counter -listset memory | select -expand counter
get-counter “\memory\available mbytes”while ($true){get-counter “\memory\available mbytes”; start-sleep -s .5}
get-vmmemory -computername hyperv1 -vmname vm1set-vmmemory -computername hyperv1 -vmname vm1 -startupbytes 4096
Dynamic Memory
Dynamic memory, on the other hand, allows the Hyper-V host to allocate memory to virtual machines based on their actual needs. With dynamic memory, the host dynamically adjusts the amount of memory allocated to each virtual machine, based on its workload and demand.
Smart Paging
Smart paging is a feature in Hyper-V that helps virtual machines start up successfully when there is a memory shortage or contention on the host server. It acts as a backup mechanism to ensure that virtual machines can be started even when there is not enough available memory.
Setting Memory Dynamic Memory
NUMA Support
NUMA support refers to the ability of a system, such as a server or a virtualization platform like Hyper-V, to effectively utilize and manage memory across multiple NUMA nodes.
Setting Processor NUMA
Resource Metering
Resource metering is a feature in Hyper-V that allows you to monitor and track the resource usage of virtual machines (VMs) running on a Hyper-V host. In simple terms, it helps you gather information about how much CPU, memory, network, and storage resources are being consumed by each VM.
Enable-VMResourceMetering -ComputerName hyperv1 -vmname vm1Measure-vm -computername hyperv1 -vmname vm1
Measure-vm -computername hyperv1 -vmname vm1 | fl
This command retrieves various metrics and information about the virtual machine named “vm1” running on the computer “hyperv1”.
Measure-vm -computername hyperv1 -vmname vm1 | select -expand harddiskmetrics
This command retrieves the hard disk metrics of the virtual machine named “vm1” running on the computer “hyperv1”.
Measure-vm -computername hyperv1 -vmname vm1 | select -expand networkmetered
This command retrieves the network metered property of the virtual machine named “vm1” running on the computer “hyperv1”.
set-vmProcessor -computername hyperv1 -vmname vm1 -EnableHostResourceProtection $true
This command is used to configure the processor settings of a virtual machine named “vm1” running on the computer “hyperv1”. The “-EnableHostResourceProtection $true” parameter is used to enable host resource protection for the virtual machine.
Enhanced session mode
Enhanced Session Mode is a feature in Hyper-V that allows for a more interactive and seamless experience when accessing virtual machines (VMs) through the Hyper-V Manager or Remote Desktop Connection.
Setting Server Enhanced session mode policy
User Enhanced session mode
Export And Import
Export and Import are operations in Hyper-V that allow you to capture and restore virtual machines (VMs) along with their configurations, making it easier to move or backup VMs between Hyper-V hosts.
GUI
Export-VMImport-VMHelp Export-Vm
Secure Boot
Secure Boot is a feature available in modern computer systems, including those running Hyper-V, that helps protect the integrity and security of the boot process and the operating system.
Enter-pssession vm1confirm-securebootuefi
Create Linux
GUI
FreeBSD
commonly used for diff appliance made by different vendors.
FressBSD on Hyper-V is primarily targeted towards our appliance vendor partners.
Hyper-V Storage
- Snapshots (Checkpoints):
- In Hyper-V, snapshots are like taking a picture of a virtual machine at a specific moment.
- They capture the current settings and data of the virtual machine, allowing you to go back to that state if needed.
- Snapshots are often used for creating backups or testing different configurations.
- In Hyper-V, they are called checkpoints.
- VSS (Volume Shadow Copy Service):
- VSS is a technology that helps create safe copies of data on a computer.
- It ensures that backups or other operations can be performed without interrupting the normal functioning of the system or data.
- In Hyper-V, VSS helps create reliable backups of virtual machine disks by coordinating the copying process.
VHD VHDX
VHD is a file format used to represent virtual hard disks in virtualization platforms like Hyper-V.
VHDX is an enhanced version of the VHD format, introduced in Windows Server 2012 and later versions.
( extension is important for vhd or vhdx or vhd set)
New-VHD -path c:\mydesktopvhd.vhdx -SizeBytes 40GB -Dynamic
This command creates a new virtual hard disk (VHD) file named “mydesktopvhd.vhdx” with a size of 40GB.
New-VHD -path c:\mydesktopvhd.vhdx -SizeBytes 40GB | `
This series of commands creates a new VHD named “mydesktopvhd.vhdx” with a size of 40GB.
mount-VHD -passthru | `
This command mounts a virtual hard disk (VHD) file. The “-passthru” parameter allows the output of this command to be used as input for the next command.
Initialize-disk -assigndriveletter -usemaximumsize | `
This command initializes the disk after mounting the VHD file.
Format-Volume -filesystem NTFS -confirm:$false -force
This command formats the volume on the initialized disk.
New-VHD -ComputerName hyperv1 -path c:\vm1.vhdx -SizeBytes 40GB -Dynamic
This command creates a new virtual hard disk (VHD) file named “vm1.vhdx” with a size of 40GB on a remote computer named “hyperv1”.
Add-VMHardDiskDrive -ComputerName hyperv1 — VMNAME vm1 -path c:\vm1.vhdx
This command adds a virtual hard disk (VHD) named “vm1.vhdx” to a virtual machine named “vm1” running on the remote computer “hyperv1”.
Differencing Disk
Add-VMHardDiskDrive -ComputerName hyperv1 — VMNAME vm1 -path c:\vm1.vhdx
This command adds a new virtual hard disk drive (VHD) to a virtual machine named “vm1” running on the computer “hyperv1”. The “-Path” parameter specifies the path where the new VHD file will be located, in this case, “c:\vm1.vhdx”. The command creates and attaches the VHD to the virtual machine, allowing it to use the specified disk for storage.
New-VHD -Differencing -ParentPath c:\template\vm1.vhdx
This command creates a new differencing virtual hard disk (VHD) using an existing parent VHD file. The “-Differencing” parameter specifies that a differencing VHD should be created. The “-ParentPath” parameter specifies the path to the parent VHD file, in this case, “c:\template\vm1.vhdx”. A differencing VHD is a type of VHD that stores only the changes made to the parent VHD, allowing for efficient disk usage and easy creation of multiple virtual machines based on a common parent disk image.
GUI
Pass Through
New-VHD -path c:\passthru.vhdx -dynamic -SizeBytes 40GB | `
This command creates a new dynamically expanding virtual hard disk (VHD) file named “passthru.vhdx” with a size of 40GB. The “-dynamic” parameter specifies that the VHD should be dynamically expanding, meaning it will only consume space on the physical disk as data is written to it.
Mount-VHD -passthru | `
This command mounts the newly created VHD file (“passthru.vhdx”) and passes it through to the next command in the pipeline. Mounting a VHD allows you to access its contents and perform operations on it.
Initialize-disk -passthru | `
This command initializes the mounted VHD disk and passes it through to the next command in the pipeline. Disk initialization prepares the disk for use by creating a disk signature and partition table.
Set-Disk -isoffline $true
This command sets the mounted disk to be offline. Making the disk offline means it will not be accessible by the operating system, preventing any accidental modification or interference with the disk.
disk part
list disk
Modify VHD
Hyperv console
EDIT DISK
INSPECT DISK
Enter-PSSession hyperv1
This command establishes a remote PowerShell session with a computer named “hyperv1.” It allows you to interact with the remote computer and execute PowerShell commands directly on that computer.
Get-Command | where name -like “*vhd*”
This command retrieves a list of all available PowerShell commands and then filters them using the “where” cmdlet. The “where” cmdlet filters the commands based on a specified condition, in this case, the command names containing “vhd” as a substring.
Test-VHD c:\vm1vhdx
The Test-VHD cmdlet tests a virtual hard disk for any problems that would make it unusable.
Output “True = USABLE”
OPTIMIZE — VHD
- MODE FULL
- This mode thoroughly optimizes the VHD by making it as small as possible, removing unused space, and organizing the data to improve efficiency. It may take more time to complete but provides the most space savings.
- MODE QUICK
- This mode quickly optimizes the VHD by reclaiming unused space, but it may not make the VHD file as small as the full mode. It’s faster but doesn’t provide as much space savings.
- MODE RETRIM
- This mode communicates with the storage system to optimize the VHD by releasing unused space. It improves performance and efficiency by letting the storage system know which parts of the VHD are no longer in use.
- MODE PRETRIMMED
- This mode assumes the storage system has already optimized the VHD by releasing unused space. It skips the optimization process since the storage system has already taken care of it.
- MODE PREZEROED
- This mode makes sure that any unused space in the VHD is filled with zeros. It helps with compression and deduplication processes by making the VHD more optimized for those operations.
Resize VHD
Resize-VHD -Path c:\vm1.vhdx -SizeBytes 120GB
This command resizes the virtual hard disk (VHD) file located at “c:\vm1.vhdx” to a specified size of 120GB.
Resize-VHD -Path c:\vm1.vhdx -ToMinimumSize
This command resizes the VHD file located at “c:\vm1.vhdx” to the minimum possible size.
Manage Checkpoints
GUI using CHECKPOINT OPTION
Limitation – When you attach pass thru to the virtual machine you can’t have checkpoints to that VM.
Checkpoint-VM -ComputerName hyperv1 -VMName vm2 -SnapshotName TESTHERE
This command creates a special saved state of a virtual machine called “vm2” on the computer “hyperv1”. This saved state is called a checkpoint or snapshot, and it’s like taking a picture of the virtual machine at that moment.
The command also assigns a specific name to this checkpoint, which is “TESTHERE”. This name helps you remember what the checkpoint represents, such as a specific test or configuration you want to preserve.
Production Checkpoints
GUI STEPS
- Setting
1.1 Checkpoints
1.2 Fiber Channel Adapter
1.3 Production Checkpoint Enable
Implement a Virtual Fiber Channel Adapter
GUI STEPS
- Virtual San Manager
Create - Setting of VM
2.1 Add Hardware
2.2 Fiber Channel Adapter
2.3 Edit Address
Create Shared VHDX Files
GUI STEPS
- NEW
- Hard disk
- VHD SET
- Dynamic
- shared.vhds
- FINISH
SETTING
1. SCSI CONTROLLER
2. SHARED DRIVE
3. VIRTUAL HDD shared.vhds
Configure Storage QoS
SETTING
SCSI CONTROLLER
HARD DISK
ENABLE QOS
IOPS
Hyper-V Networking
RSS — RECEIVED SIDE SCALLING
RDMA
Configure Hyper-V Virtual Switches
GUI
VIRTUAL SWITCH MANAGER
EXTERNAL (Allow to share)
INTERNAL (Only to talk with inside VMs)
PRIVATE (Virtual machines cannot talk to host {ISOLATED} But they can talk to each other VMs)
Configure NAT for Hyper-V VMs
New-VMSwitch -ComputerName hyperv1 -SwitchName NAT -SwitchType Internal
Get-NetAdapter
This command retrieves information about the network adapters on the computer where it is executed.
Enter-PSSession hyperv1
This command establishes a remote PowerShell session with a computer named “hyperv1”.
Get-NetAdapter
New-NetIPAddress -InterfaceIndex 16 -IPAddress 192.168.4.1 -PrefixLength 24
New-NetNat -Name NAT -internalipinterfaceaddressprefix “192.168.4.0/24”
Add-NetNatStaticMapping -NetName NAT -Protocol TCP -ExternalIpAddress 0.0.0.0 -InternalIPAddress 192.168.4.20 -InternalPort 80 -ExternalPort 80
Outside world can speak to inside world (Static mapping whatever the external IP someone coming in and integration add port no to connect)
Limitation – Only allows you to create one NAT network per machine.
GUI
SETTING
NETWORK ADAPTER
NAT
Add and Remove vNICs
Add-VMNetworkAdapter
help Add-VMNetworkAdapter
GUI
SETTING
Add Hardware
Add
Select Switch
Configure Network Isolation
GUI
Virtual Switch Manager
External Network
Enable V-Lan
“You have to have trunk port plugged in to this network interface. And Check the box to identify the vlan and communicate”
SETTINGS
Network Adapter
Virtual Switch
Enable V-Lan
Set-VMNetworkAdapterIsolation
help Set-VMNetworkAdapterIsolation
Set-VMNetworkAdapterVlan
help Set-VMNetworkAdapterVlan
Configure Bandwidth Management
SETTING
NETWORK ADAPTER
ENABLE BANDWIDTH MAN
set-vmnetworkadapter -Maximumbandwidth
set-vmnetworkadapter -MinimumBandwidthAbsolute
Configure Synthetic and Legacy vNICs
- CREATE GEN 1 VM
- GO TO SETTING
- ADD HARDWARE
- REGULAR NETWORRK ADAPTER
- LEGACY NETWORK ADAPTER (WDS, to deploy OS over the network for gen 1 VM)
- LEGACY NETWORK ADAPTER COMES UP WITH THE BOOT
Configure Mac Address
MAC IS UNIQUE
MAC SPOOFING
SETTINGS
NETWORK ADAPTER
ADVANCED FEATURES
LOAD BALANCING, NLB CLUSTERS SUPPORT THIS WE NEED MAC ADD SPOOFING
set-vmnetworkadapter -StaticMacAddress macaddress
Configure vNIC Advanced Features
ADVANCED FEATURES in NETWORK ADAPTER SETTING
DHCP GUARD
(If there’s a DHCP server, obvious it must be connected to a adds)
For the DHCP server which not authorized by adds, enabling DHCP guard will be dropped.
From protecting from unauthorized IP address.
ROUTER GUARD
May protect from malicious virtual machines pretending has a router
PORT MIRROR
Mirror the content of on that port from some other vm where sniffer is located so we can look at the traffic going in and out of that vm
Source (vm1)
Destination (vm2 which is running sniffer)
And can look the network traffics
DEVICE NAMING
Name for the network adapter
set-vmnetworkadapter -Macaddressspoofing
set-vmnetworkadapter -DhcpGuard
set-vmnetworkadapter -RouterGuard
set-vmnetworkadapter -PortMirroring
set-vmnetworkadapter -DeviceName
Configure VMQ
SETTING
NETWORK ADAPTER
HARDWARE ACCELERATION
VIRTUAL MACHINE QUEUE
Get-NetAdapterRss
Get-NetAdapterVmq
Set-NetAdapterVmq
Prepare Physical NICs for LBFO Teaming
GUI
VMWARE SETTING
ADD NETWORK CARD
MAKE IT VMNET3(NAT)
AND ADD IT TO HYPER V ADAPTERS
Stop-Computer -computername hypverv1
hyperv1.vmx open with notepad
Configure LBFO Teaming and Virtual Switch
Server Manager
Hyperv1
Right click – Configure NICteam
Task — New — Select Adapters — Additional Properties — OK
REFRESH
Hyper-V manager
New Victual Switch
External Network
Multiplexor Driver (TEAM INTERFACE)
(DISABLE)NOT TO ALLOW MANAGEMENT OS TRAFFIC
OK
802.3ad LACP
Configure SET and Enable RDMA
(Remote Direct Memory Access)
This is for Switch Embedding Teaming Portion
New-VMSwitch -EnableEmbeddedTeaming $true -NetAdapterName “NIC1”,”NIC2″
This is for RDMA portion
Enable-NetAdapterRdma
help Enable-NetAdapterRdma
Conclusion
In this blog, we explored various aspects of Hyper-V settings and configurations using PowerShell commands. We discussed Integration Services, which are tools that enhance the functionality and performance of virtual machines running on Hyper-V. We also covered topics like static memory and dynamic memory, which allow us to allocate memory to virtual machines based on their needs. Additionally, we learned about features like Smart Paging, NUMA support, and Resource Metering, which help optimize resource utilization in the virtualization environment.
We delved into topics like Enhanced Session Mode, Export and Import operations, and Secure Boot, which are important for managing and securing virtual machines. We also touched upon Hyper-V storage concepts, such as snapshots (checkpoints), VSS (Volume Shadow Copy Service), and VHD (Virtual Hard Disk) formats.