powershell - Exporting Drive Letters to Columns -


i trying list of drive letters post csv across page not down,

ex:
systemname, drive1,drive2,drive3,drive4,drive5

svr,c:,d:,e:,f:

not

systemname, deviceid
svr, c:
svr, d:
svr, e:
svr, f:

the code put , has worked before other projects

get-wmiobject win32_logicaldisk -filter "drivetype = '3'" -computername $serverlist[$j] | select systemname, deviceid 

now there more before file computers in , checking make sure online, being meat figure there has way it, can't figure out. ideas?

thanks, luke

full code

# loop executed when ping successful     if (test-connection -computername $serverlist[$j] -count 1 -quiet)     {         $results = get-wmiobject win32_logicaldisk -filter "drivetype = '3'" -computername $serverlist[$j]         "{0},{1}" -f $serverlist[$j], $results.deviceid -join "," | add-content c:\scripts\file.csv         ($k = 0; $k -lt $tempvar.count; $k++)         {             $tempoutput = $tempvar[$k]              # setup line written file              $exporttofile = $tempoutput.systemname + "," + $tempoutput.deviceid              # write log, utf8 encoding .csv             $exporttofile | out-file $logfile -append -encoding utf8         }     } 

unless there more code simple answer appears use -join in conjunction add-content set line. have in sort of loop structure should not affected here.

$results = get-wmiobject win32_logicaldisk -filter "drivetype = '3'" -computername $serverlist[$j] "{0},{1}" -f $serverlist[$j],($results.deviceid -join ",") | add-content c:\temp\file.csv 

using format operator build line server name , append comma delimited string of drive id's


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -