Public/SystemInformation/Get-EZComputerModel.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<#
.SYNOPSIS
Returns the Computer Model
 
.DESCRIPTION
Returns the Computer Model
 
.LINK
https://osd.osdeploy.com/module/functions/system-information/get-ezcomputermodel
 
.NOTES
21.1.28 Initial Release
#>

function Get-EZComputerModel {
    [CmdletBinding()]
    Param ()

    begin {
        if ($(Get-EZComputerManufacturer) -match 'Lenovo') {
            $Model = Get-CimInstance -ClassName Win32_ComputerSystemProduct -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Version
        } else {
            $Model = Get-CimInstance -ClassName CIM_ComputerSystem -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Model
        }
    }
    process {
        if ($null -eq $Model) {$Model = 'Unknown'}
        elseif ($Model -eq '') {$Model = 'Unknown'}
        elseif ($Model -match 'to be filled') {$Model = 'Generic'}
    }
    end {
        Return $Model
    }
}