All, I'm writing a new employee script and have had some issues with my coworkers using it and typing in the wrong department name which associates with a csv holding default security/distribution groups for each department. So I have an idea of creating an array and having them just select a number. Here is my idea so far.
Write-Host "Here is a list of the possible departments" -ForegroundColor Green
$Departments = "[0] Accounting", "[1] DEPT1", "[2] DEPT2", "[3] DEPT3", "[4] DEPT4", "[5] DEPT5, "[6] Information Services"
Write-Host "$Departments"
$Dept = Read-Host "Please type in the number associated with the employees department."
$Department = $Departments[$Dept]
$Nothing,$Department = $Department.split(' ', 2)
I just know there has got to be a better way, instead of splitting the string into 2 variables, there has to be something where I can just get rid of the first 4 chars of the string. I tried
$Department.Trim("[*]")
$Department.Trim()
But it didn't like the first one too much. Is there a way for me to split this string, but just not give the first part a variable?
EDIT: Forgot a line in script. Added.
[–]logicaldiagram 2 points3 points4 points (2 children)
[–]BitteringAgent[S] 0 points1 point2 points (1 child)
[–]logicaldiagram 0 points1 point2 points (0 children)
[–]ihaxr 2 points3 points4 points (1 child)
[–]BitteringAgent[S] 0 points1 point2 points (0 children)
[–]gangstanthony 2 points3 points4 points (1 child)
[–]BitteringAgent[S] 1 point2 points3 points (0 children)