Public/Functions/OSDCloud/Get-HyperVName.ps1
function Get-HyperVName { [CmdletBinding()] param () if ($WindowsPhase -eq 'WinPE'){ Write-host "Unable to get HyperV Name in WinPE" } else{ if (((Get-CimInstance Win32_ComputerSystem).Model -eq "Virtual Machine") -and ((Get-CimInstance Win32_ComputerSystem).Manufacturer -eq "Microsoft Corporation")){ $HyperVName = Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters' -Name "VirtualMachineName" -ErrorAction SilentlyContinue } return $HyperVName } } |