Scripts/Get-PCBIOS.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
Function Get-PCBIOS {

    <#
 
    .SYNOPSIS
    Get BIOS information/configuration
 
    .DESCRIPTION
    Get BIOS information/configuration
 
    .PARAMETER ComputerName
    The target computer name
 
    .EXAMPLE
    Get-PCBIOS -ComputerName LabPC2024
 
    .NOTES
    N/A
 
    .LINK
    N/A
 
    #>


    [CmdletBinding ()]

    Param (

        [Parameter (Mandatory = $True,
                    ValueFromPipeline = $True,
                    ValueFromPipelineByPropertyName = $True,
                    HelpMessage = 'Enter computer name'
                   )
        ]

        [String[]]$ComputerName,

        [Switch]$IncludeBIOSCharacteristics

    )

    BEGIN {

        $BIOSCharacteristics = @{

            '0' = 'Reserved'
            '1' = 'Reserved'
            '2' = 'Unknown'
            '3' = 'BIOS characteristics not Supported'
            '4' = 'ISA is supported'
            '5' = 'MCA is supported'
            '6' = 'EISA is supported'
            '7' = 'PCI is supported'
            '8' = 'PC Card (PCMCIA) is supported'
            '9' = 'Plug and Play is supported'
            '10' = 'APM is supported'
            '11' = 'BIOS is upgradable (Flash)'
            '12' = 'BIOS shadowing is allowed'
            '13' = 'VL-VESA is supported'
            '14' = 'ESCD support is available'
            '15' = 'Boot from CD is supported'
            '16' = 'Selectable boot is supported'
            '17' = 'BIOS ROM is socketed'
            '18' = 'Boot from PC card (PCMCIA) is supported'
            '19' = 'EDD (Enhanced Disk Drive) specification is supported'
            '20' = 'Int 13h - Japanese floppy for NEC 9800 1.2mb (3.5, 1k Bytes/sector, 360 RPM) is supported'
            '21' = 'Int 13h - Japanese floppy for Toshiba 1.2mb (3.5, 360 RPM) is supported'
            '22' = 'Int 13h - 5.25/360 KB floppy services are supported'
            '23' = 'Int 13h - 5.25/1.2MB floppy services are supported'
            '24' = 'Int 13h - 3.5/720 KB floppy services are supported'
            '25' = 'Int 13h - 3.5/2.88 MB floppy services are supported'
            '26' = 'Int 5h, Print Screen service is supported'
            '27' = 'Int 9h, 8042 Keyboard services are supported'
            '28' = 'Int 14h, Serial services are supported'
            '29' = 'Int 17h, Printer services are supported'
            '30' = 'Int 10h, CGA/Mono video services are supported'
            '31' = 'NEC PC-98'
            '32' = 'ACPI is supported'
            '33' = 'USB legacy is supported'
            '34' = 'AGP is supported'
            '35' = 'I2O boot is supported'
            '36' = 'LS-120 boot is supported'
            '37' = 'ATAPI ZIP drive boot is supported'
            '38' = '1394 boot is supported'
            '39' = 'Smart battery is supported'

        }

        Function Show-Error ($Computer, $Status) {

            [PSCustomObject]@{

                ComputerName = $Computer
                Caption = ''
                Description = ''
                Manufacturer = ''
                PrimaryBIOS = ''
                ReleaseDate = ''
                SerialNumber = ''
                Version = ''
                Status = $Status

            }

        }

    }

    PROCESS {

        ForEach ($Computer In $ComputerName) {

            If (Test-Connection -ComputerName $Computer -Count 1 -Quiet) {

                Try {

                    $OutputObj = New-Object -TypeName PSObject

                    $Data = Get-WmiObject Win32_BIOS -ComputerName $Computer | Select-Object *

                    [Object]$DateTime = [System.Management.ManagementDateTimeConverter]::ToDateTime($Data.ReleaseDate).ToUniversalTime()

                    $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
                    $OutputObj | Add-Member -MemberType NoteProperty -Name Caption -Value $Data.Caption
                    $OutputObj | Add-Member -MemberType NoteProperty -Name Description -Value $Data.Description
                    $OutputObj | Add-Member -MemberType NoteProperty -Name Manufacturer -Value $Data.Manufacturer
                    $OutputObj | Add-Member -MemberType NoteProperty -Name PrimaryBIOS -Value $Data.PrimaryBIOS
                    $OutputObj | Add-Member -MemberType NoteProperty -Name ReleaseDate -Value $DateTime
                    $OutputObj | Add-Member -MemberType NoteProperty -Name SerialNumber -Value $Data.SerialNumber
                    $OutputObj | Add-Member -MemberType NoteProperty -Name Version -Value $Data.Version

                    If ($IncludeBIOSCharacteristics) {

                        ForEach ($Item In $Data.BIOSCharacteristics) {

                            $OutputObj | Add-Member -MemberType NoteProperty -Name "$('Characteristic_')$($Item)" -Value $BIOSCharacteristics["$Item"] -Force

                            If ($Item -ge 40 -and $Item -le 47) {

                                $OutputObj | Add-Member -MemberType NoteProperty -Name "$('Characteristic_')$($Item)" -Value 'Reserved for BIOS vendor' -Force

                            }

                            If ($Item -ge 48 -and $Item -le 63) {

                                $OutputObj | Add-Member -MemberType NoteProperty -Name "$('Characteristic_')$($Item)" -Value 'Reserved for system vendor' -Force

                            }

                        }

                    }

                    $OutputObj | Add-Member -MemberType NoteProperty -Name Status -Value 'Ok'

                    Write-Output $OutputObj

                }

                Catch {

                    Show-Error $Computer.ToUpper() $PSItem.Exception.Message

                }

            }

            Else {

                Show-Error $Computer.ToUpper() 'Unreachable'

            }

        }

    }

    END {}

}