I want to select the second/third/forth object of a Get-ChildItem statement in my PowerShell script. This gives me the first:
$first = Get-Child
First Item
gci > out.txt
Get-Content out.txt | Select -Index 7 | Format-list
Second Item
gci > out.txt
Get-Content out.txt | Select -Index 8 | Format-list
The item between n and p
$n=3
$p=7
$count = 0
$index = $n+7
$p=7+7
while($true){
$index = $index + $count
Get-Content out.txt | Select -Index $index | Format-list
if($index -eq $p)
{
break;
}
$count = $count + 1
}
Note : The first seven lines are empty and the description lines.