Monitor size inventory
-nologo -executionpolicy bypass -WindowStyle hidden -noprofile -file "monitor.ps1"> "C:\kbox\monitor.txt"
Hello,
I found a power shell script that give me the serial number, model, make of the monitor on attached to the pc. I want to run this on our network and have the output save to a folder on c drive. Can someone help with the output save to c drive side. thank you.
here is the power Shell script:
function Decode {
If ($args[0] -is [System.Array]) {
[System.Text.Encoding]::ASCII.GetString($args[0])
}
Else {
"Not Found"
}
}
echo "Name, Serial"
ForEach ($Monitor in Get-WmiObject WmiMonitorID -Namespace root\wmi) {
$Name = Decode $Monitor.UserFriendlyName -notmatch 0
$Serial = Decode $Monitor.SerialNumberID -notmatch 0
$Manufacturer = Decode $Monitor.ManufacturerName -notmatch 0
$User = $Monitor.PSComputerName
echo "$User, $Manufacturer, $Name, $Serial"
}
Answers (1)
This will print the results to a text file called "psresults" in the root of C:
$(function Decode {
If ($args[0] -is [System.Array]) {
[System.Text.Encoding]::ASCII.GetString($args[0])
}
Else {
"Not Found"
}
}
echo "Name, Serial"
ForEach ($Monitor in Get-WmiObject WmiMonitorID -Namespace root\wmi) {
$Name = Decode $Monitor.UserFriendlyName -notmatch 0
$Serial = Decode $Monitor.SerialNumberID -notmatch 0
$Manufacturer = Decode $Monitor.ManufacturerName -notmatch 0
$User = $Monitor.PSComputerName
echo "$User, $Manufacturer, $Name, $Serial"
}
) *>&1 > C:\psresults.txt
Comments:
-
Does not work. get error:
At C:\Users\kdebiasse\Desktop\monitor.ps1:21 char:1
+ ) *>&1 > C:\psresults.txt
+ ~
Unexpected token ')' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : UnexpectedToken - Kdebiasse 6 years ago-
retried, works fine here.
1-Make sure you are running PS as administrator
2- Make sure you are running the Script on a Physical Device, for VMs will not work
See:
https://imgur.com/a/5OQfbhA - Channeler 6 years ago-
Running as admin is only needed because the file is being saved to c:\. Just change the location off of root and it'll save with a non elevated PS. Otherwise it works fine for me. - five. 6 years ago
-
Thank you I found what was wrong. I did not put $(function .... in the beginning. It is working. - Kdebiasse 6 years ago
KDEBIASSE; DELL P2213 ; FP04F3AVD3VS
KDEBIASSE; DELL P2210 ; 6H6FX22EBKTM
but when I do inventory on the file:
ShellCommandTextReturn(cmd /c type c:\KBOX\monitors.txt)
nothing comes up:
4) Monitor Inventory PS: KDEBIASSE; DELL P2213TM [string]
I'm able to get other txt file into inventory lists:
Printer_list: 5/30/2018 4:17:46 PM - Logged in user: kdebiasse
------------------------------------------------------
Send To OneNote 16
Microsoft XPS Document Writer
Microsoft Print to PDF
Fax
Adobe PDF
\\admcprint1\ITCopyRoom
\\admcprint2\IThpP3005 - Kdebiasse 6 years ago