This may sound like a stupid question, but I am trying to separate the values in a variable so that I can cross compare them with another variable to decide what to do within an if statement.
Basically, I want to take the beginning letter of a users username, whatever letter that is, will then be compared to both variable to decide what action to take. So for example if the username is "Josh" the message "Home2" should appear. I'm not sure whether what I'm trying to achieve is possible but any help is appreciated.
$UserName = $env:username
$HomeDriveLetterAK = "\\charlie\home_A-K\$Username"
$HomeDriveLetterAK = "\\charlie\home_L-Z\$Username"
$Home1 = "A, B, C, D, E, F"
$Home2 = "H, I, J, K, L, M"
If ($username.StartsWith($Home1, 1))
{
[System.Windows.Forms.MessageBox]::Show("Home1" , "Status" , 'OK', 'error')
}
ElseIf ($username.StartsWith($Home2, 1))
{
[System.Windows.Forms.MessageBox]::Show("Home2" , "Status" , 'OK', 'error')
}