I've struggled with this all day... I'm trying to import a csv, filter out certain stores, zero pad all store ids to 5 digits, then re-export the csv with a different delimiter and remove quotes. I've got it all working except zero padding (input3 isn't working).
#Sleep -seconds 20 #wait for RW report generation
$input = Import-Csv E:\RWS\SysFiles\reports\CAST\ClientExport.csv -Header 'store','desc','status','ip','tcpip','timezone','drive','path','col9','col10'
$input2 = $input | where-object { $_.store -match "[0-9]" -and -not $_.store.StartsWith("99") }
#$input3 = $input2 | ForEach-Object { $_.store = $_.store.PadLeft(5,'0') }
$input3 | ConvertTo-Csv -NoTypeInformation -Delimiter ';' | % {$_ -replace '"', ""} | out-file E:\RWS\SysFiles\reports\CAST\CleanClientExport.csv -force
example input:
32013,"SHREVEPORT, LA",ENABLED,10.4.43.11,(TCP/IP),-6,C:,\Program Files\Remote\,, 7045,ELIZABETHTOWN-KY,ENABLED,10.82.240.11,(TCP/IP),-5,C:,\Program Files\Remote\,,
example out:
32013;SHREVEPORT, LA;ENABLED;10.4.43.11;(TCP/IP);-6;C:;\Program Files\Remote\;; 07045;ELIZABETHTOWN-KY;ENABLED;10.82.240.11;(TCP/IP);-5;C:;\Program Files\Remote\;;
I'm just getting a blank csv...and I'm struggling with viewing $input in a PS console, can't figure out how to display what i've imported on the host screen!