GuíasGuides · Nivel 3Level 3

Hyper-V: crear una máquina virtual, el conmutador virtual, puntos de control y exportaciónHyper-V: creating a virtual machine, the virtual switch, checkpoints and export

El rol en Windows Server, el conmutador externo que no te deja sin red, una VM de generación 2 con PowerShell, puntos de control antes de un cambio y la exportación como copia fría.The role on Windows Server, the external switch that doesn't cut your network, a generation 2 VM with PowerShell, checkpoints before a change and export as a cold backup.

Qué vas a conseguir

Un servidor Windows con Hyper-V donde crear máquinas virtuales de pruebas y de producción pequeña con PowerShell en lugar de a golpe de asistente, con puntos de control antes de cada cambio y una exportación semanal a otro disco.

Antes de empezar

  • Windows Server 2022/2025 con la virtualización activada en la BIOS/UEFI y dos interfaces de red si puede ser: una para gestión, otra para las VMs.
  • Un volumen aparte para las VMs (D:\VMs), no el disco del sistema.
  • Las ISO de los sistemas que vas a instalar en D:\ISO.

1. Instalar el rol

PowerShell · srv-hv-01 (administrador)
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -RestartSuccess Restart Needed Exit Code      Feature Result------- -------------- ---------      --------------True    Yes            SuccessRest... {Hyper-V, Hyper-V Module for Windows PowerShell, ...}# tras el reinicioGet-VMHost | Select-Object Name, VirtualMachinePath, VirtualHardDiskPathName       VirtualMachinePath                      VirtualHardDiskPath----       ------------------                      -------------------SRV-HV-01  C:\ProgramData\Microsoft\Windows\Hyper-V  C:\Users\Public\Documents\Hyper-V\Virtual Hard DisksSet-VMHost -VirtualMachinePath D:\VMs -VirtualHardDiskPath D:\VMs\Disks

Cambia las rutas por defecto antes de crear la primera VM: luego cuesta mover.

2. El conmutador virtual

PowerShell · srv-hv-01
Get-NetAdapter | Select-Object Name, Status, LinkSpeedName   Status LinkSpeed----   ------ ---------MGMT   Up     1 GbpsVMNET  Up     10 GbpsNew-VMSwitch -Name "vSwitch-LAN" -NetAdapterName "VMNET" -AllowManagementOS $falseName        SwitchType NetAdapterInterfaceDescription----        ---------- ------------------------------vSwitch-LAN External   Intel(R) Ethernet Controller X710New-VMSwitch -Name "vSwitch-Lab" -SwitchType Internal

Si solo tienes una tarjeta de red, el conmutador externo tiene que llevar -AllowManagementOS $true; si no, el servidor se queda sin red en el momento de crearlo y pierdes la sesión remota. Hazlo desde la consola física o con iDRAC/iLO.

El conmutador Interno (vSwitch-Lab) es para pruebas que no deben tocar la red de la empresa: las VMs se ven entre sí y con el host, nada más.

3. Crear la VM con PowerShell

PowerShell · srv-hv-01
$vm = New-VM -Name "srv-test-01" -Generation 2 -MemoryStartupBytes 4GB -NewVHDPath "D:\VMs\Disks\srv-test-01.vhdx" -NewVHDSizeBytes 80GB -SwitchName "vSwitch-LAN"Set-VM -VM $vm -ProcessorCount 2 -DynamicMemory -MemoryMinimumBytes 2GB -MemoryMaximumBytes 8GB -AutomaticStartAction StartIfRunning -AutomaticStopAction ShutDown -CheckpointType ProductionAdd-VMDvdDrive -VM $vm -Path "D:\ISO\WindowsServer2025.iso"Set-VMFirmware -VM $vm -FirstBootDevice (Get-VMDvdDrive -VM $vm) -EnableSecureBoot OnSet-VMKeyProtector -VM $vm -NewLocalKeyProtector; Enable-VMTPM -VM $vmStart-VM -VM $vm; vmconnect.exe localhost srv-test-01Get-VM | Format-Table Name, State, CPUUsage, MemoryAssigned, Uptime, StatusName         State   CPUUsage MemoryAssigned Uptime   Status----         -----   -------- -------------- ------   ------srv-test-01  Running 12       4294967296     00:02:11 Operating normally

Generación 2 con Secure Boot y TPM virtual es lo que pide Windows 11 y Server 2025; para Linux cambia la plantilla: Set-VMFirmware -SecureBootTemplate MicrosoftUEFICertificateAuthority. CheckpointType Production hace que los puntos de control usen VSS dentro del invitado: consistentes con las aplicaciones, no solo con el disco.

4. Puntos de control antes de un cambio

PowerShell · srv-hv-01
Checkpoint-VM -Name "srv-test-01" -SnapshotName "antes-parche-2026-10-22"Get-VMSnapshot -VMName "srv-test-01" | Format-Table Name, CreationTime, ParentSnapshotNameName                     CreationTime        ParentSnapshotName----                     ------------        ------------------antes-parche-2026-10-22  22/10/2026 9:40:12# si el cambio sale mal:Restore-VMSnapshot -Name "antes-parche-2026-10-22" -VMName "srv-test-01" -Confirm:$false# si sale bien, en cuanto esté comprobado:Remove-VMSnapshot -VMName "srv-test-01" -Name "antes-parche-2026-10-22"

Un punto de control no es una copia de seguridad: es un disco diferencial que crece y ralentiza la VM mientras exista. La regla es crear antes del cambio, borrar en cuanto se valide, nunca más de unos días. Get-VM | Get-VMSnapshot | Where-Object CreationTime -lt (Get-Date).AddDays(-7) lista los olvidados.

5. Exportar: la copia fría

PowerShell · srv-hv-01
Export-VM -Name "srv-test-01" -Path "E:\Export\$(Get-Date -Format yyyy-MM-dd)"Get-ChildItem "E:\Export\2026-10-22\srv-test-01" -Recurse -File | Measure-Object Length -Sum | Select-Object Count, @{n="GB";e={[math]::Round($_.Sum/1GB,1)}}Count GB----- --    5 21,4# importar en otro host (copia con nuevo ID para no chocar con la original):Import-VM -Path "E:\Export\2026-10-22\srv-test-01\Virtual Machines\<GUID>.vmcx" -Copy -GenerateNewId -VhdDestinationPath "D:\VMs\Disks"

Export-VM funciona con la VM encendida y deja configuración, discos y puntos de control en una carpeta que se puede importar en cualquier otro Hyper-V. Programado en una tarea semanal hacia otro disco o un NAS, es la copia mínima de un host sin Veeam; con Veeam (Nivel 2), el agente hace esto mismo con deduplicación y retención.

6. Lo que revisas cada mes

  • Get-VM | Get-VMSnapshot: puntos de control con más de una semana.
  • Get-VM | Where State -eq Running | Get-VMIntegrationService | Where Enabled -and -not PrimaryStatusDescription -eq 'OK': servicios de integración que no responden (normalmente, invitado sin actualizar).
  • Espacio en D:\VMs frente a la suma de los VHDX dinámicos: pueden crecer hasta su tamaño máximo sin avisar.
  • Visor de eventos Microsoft-Windows-Hyper-V-VMMS/Admin: errores de puntos de control o de exportación.

Siguientes pasos

  • Hyper-V Replica hacia un segundo host: una copia de la VM a cinco minutos, con conmutación planificada; es el DR pequeño antes de un clúster.
  • Un clúster de conmutación por error con almacenamiento compartido o S2D cuando las VMs sean de producción.
  • La guía de vSphere hace lo mismo del otro lado; las ideas (snapshots cortos, exportación, host en mantenimiento) son las mismas con otros nombres.

¿Falta algo o en tu entorno es distinto? Escríbeme y lo corrijo.

What you'll get

A Windows server with Hyper-V where you create test and small-production virtual machines with PowerShell instead of clicking through wizards, with checkpoints before every change and a weekly export to another disk.

Before you start

  • Windows Server 2022/2025 with virtualisation enabled in the BIOS/UEFI and, if possible, two network interfaces: one for management, one for the VMs.
  • A separate volume for the VMs (D:\VMs), not the system disk.
  • The ISOs of the systems you will install in D:\ISO.

1. Install the role

PowerShell · srv-hv-01 (administrator)
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -RestartSuccess Restart Needed Exit Code      Feature Result------- -------------- ---------      --------------True    Yes            SuccessRest... {Hyper-V, Hyper-V Module for Windows PowerShell, ...}# after the rebootGet-VMHost | Select-Object Name, VirtualMachinePath, VirtualHardDiskPathName       VirtualMachinePath                      VirtualHardDiskPath----       ------------------                      -------------------SRV-HV-01  C:\ProgramData\Microsoft\Windows\Hyper-V  C:\Users\Public\Documents\Hyper-V\Virtual Hard DisksSet-VMHost -VirtualMachinePath D:\VMs -VirtualHardDiskPath D:\VMs\Disks

Change the default paths before creating the first VM: moving later is painful.

2. The virtual switch

PowerShell · srv-hv-01
Get-NetAdapter | Select-Object Name, Status, LinkSpeedName   Status LinkSpeed----   ------ ---------MGMT   Up     1 GbpsVMNET  Up     10 GbpsNew-VMSwitch -Name "vSwitch-LAN" -NetAdapterName "VMNET" -AllowManagementOS $falseName        SwitchType NetAdapterInterfaceDescription----        ---------- ------------------------------vSwitch-LAN External   Intel(R) Ethernet Controller X710New-VMSwitch -Name "vSwitch-Lab" -SwitchType Internal

If you only have one network card, the external switch must carry -AllowManagementOS $true; otherwise the server loses its network the moment the switch is created and you lose the remote session. Do it from the physical console or through iDRAC/iLO.

The Internal switch (vSwitch-Lab) is for tests that must not touch the company network: the VMs see each other and the host, nothing else.

3. Create the VM with PowerShell

PowerShell · srv-hv-01
$vm = New-VM -Name "srv-test-01" -Generation 2 -MemoryStartupBytes 4GB -NewVHDPath "D:\VMs\Disks\srv-test-01.vhdx" -NewVHDSizeBytes 80GB -SwitchName "vSwitch-LAN"Set-VM -VM $vm -ProcessorCount 2 -DynamicMemory -MemoryMinimumBytes 2GB -MemoryMaximumBytes 8GB -AutomaticStartAction StartIfRunning -AutomaticStopAction ShutDown -CheckpointType ProductionAdd-VMDvdDrive -VM $vm -Path "D:\ISO\WindowsServer2025.iso"Set-VMFirmware -VM $vm -FirstBootDevice (Get-VMDvdDrive -VM $vm) -EnableSecureBoot OnSet-VMKeyProtector -VM $vm -NewLocalKeyProtector; Enable-VMTPM -VM $vmStart-VM -VM $vm; vmconnect.exe localhost srv-test-01Get-VM | Format-Table Name, State, CPUUsage, MemoryAssigned, Uptime, StatusName         State   CPUUsage MemoryAssigned Uptime   Status----         -----   -------- -------------- ------   ------srv-test-01  Running 12       4294967296     00:02:11 Operating normally

Generation 2 with Secure Boot and a virtual TPM is what Windows 11 and Server 2025 require; for Linux change the template: Set-VMFirmware -SecureBootTemplate MicrosoftUEFICertificateAuthority. CheckpointType Production makes checkpoints use VSS inside the guest: consistent with the applications, not just the disk.

4. Checkpoints before a change

PowerShell · srv-hv-01
Checkpoint-VM -Name "srv-test-01" -SnapshotName "before-patch-2026-10-22"Get-VMSnapshot -VMName "srv-test-01" | Format-Table Name, CreationTime, ParentSnapshotNameName                     CreationTime        ParentSnapshotName----                     ------------        ------------------before-patch-2026-10-22  22/10/2026 9:40:12# if the change goes wrong:Restore-VMSnapshot -Name "before-patch-2026-10-22" -VMName "srv-test-01" -Confirm:$false# if it goes well, as soon as it is verified:Remove-VMSnapshot -VMName "srv-test-01" -Name "before-patch-2026-10-22"

A checkpoint is not a backup: it is a differencing disk that grows and slows the VM down while it exists. The rule is create before the change, delete as soon as it is validated, never more than a few days. Get-VM | Get-VMSnapshot | Where-Object CreationTime -lt (Get-Date).AddDays(-7) lists the forgotten ones.

5. Export: the cold copy

PowerShell · srv-hv-01
Export-VM -Name "srv-test-01" -Path "E:\Export\$(Get-Date -Format yyyy-MM-dd)"Get-ChildItem "E:\Export\2026-10-22\srv-test-01" -Recurse -File | Measure-Object Length -Sum | Select-Object Count, @{n="GB";e={[math]::Round($_.Sum/1GB,1)}}Count GB----- --    5 21.4# import on another host (copy with a new ID so it doesn't clash with the original):Import-VM -Path "E:\Export\2026-10-22\srv-test-01\Virtual Machines\<GUID>.vmcx" -Copy -GenerateNewId -VhdDestinationPath "D:\VMs\Disks"

Export-VM works with the VM running and leaves configuration, disks and checkpoints in a folder that can be imported on any other Hyper-V. Scheduled as a weekly task to another disk or a NAS, it is the minimum backup of a host without Veeam; with Veeam (Level 2), the agent does the same with deduplication and retention.

6. What you review each month

  • Get-VM | Get-VMSnapshot: checkpoints older than a week.
  • Get-VM | Where State -eq Running | Get-VMIntegrationService | Where Enabled -and -not PrimaryStatusDescription -eq 'OK': integration services not responding (usually an un-updated guest).
  • Space on D:\VMs against the sum of the dynamic VHDXs: they can grow to their maximum size without warning.
  • Event Viewer Microsoft-Windows-Hyper-V-VMMS/Admin: checkpoint or export errors.

Next steps

  • Hyper-V Replica to a second host: a copy of the VM five minutes behind, with planned failover; it is the small DR before a cluster.
  • A failover cluster with shared storage or S2D when the VMs are production.
  • The vSphere guide does the same from the other side; the ideas (short snapshots, export, host in maintenance) are the same with other names.

Is something missing, or different in your environment? Get in touch and I'll fix it.

Tech Career Lab · newsletter

¿Te ha servido? Cada dos semanas envío una idea práctica para perfiles IT: LinkedIn, proyectos, networking y procesos de selección.Found this useful? Every two weeks I send one practical idea for IT professionals: LinkedIn, projects, networking and hiring processes.

Apúntate y llévate las 33 ideasSign up and get the 33 ideas →