Click here for important information about

Convert this bat to powershell

Dell / OPTIPLEX 755
May 24, 2010 at 01:02:24
Specs: Microsoft Windows 7 Enterprise, 2.333 GHz / 3965 MB

I often use the below type of loop in batch files.

for /f %%a in (file.csv) do echo %%a

can anyone help me converting this into a powershell script?

I have googled but not had much luck, i am new to powershell and need help with this is anyone can offer it? It would be much appreciated.


See More: Convert this bat to powershell

May 25, 2010 at 12:32:06
If anyone is reading this I managed to sort this by doing the following

$file = "C:\file.csv"
$macs = Get-Content $file | foreach{$_.split(",")}

foreach ($mac in $macs)
   write-output $mac | out-file -filepath "C:\file2.txt" -append

I know this seems silly, taking one file and putting it into another but for illustration it is good, in the foreach loop you can do anything with the $mac variable

Report •
Related Solutions

Ask Question