Convert Array into a single string and get full-path file name after doing a Get-ChildItem
hi, using get-childitem in location list of files specific file-extension, storing results array. trying convert array single-string contain file names full-path , comma (, ) seperator in between. getting file-name inside whole table.
$location = "e:\procserver\allprocess"
$filelist = get-childitem -path $location -recurse -include "*.txt", "*.log"
$result = $filelist | out-string
$result
directory: e:\ques
mode lastwritetime length name
---- ------------- ------ ----
-a--- 9/20/2012 7:34 2 proc.log
-a--- 9/20/2012 6:23 2 step.txt
-a--- 7/16/2012 7:43 2 qwet.log
the string should , stored in $result, can use $result other purposes:
$result="e:\procserver\allprocess\proc.log, e:\procserver\allprocess\step.txt, e:\procserver\allprocess\qwet.log"
Windows Server > Windows PowerShell
Comments
Post a Comment