Set-QADUser failing with variable??

I have this script in a workflow and this line fails when I use a variable

set-Qaduser -identity agntest\$usr -ObjectAttributes @{employeetype = $UserEmpType}

If I put text it works fine.

set-Qaduser -identity agntest\$usr -ObjectAttributes @{employeetype = 'TextWorks"}

I know the variable is correct because I did a output to a file. It just has a few number characters.

This is the error in the log when the variable causes failure: At line: 39 char:13. Exception has been thrown by the target of an invocation.

How do I use a variable correctly in that command?

Parents
  • Couple of thoughts here:

    1) I never leave spaces around the '=' 
    2) Is it possible that $UserEmpType is an empty string?  Active Directory doesn't like it when you try to set an attribute value to an empty string.

    To be clear:

    $UserEmpType = "" # Active Directory doesn't like this

    $UserEmpType = $null # This is OK


Reply
  • Couple of thoughts here:

    1) I never leave spaces around the '=' 
    2) Is it possible that $UserEmpType is an empty string?  Active Directory doesn't like it when you try to set an attribute value to an empty string.

    To be clear:

    $UserEmpType = "" # Active Directory doesn't like this

    $UserEmpType = $null # This is OK


Children