Outputting foreach loop in Powershell -


i'm trying list of computers , ou's csv file of computer names

add-pssnapin quest.activeroles.admanagement  $results = @() $computers = get-content "computers.csv"  foreach ($computer in $computers) {     $results += get-qadcomputer $computer | select name, parentcontainer }  $results = export-csv -path "computerswithous.csv" 

but errors out asking me supply values. how can output data csv file?

you did not include in post getting:

cmdlet export-csv @ command pipeline position 1 supply values following parameters: inputobject:  

simple answer line

$results = export-csv -path "computerswithous.csv" 

should this

$results | export-csv -path "computerswithous.csv" 

in example export-csv has no input data prompt (not error) requesting. want pipe $results csv file.

you away construct , use standard pipeline looking for.

add-pssnapin quest.activeroles.admanagement  get-content "computers.csv" | foreach-object{get-qadcomputer $_} |      select name,parentcontainer | export-csv -path "computerswithous.csv" -notypeinformation 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -