## Custom Inventory Report - Imported text file is truncated

So i wrote a powershell script to export the monitors hardware information to a text file on the local computer.

The results of the text file in notepad are correct.  For example.

Model: DELL U2711    Year: 2012

S/N:D971T26D11FL     Connection:Digital

Model: DELL U2711    Year: 2010

S/N:D971T08P181L     Connection:Digital

But when i look at the custom inventory rule in Kace for this information to get imported it shows up like this.

 CIR-MonitorInventory2019: Model: DELL U2711italModel: DELL U2711 [string]
 I tried changing the encoding type on the powershell export file, but it made no difference.  Both Ascii and Unicode exportThe command i used for the CIR is this FileExists(C:\ProgramData\Quest\KACE\monitor2019.txt) AND ShellCommandTextReturn(cmd /c type  C:\ProgramData\Quest\KACE\monitor2019.txt)  I have a few other CIRs which work fine, but have no idea why this text file is different.Any tips is appreciated.Charles

• If you run cmd /c type C:\ProgramData\Quest\KACE\monitor2019.txt on a machine what does the output look like? - chucksteel 3 years ago
• It displays whats in the text file and not truncated. Its a mystery to me. - ctrakarn 3 years ago
• Turns out Powershell adds null values to the text file. The null values is what causes the import to be truncated. Once the null values were removed the text was imported as expected. Thanks everyone! You would think this would be part of the Kace inventory agent already by now. - ctrakarn 3 years ago

Posted by: kayroccs 1 year ago
0

Hey guys,

Know this post is 2 years old but the way I was able to get the information returned without it being truncated is by calling powershell instead of cmd. I used the same script ctrakarn posted

ShellCommandTextReturn(powershell.exe /c type C:\Path\to\MonitorInformation.txt)

Posted by: SMal.tmcc 3 years ago
0

I ran into all sorts of weird things like that trying to get the monitor serial numbers also.  I ended up using freeware to get that info. https://www.nirsoft.net/utils/monitor_info_view.html

I created a CIR to see if the exe was on the computer and created a MI against that CIR to copy the exe to any computers missing the file. FileExists(c:\temp\MonitorInfoView.exe)

I have a CIR to create the file ShellCommandTextReturn(cmd /c if exist "C:\temp\MonitorInfoView.exe" C:\temp\MonitorInfoView.exe /stext C:\temp\monitorinfo.txt /HideInactiveMonitors 1)

The raw file contained to much info for what we wanted so I created one more CIR to filter the info in that file to a file with the info we wanted.

Shellcommandtextreturn(cmd /c if exist c:\temp\monitorinfo.txt (echo off & for %g in (c:\temp\monitorinfo.txt) do (findstr /v /b /c:"Active" %g > C:\temp\temp1.txt) && for %g in (c:\temp\temp1.txt) do (findstr /v /b /c:"Active" %g > C:\temp\temp.txt) && for %g in (c:\temp\temp.txt) do (findstr /v /b /c:"ManufacturerID" %g > C:\temp\temp1.txt) && for %g in (c:\temp\temp1.txt) do (findstr /v /b /c:"ProductID" %g > C:\temp\temp.txt) && for %g in (c:\temp\temp.txt) do (findstr /v /b /c:"Maximum" %g > C:\temp\temp1.txt) && for %g in (c:\temp\temp1.txt) do (findstr /v /b /c:"Image Size" %g > C:\temp\temp.txt) && for %g in (c:\temp\temp.txt) do (findstr /v /b /c:"Horizontal" %g > C:\temp\temp1.txt) && for %g in (c:\temp\temp1.txt) do (findstr /v /b /c:"Vertical" %g > C:\temp\temp.txt) && for %g in (c:\temp\temp.txt) do (findstr /v /b /c:"Digital" %g > C:\temp\temp1.txt) && for %g in (c:\temp\temp1.txt) do (findstr /v /b /c:"Standby" %g > C:\temp\temp.txt) && for %g in (c:\temp\temp.txt) do (findstr /v /b /c:"Suspend" %g > C:\temp\temp1.txt) && for %g in (c:\temp\temp1.txt) do (findstr /v /b /c:"Low-Power" %g > C:\temp\temp.txt) && for %g in (c:\temp\temp.txt) do (findstr /v /b /c:"Default" %g > C:\temp\temp1.txt) && for %g in (c:\temp\temp1.txt) do (findstr /v /b /c:"Display" %g > C:\temp\temp.txt) && for %g in (c:\temp\temp.txt) do (findstr /v /b /c:"EDID" %g > C:\temp\temp1.txt) && for %g in (c:\temp\temp1.txt) do (findstr /v /b /c:"Registry" %g > C:\temp\temp.txt) && for %g in (c:\temp\temp.txt) do (findstr /v /b /c:"Computer" %g > C:\temp\temp1.txt) && for %g in (c:\temp\temp1.txt) do (findstr /v /b /c:"=" %g > C:\temp\filtermonitor.txt) && type C:\temp\filtermonitor.txt))

• Hi SMal.tmcc.

Its been a long time. I did use this utility and it works if someone is logged in to the computer locally. If you log in via remote desktop it does not show the the monitors attached. I get 0kb files when it runs when no one is logged in or logged in via remote desktop. Have you run into that problem? Or do you execute only with a logged in user? The powershell script gets that information from WMI i think and it didnt need anyone to be logged in. But the text file wont import properly even though it displays fine in cmd window.

Here is my powershell script.

$(function Decode { If ($args[0] -is [System.Array]) {
[System.Text.Encoding]::ASCII.GetString($args[0]) } # Else { #"Not Found" } #} ForEach ($Monitor in Get-WmiObject WmiMonitorID -Namespace root\wmi) {
$file = "C:\programdata\quest\kace\monitor2019.txt"$time = Get-Date
$Name = Decode$Monitor.UserFriendlyName -notmatch 0
$Serial = Decode$Monitor.SerialNumberID -notmatch 0
$Manufacturer = Decode$Monitor.ManufacturerName -notmatch 0
$User =$Monitor.PSComputerName
$year =$Monitor.YearOfManufacture
$in = ($monitor.InstanceName).Replace('\', '\\')
Write-Verbose -Message $in$dp = Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams -Filter "InstanceName = '$in'" -ComputerName$computername
$video = (Get-WmiObject -Class Win32_VideoController).VideoModeDescription;$maxres = $video[-1]$type = 'Unknown'
switch ($dp.VideoInputType){ 0 {$type = 'Analog'}
1 {$type = 'Digital'} } New-Object -TypeName PSObject -Property @{ } echo " Model:$Name Year: $year S/N:$Serial Connection:$type" #$maxres
# $time" } ) *>&1 | out-file -Encoding unknown -filepath$file - ctrakarn 3 years ago
• The Nirsoft program works, it runs as a CIR at startup or per inventory cycle settings. The exe is local on the machine, I think that makes the difference.

I have not seen the problem you have with your output file truncating and I do all sorts of weird things with CIRs via PS and WMIC.

ShellCommandTextReturn(Cmd /c If Exist C:\ProgramData\Quest\KACE\monitor2019.txt Type C:\ProgramData\Quest\KACE\monitor2019.txt)

or try one thing - use type to strip any hidden code and read that output to see if it works

ShellCommandTextReturn(Cmd /c If Exist C:\ProgramData\Quest\KACE\monitor2019.txt Type C:\ProgramData\Quest\KACE\monitor2019.txt > C:\ProgramData\Quest\KACE\monitor.txt|type C:\ProgramData\Quest\KACE\monitor.txt) - SMal.tmcc 3 years ago
• Looks like there is something in the output file that I dont know how to get rid of. Its not visible in the output file. If i copy the text and create text document with same content it imports correctly. Using this tool Beyond compare to compare the files and there is some hidden binary after the first variable output. That is probably why its truncating the import of the data? - ctrakarn 3 years ago
• some ascii tab code or something messing with the import. you can use a binary editor or word perfect reveal codes to see what is in it or just use the last option I gave you to copy the file and read the copy into the CIR. You can email me the file and I have both BE and WP to look at it for you. email in my profile - SMal.tmcc 3 years ago
Posted by: MGruber 3 years ago
0

Hi,

I'm using KACE since a few years already and I found this a few days ago.

You could install the "Dell Command | Monitor" application. https://www.dell.com/support/article/at/de/atbsdt1/sln311855/dell-command-monitor?lang=en

This installs a lot of APIs on the target computer and KACE has already a build in function to read some values.

If the computer has installed the program and sends an Inventory to your KACE appliance, you are able to see some hardware information and also the monitors attached to it.

It tells you the Model, Year of Produce, Serial number, Size and some more.

• Does this work on non-dell machines? - SMal.tmcc 3 years ago

#### Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

question