I am trying to assign the output of an if statement to a variable, I am New To Powershell and don't have a firm grasp of it, Any Help would be Great. Thanks!
$Var = if ($Title -eq "Service Route Rep"){
$Department = "Operations"}elseif ($Title -eq "AP Clerk"){
$Department = "Finance"}elseif($Title -eq "Product Development Manager")
$Department = "Operations"}
$Title = "Service Route Rep"
$Department = "$var"
$user.department = "$Department"
and i receive the error
Set-ADUser : replace
At line:1 char:1
+ Set-ADUser -instance $user
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-ADUser],
ADInvalidOperationException
+ FullyQualifiedErrorId :
ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.SetADUser