Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This issue you're facing is that the <strong>inventory</strong> function you wrote was designed to use $_ directly, and you are assuming that the $_ Variable will only be a string. The command works initially because you are extracting a list of names from a file, which is giving you a list of names which are of type <strong>[String]</strong>, and passing this collection/list of strings into the pipeline for <strong>inventory</strong> to use.</p> <p>But when using Get-QADComputer, you are getting objects of type <strong>[Selected.Quest.ActiveRoles.ArsPowerShellSnapIn.Data.ArsComputerObject]</strong> which is so much more then just a list of names. The objects have a name property, which i assume you truly are after, along with other information. You need to pull just the name portion out and pass that along into the pipeline</p> <p>So you have two options:</p> <ul> <li><p>Change the inventory function to account for the difference in input types from the pipeline (simple strings which contain the just names, or objects that have a name property and use just the name portion) </p></li> <li><p>Change the way in which you are calling the script</p></li> </ul> <p>Here is the command, I think you want </p> <pre><code> Get-QADComputer -LdapFilter "(operatingsystem=*server*)" | Select -ExpandProperty Name | inventory | Export-Csv c:\scripts\lastreboot\inventory2.csv </code></pre> <p>Note the <strong>Select -ExpandProperty Name</strong>, which takes the ADObject and will pass only the name along into the pipeline which your inventory function is expecting </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload