PowerShell - Hyper-V - Adding comments to a virtual machine
To support me, you can subscribe to the channel, share and like the videos, disable your ad blocker or make a donation. Thank you!
Hello,
To keep track of changes to virtual machines in Hyper-V, it can be useful to use the comments function and add any information you think might be useful.
Here’s a little PowerShell function for adding comments easily.
The comments will take the following form [date] comment (user) :
[2024-04-01_13:20:35] Comment test (Guillaume)
[2024-04-02_10:24:49] Nested virtualisation configuration (Guillaume)
function Add-VMNoteGB { [CmdletBinding()] param ( [string]$VmName, [string]$ComputerName = $env:COMPUTERNAME, [string]$Note )
begin { [string]$ActualNote = (get-vm $VmName -ComputerName $ComputerName).Notes }
process { [string]$NewNote = '[{0:yyyy-MM-dd_HH:mm:ss}] {2} ({1})' -f (get-date), $env:USERNAME, $Note [string]$FinalNote = $ActualNote, $NewNote -join "`n" Set-VM -VMName $VmName -Notes $FinalNote -ComputerName $ComputerName }
}Add-VMNoteGB -VmName VM1 -Note 'Test de commentaire'# Or for a virtual machine on a remote hyper-v serverAdd-VMNoteGB -VmName VM1 -Note 'Comment test' -ComputerName srv-hyperv-1
# Display comments(Get-Vm -VmName VM1) Notes
Related links
Powershell - Hyper-V - Give a custom name to a virtual network adapter
Hyper-V defaults to naming virtual machine NICs as network adapters. This can make it difficult to identify their usage, but this problem can be solved with Powershell which allows you to change the name of virtual network adapters.PowerShell - Hyper-V - Adding comments to a virtual machine
To keep track of changes to virtual machines under Hyper-V, it may be useful to use the comments function and add any information you think might be usefulPowershell - Hyper-V - Managing virtual machine configuration versions
How to update the configuration version of a virtual machine so that it can use the new features available on your new Hyper-VPowershell - Create a virtual machine for Windows 11 with Hyper-V
Here's how to create a virtual machine in Hyper-V ready to host a Windows 11 using Hyper-VHyper-V - How to compress a virtual disk with a dynamic size
In this video, I show you how to compress a VHDX with a dynamic size in Hyper-V using graphics or the command line, and also explain why this sometimes doesn't workPowershell - Testing network connectivity and port accessibility
Testing network connectivity and port accessibility with Powershell
Follow me on
Support me
Last content
Powershell - Testing network connectivity and port accessibility
Powershell - Display network connections (equivalent to netstat)
Powershell - Testing name resolution (equivalent to nslookup)
Powershell - View and manage DNS configuration of network interfaces
Powershell - Managing IP configuration of network interfaces
Powershell - Managing the status and configuration of network interfaces
Powershell and the Left Hand Side
Powershell - Managing disks, partitions and volumes