/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


Problems retrieving txt file.

06/05/2018 517 views

Hello,

 I have a script that place the results into a folder on the c drive. I have other scripts that work, but this one does not show me anything in a custom field.

This is the command I'm using in software inventory: ShellCommandTextReturn(cmd /c type c:\KBOX\monitors.txt).

This is the 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) { 
    $Name = Decode $Monitor.UserFriendlyName -notmatch 0
    $Serial = Decode $Monitor.SerialNumberID -notmatch 0
    $Manufacturer = Decode $Monitor.ManufacturerName -notmatch 0
    $User = $Monitor.PSComputerName
 
    echo "$Name,$Serial"
}
)*>&1 > C:\kbox\monitors.txt.

above is what the kbox\monitor.txt file looks like.


2 Comments   [ + ] Show comments

Comments

  • So the monitors.txt file is being created correctly but the CIR doesn't contain that information? Does the CIR not show up in a device'es inventory or does it report some value? Does your CIR have all relevant OSes selected?
    • it may one show one line
      • odd, I have some CIRs using 'type' and are able to return txt files with multiple lines. I don't know what might be wrong :-/
  • above is the software inventory and what the text file looks like. It's not pulling in the data.

Be the first to answer this question

Don't be a Stranger!

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

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ