powershell - table not showing output in new line -


i'm sure there simple solution, i'm stuck. output in members column this

{domain\domain admins, domain\joerod...

how can show

$member

value on each line?

function get-admingroups{  foreach($i in (get-content c:\users\joerod\desktop\remove_users.txt)){  #test if machine on network if (-not (test-connection -computername $i -count 1 -quiet -erroraction silentlycontinue)) {         write-warning "$i unavalible"         "`r"         }  else { (invoke-command { $members = net localgroup administrators |   ? {$_ -and $_ -notmatch "command completed successfully"} |   select -skip 4 new-object psobject -property @{  computername = $env:computername  users=$members  } } -computer $i -hidecomputername |  select * -excludeproperty runspaceid )   } }  } get-admingroups |ft 
share|improve question
    
try fl instead of ft. – kevin_ may 29 '14 @ 20:18
    
the show groups want in table format – joerod may 29 '14 @ 20:27
up vote 1 down vote accepted

iterate through $members , make object each one. creates empty array, loops through computers in text file, , in loop pulls list of local administrators, , each 1 creates custom object doing, , adds array.

$results = @() foreach($i in (gc c:\users\joerod\desktop\remove_users.txt)){     #test if machine on network     if (!(test-connection -computername $i -count 1 -quiet -erroraction silentlycontinue)) {         write-warning "$i unavalible`r"         continue     }     invoke-command {         $members = net localgroup administrators |?{$_ -and $_ -notmatch "command completed successfully"} | select -skip 4         foreach($member in $members){             $results += new-object psobject -property @{                 computername = $env:computername                 users=$member             }         }     } -computer $i -hidecomputername # | select * -excludeproperty runspaceid } $results | ft 
share|improve answer
    
im getting error when running script. method invocation failed because [system.management.automation.psobject] doesn't contain method named 'op_addition'. – joerod may 30 '14 @ 12:47
1  
sorry, move $results = @() after $members = , before foreach – themadtechnician may 30 '14 @ 13:50

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments