forked from BirkdaleHigh/ps-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasset.psm1
51 lines (47 loc) · 1.53 KB
/
asset.psm1
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
function Get-MonitorInformation {
<#
.SYNOPSIS
Gets attached monitor product information for inventory.
.DESCRIPTION
Find the monitor manufacture date, name and serial number for a target computer.
.EXAMPLE
"itspc04" | Get-MonitorInformation
ComputerName Name Serial YearOfManufacture
------------ ---- ------ -----------------
ITSPC04 AOC D3EXXXXXXXXX 2014
ITSPC04 AOC D3EXXXXXXXXX 2014
.NOTES
Todo: Detect trailing zeros in serial number for correct length.
#>
[cmdletBinding()]
param(
# Target computer
[parameter(ValueFromPipeline,
ValueFromPipelineByPropertyName)]
[string[]]
$ComputerName = 'localhost'
)
Process{
Get-WmiObject -Class wmiMonitorID -Namespace "root\wmi" -ComputerName $ComputerName |
Select-Object @{
name = 'ComputerName'
expression = { $psitem.__SERVER }
},
@{ name = 'Name'
expression = {convertUint16ToString $psitem.ManufacturerName}
},
@{ name = 'Serial'
expression = {convertUint16ToString $psitem.SerialNumberID}
},
YearOfManufacture
}
}
function convertUint16ToString($int){
$str = $int | Where-Object {
$_ -notmatch 0
} | ForEach-Object {
[char]$_
}
Write-Output ($str -join "")
}
Export-ModuleMember -Function "Get-MonitorInformation"