Thursday, April 22, 2010

Powershell Script to Read and Write a File


Powershell Script to Read and Write a File


function Copy-File ($infile, $outfile)
{
    $file = gc $infile
    Clear-Content $outfile
    foreach( $line in $file)
    {
        $line | Out-File -filepath $outfile -encoding utf8 -append
    }
}
Copy-File infile.txt outfile.txt

No comments: