Trying to simplify this code for obvious reasons..... found this little snippit as a start, but I'm not really sure how to incorporate it into the larger scheme.
It's basically a phonebook CSV file that we need broken out into multiple files. The code below does work but it's very inefficient:
[char[]](65..90)
Code below:
GC C:\Users\x\documents\Telephonebook.csv | %{
if ($_.StartsWith("A")){
$_ | out-file -filepath c:\users\aricci\documents\A.asp -append
}
ElseIf ($_.StartsWith("B")){
$_ | out-file -filepath c:\users\aricci\documents\B.asp -append
}
ElseIf ($_.StartsWith("C")){
$_ | out-file -filepath c:\users\aricci\documents\C.asp -append
}
ElseIf ($_.StartsWith("D")){
$_ | out-file -filepath c:\users\aricci\documents\D.asp -append
}
ElseIf ($_.StartsWith("E")){
$_ | out-file -filepath c:\users\aricci\documents\E.asp -append
}
ElseIf ($_.StartsWith("F")){
$_ | out-file -filepath c:\users\aricci\documents\F.asp -append
}
ElseIf ($_.StartsWith("G")){
$_ | out-file -filepath c:\users\aricci\documents\G.asp -append
}
ElseIf ($_.StartsWith("H")){
$_ | out-file -filepath c:\users\aricci\documents\H.asp -append
}
ElseIf ($_.StartsWith("I")){
$_ | out-file -filepath c:\users\aricci\documents\I.asp -append
}
ElseIf ($_.StartsWith("J")){
$_ | out-file -filepath c:\users\aricci\documents\J.asp -append
}
ETC....