Export-CSV only gets the "Length", So odd~


hi,

i found 1 script me fining lcoal admin group member, when  try export csv list, number "length"

script:

function get-localadmin {
param ($strcomputer)
 
$admins = gwmi win32_groupuser –computer $strcomputer 
$admins = $admins |? {$_.groupcomponent –like '*"administrators"'}
 
$admins |% {
$_.partcomponent –match “.+domain\=(.+)\,name\=(.+)$” > $nul
$matches[1].trim('"') + “\” + $matches[2].trim('"')
}
}

 get-content “d:\server.txt” | % {get-localadmin $_} | export-csv -notypeinformation d:\serveradmin_list.csv

=================================================================================

only length:

length
24
28
30
27
32
24
24
30

thanks.

get-content “d:\server.txt” | % {get-localadmin $_} | out-file d:\serveradmin_list.csv


Сазонов Илья http://isazonov.wordpress.com/



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

some help on Event 540

WMI Repository 4GB limit - Win 2003 Ent Question

Event ID 1302 (error 1307) DFS replication service encountered an error while writing to the debug log file