-
Notifications
You must be signed in to change notification settings - Fork 2
/
asset.psm1
105 lines (98 loc) · 2.94 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
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
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-CimInstance -Class wmiMonitorID -Namespace "root\wmi" -ComputerName $ComputerName |
Select-Object @{
name = 'ComputerName'
expression = { $psitem.PSComputerName }
},
@{ name = 'Name'
expression = { [System.Text.Encoding]::ASCII.GetString($psitem.ManufacturerName) }
},
@{ name = 'Serial'
expression = { [System.Text.Encoding]::ASCII.GetString($psitem.SerialNumberID) }
},
'YearOfManufacture'
}
}
function Get-Memory {
[CmdletBinding()]
[OutputType([psobject])]
Param
(
# Target computer names
[Parameter(ValueFromPipelineByPropertyName = $true,
Position = 0)]
$ComputerName = 'localhost'
)
Begin {
# Inconsistent notation to increase readability.
$ListOfMemory = @{
20 = "DDR"
21 = "DDR 2"
24 = "DDR 3"
26 = "DDR 4"
0 = "Unknown"
}
$Speed = @{
Name = "Speed (MHz)"
Expression = {
$_.Speed
}
}
$Capacity = @{
Name = "Capacity (MB)"
Expression = {
[Math]::Round( $_.Capacity / 1mb , 0)
}
}
$SourceComputer = @{
Name = "ComputerName"
Expression = {
$_.PSComputerName
}
}
$MemoryType = @{
Name = "Memory Type"
Expression = {
$ListOfMemory.Item([int]$_.SMBIOSMemoryType)
}
}
}
Process {
Get-CimInstance -ClassName 'win32_PhysicalMemory' -ComputerName $ComputerName |
select-Object @(
$SourceComputer
'Manufacturer'
'PartNumber'
$Speed
$Capacity
'DeviceLocator'
$MemoryType
) |
where-Object { $_.DeviceLocator -notmatch "SYSTEM ROM" } |
Write-Output
}
}
Export-ModuleMember -Function "Get-MonitorInformation", "Get-Memory"