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

directory stack

After enabling Windows Server 2012 R2 DHCP Failover Getting Packet dropped because of Client ID hash mismatch

WMI Repository 4GB limit - Win 2003 Ent Question