Skip to content

Commit

Permalink
Merge pull request #24 from rstolpe/dev
Browse files Browse the repository at this point in the history
Added new features and translation
  • Loading branch information
rstolpe authored Jan 24, 2023
2 parents 69f4740 + 6adec72 commit 46da901
Show file tree
Hide file tree
Showing 11 changed files with 2,719 additions and 20 deletions.
294 changes: 294 additions & 0 deletions .src/private/function/Convert-MonitorManufacturer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
Function Convert-MonitorManufacturer
{
<#
.SYNOPSIS
This should only be used by Get-RSMonitorInformation
.DESCRIPTION
Will translate the 3 letter code to the full name of the manufacturer, this should only be used by Get-RSMonitorInformation.
.PARAMETER Manufacturer
Enter the 3 letter manufacturer code.
.EXAMPLE
Convert-MonitorManufacturer -Manufacturer "PHL"
# Return the translation of the 3 letter code to the full name of the manufacturer, in this example it will return Philips
.LINK
https://github.com/rstolpe/MonitorInformation/blob/main/README.md
.NOTES
Author: Robin Stolpe
Mail: robin@stolpe.io
Twitter: https://twitter.com/rstolpes
Linkedin: https://www.linkedin.com/in/rstolpe/
Website/Blog: https://stolpe.io
GitHub: https://github.com/rstolpe
PSGallery: https://www.powershellgallery.com/profiles/rstolpe
#>

[CmdletBinding()]
Param(
[Parameter(Mandatory = $true, HelpMessage = "Enter the 3 letter manufacturer code")]
[String]$Manufacturer
)

Switch ($Manufacturer)
{
ACI {
return "Asus"
}
ACR {
return "Acer"
}
ACT {
return "Targa"
}
ADI {
return "ADI Corporation"
}
AMW {
return "AMW"
}
AOC {
return "AOC"
}
API {
return "Acer"
}
APP {
return "Apple"
}
ART {
return "ArtMedia"
}
AST {
return "AST Research"
}
AUO {
return "AU Optronics"
}
BMM {
return "BMM"
}
BNQ {
return "BenQ"
}
BOE {
return "BOE Display Technology"
}
CPL {
return "Compal"
}
CPQ {
return "COMPAQ"
}
CTX {
return "Chuntex"
}
DEC {
return "Digital Equipment Corporation"
}
DEL {
return "Dell"
}
DPC {
return "Delta"
}
DWE {
return "Daewoo"
}
ECS {
return "ELITEGROUP"
}
EIZ {
return "EIZO"
}
EPI {
return "Envision"
}
FCM {
return "Funai"
}
FUS {
return "Fujitsu Siemens"
}
GSM {
return "LG (GoldStar)"
}
GWY {
return "Gateway"
}
HEI {
return "Hyundai Electronics"
}
HIQ {
return "Hyundai ImageQuest"
}
HIT {
return "Hitachi"
}
HSD {
return "Hannspree"
}
HSL {
return "Hansol"
}
HTC {
return "Hitachi / Nissei Sangyo"
}
HWP {
return "Hewlett Packard (HP)"
}
HPN {
return "Hewlett Packard (HP)"
}
IBM {
return "IBM"
}
ICL {
return "Fujitsu"
}
IFS {
return "InFocus"
}
IQT {
return "Hyundai"
}
IVM {
return "Idek Iiyama"
}
KDS {
return "KDS"
}
KFC {
return "KFC Computek"
}
LEN {
return "Lenovo"
}
LGD {
return "LG"
}
LKM {
return "ADLAS / AZALEA"
}
LNK {
return "LINK"
}
LPL {
return "LG Philips"
}
LTN {
return "Lite-On"
}
MAG {
return "MAG InnoVision"
}
MAX {
return "Maxdata"
}
MEI {
return "Panasonic"
}
MEL {
return "Mitsubishi"
}
MIR {
return "miro"
}
MTC {
return "MITAC"
}
NAN {
return "NANAO"
}
NEC {
return "NEC"
}
NOK {
return "Nokia"
}
NVD {
return "Nvidia"
}
OQI {
return "OPTIQUEST"
}
PBN {
return "Packard Bell"
}
PCK {
return "Daewoo"
}
PDC {
return "Polaroid"
}
PGS {
return "Princeton Graphic Systems"
}
PHL {
return "Philips"
}
PRT {
return "Princeton"
}
REL {
return "Relisys"
}
SAM {
return "Samsung"
}
SEC {
return "Seiko Epson"
}
SMC {
return "Samtron"
}
SMI {
return "Smile"
}
SNI {
return "Siemens"
}
SNY {
return "Sony"
}
SPT {
return "Sceptre"
}
SRC {
return "Shamrock"
}
STN {
return "Samtron"
}
STP {
return "Sceptre"
}
TAT {
return "Tatung"
}
TRL {
return "Royal"
}
TSB {
return "Toshiba"
}
UNM {
return "Unisys"
}
VSC {
return "ViewSonic"
}
WTC {
return "Wen"
}
ZCM {
return "Zenith"
}
default {
return $Manufacturer
}
}
}
30 changes: 22 additions & 8 deletions .src/public/function/Get-RSMonitorInformation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
PSGallery: https://www.powershellgallery.com/profiles/rstolpe
#>

# PNPDeviceID maps with InstanceName.trim("_0")

[CmdletBinding()]
Param(
[Parameter(Mandatory = $false, HelpMessage = "Enter computer or computernames that you want to run this against")]
Expand All @@ -51,17 +53,29 @@
try
{
Write-Output "`n=== Monitor information from $Computer ===`n"
foreach ($MonInfo in $( Get-CimInstance -ComputerName $Computer -ClassName WmiMonitorID -Namespace root\wmi ))
$CimSession = New-CimSession -ComputerName $Computer
$PnPInfo = Get-CimInstance -CimSession $CimSession -ClassName Win32_DesktopMonitor
if ($null -ne $CimSession)
{
[PSCustomObject]@{
Active = $MonInfo.Active
'Manufacturer Name' = ($MonInfo.ManufacturerName | ForEach-Object { [char]$_ }) -join ""
Model = ($MonInfo.UserFriendlyName | ForEach-Object { [char]$_ }) -join ""
'Serial Number' = ($MonInfo.SerialNumberID | ForEach-Object { [char]$_ }) -join ""
'Year Of Manufacture' = $MonInfo.YearOfManufacture
'Week Of Manufacture' = $MonInfo.WeekOfManufacture
foreach ($MonInfo in $( Get-CimInstance -CimSession $CimSession -ClassName WmiMonitorID -Namespace root\wmi ))
{
$DisplayPnPInfo = $PnPInfo | Where-Object {$MonInfo.InstanceName.trim("_0") -eq $_.PNPDeviceID}
$GetManufacturer = $DisplayPnPInfo | Select-Object -ExpandProperty MonitorManufacturer
$GetManufacturer2 = Convert-MonitorManufacturer -Manufacturer $(($MonInfo.ManufacturerName | ForEach-Object { [char]$_ }) -join "")

[PSCustomObject]@{
Active = $MonInfo.Active
Status = $DisplayPnPInfo | Select-Object -ExpandProperty Status
Availability = $DisplayPnPInfo | Select-Object -ExpandProperty Availability
'Manufacturer Name' = if ($null -ne $GetManufacturer) { $GetManufacturer } else { $GetManufacturer2 }
Model = ($MonInfo.UserFriendlyName | ForEach-Object { [char]$_ }) -join ""
'Serial Number' = ($MonInfo.SerialNumberID | ForEach-Object { [char]$_ }) -join ""
'Year Of Manufacture' = $MonInfo.YearOfManufacture
'Week Of Manufacture' = $MonInfo.WeekOfManufacture
}
}
}
Remove-CimSession -InstanceId $CimSession.InstanceId
}
catch
{
Expand Down
6 changes: 3 additions & 3 deletions MonitorInformation/MonitorInformation.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#
# Generated by: Robin Stolpe
#
# Generated on: 2023-01-22
# Generated on: 2023-01-24
#

@{
Expand All @@ -36,7 +36,7 @@
RootModule = '.\MonitorInformation.psm1'

# Version number of this module.
ModuleVersion = '0.1.1'
ModuleVersion = '0.1.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -93,7 +93,7 @@
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = "Get-RSMonitorInformation"
FunctionsToExport = "Get-RSMonitorInformation", "Convert-MonitorManufacturer"

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
Expand Down
Loading

0 comments on commit 46da901

Please sign in to comment.