Private/Helper/Test-IsVirtual.ps1

<#
Copyright © 2024 Integris. For internal company use only. All rights reserved.
#>


FUNCTION Test-IsVirtual {
    <#
    .SYNOPSIS
    Determines if the system is a virtual machine.
 
    .DESCRIPTION
    This function checks the model of the system to determine if it is a virtual machine, including common virtual environments like AWS, Google, VMWare, and Xen.
 
    .PARAMETER None
 
    .EXAMPLE
    Test-IsVirtual
 
    .NOTES
    The function uses the Get-WmiObject cmdlet to get the system model from the Win32_ComputerSystem class.
    #>


    IF ((Get-WmiObject -Class Win32_ComputerSystem).Model -like "*Virtual*") { RETURN $True }
    IF ((Get-WmiObject -Class Win32_ComputerSystem).Model -like "*AWS*") { RETURN $True }
    IF ((Get-WmiObject -Class Win32_ComputerSystem).Model -like "*Google*") { RETURN $True }
    IF ((Get-WmiObject -Class Win32_ComputerSystem).Model -like "*VMWare*") { RETURN $True }
    IF ((Get-WmiObject -Class Win32_ComputerSystem).Model -like "*Xen*") { RETURN $True }
    RETURN $False
}