One of the features I most love about Power shell is it’s ability to let you work with a CSV file just as if it was a database table. Assuming your columns have names at the top of the file, you can select specific items, filter using where and even join them. Here’s a quick example:

$UserToRestore = Import-CSV c:\ps\Azure\AllAzureADUsers.csv | select UserPrincipalName, ObjectId | where UserPrincipalName -eq $EmailAddress
$NewUserPrincipalName = $UserToRestore.UserPrincipalName.Replace('Domain.TLD','SubDomain.onmicrosoft.com')
Restore-MsolUser -ObjectId $UserToRestore.ObjectId -AutoReconcileProxyConflicts -NewUserPrincipalName $NewUserPrincipalName

This is just so useful.