Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Get-Content $Path from 2nd line

$
0
0

Hi,

I have inserted a pipe-delimiter at certain positions in text file, but i want to skip the first line from inserting the pipe-delimiters, and on creation of new text file copy the first line from there.

Please some one help me.

$path ="c:\sample.txt"
Get-Content $Path

$NewPath="C:\New sample.txt"

$Positions=@(9,18,26,39,45,55,57)
$dat = Get-Content $path
ForEach ($Line in $Dat)
{
    For($I=$Positions.Count-1;$I -GE 0;$I--)
    {
        $Line=$Line.Insert($Positions[$I],"|")
    }
    Add-Content $NewPath $Line
}

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles