[Solved] Powershell script
Go to solution
Solved by C2dan88,
1 hour ago, Pup Shepard said:I was hoping that if the user wrote teacher it would write to $path. Then I could do something like, $($path) and that become the desired variable.
Try using get-variable like this
$teacher = "OU=Teachers,OU=Educators,OU=Alpha,DC=REDACTED,DC=REDACTED" $student = "OU=Students,DC=REDACTED,DC=REDACTED" $type = Read-Host -Prompt "Type student or Type teacher" $path = (get-variable $type).value Write-Output "Path is: $path"
But I think it would be much safer to use a simple if statement.
if ($type -eq "student") { $path = $student } else if ($path_type -eq "teacher") { $path = $teacher } else { Write-Output "Incorect value entered. Only student or teacher permitted" }
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now