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
Post a Comment