PowerShell extract characters from string
<p>I have a list of user names in a .csv file. Looks like this</p>

<pre><code>PC,User
comp-1,john.doe
PC-2,steven.smith
MAC-1,betty.crocker
</code></pre>

<p>and I would like to extract the first letter of the first and last name to put into another variable. Not sure how to accomplish this. Here is my code that will get me the first letter. </p>

<pre><code> $PepCSV = import-csv C:\pep.csv 
 foreach($X in $PepCSV)
   {
   $UserName = $X.User
   $UserInt = $UserName.Substring(0,1)
   Write-Output "UserName = $UserName `n UserInt = $UserInt"
   } 
</code></pre>

<p>The output is this</p>

<pre><code>UserName = john.doe 
 UserInt = j
UserName = steven.smith 
 UserInt = s
UserName = betty.crocker 
 UserInt = b
</code></pre>

<p>How can I get the second letter for UserInt? </p>