Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Could use a sanity check on this code

$
0
0

Writing a script to inventory our monitors and, due to our organizational structure, I'm not allowed to run it against more than my own computer, so I have no idea if it will actually pull the information I need

It takes a list of computer names from a text input file and grabs the monitor information, then outputs it to a csv (or, it's "supposed" to, anyway)


$computers = Get-Content c:\inputfiles\CompInp2.txt
foreach ($Computer in $computers) {
    gwmi WmiMonitorID -Namespace root\wmi -ComputerName $computer |
    Select @{n="Computer";e={$computer}},
    @{n="Model";e={[System.Text.Encoding]::ASCII.GetString($_.UserFriendlyName -ne 00)}},
    @{n="Serial Number";e={[System.Text.Encoding]::ASCII.GetString($_.SerialNumberID -ne 00)}},
    @{n="PCode";e={($_.ProductCodeID | % {[char]$_}) -join ''}},
    @{n="MfgrYr";e={$_.YearOfManufacture}},
    @{n="MfgrWk";e={$_.WeekOfManufacture}} |
    Export-csv c:\outputfiles\newmoninfo.csv -NoTypeInformation
    }

I would REALLY appreciate it if someone could throw a couple computernames into an input file and run the script against it to let me know if it's grabbing the monitor info for both computers or just the first one, or just the last one.


Viewing all articles
Browse latest Browse all 6937

Trending Articles