none
variable not passing correctly... RRS feed

  • Question

  • Having problem with string var when used with set-aduser

    pulling from a csv file,
    first,last,title,depart
    Joe,User,Head Honcho,Corporate

    $data = import-csv "C:\reports\user.csv"
    foreach ( $I in $data)
    {

    $first = $i.first
    $last = $i.last
    $alias = $i.first + "." + $i.Last
    $title = $i.Title

    get-aduser -identity $alias | set-aduser -Title $title  //Fails with object not found "Set-ADUser : A value for the attribute was not in the acceptable range of values"

    }

    When debugging it says user cannot be found, but if I run straight from powershell it works.
    get-aduser -identity "Joe.User" | set-Aduser -Title "HeadHoncho"

    $alias actually equals joe.user

    do I need to dress up $alias ? (I tried adding extra quotes but that also failed.)

    • Moved by Bill_Stewart Wednesday, September 13, 2017 10:11 PM This is not "fix/debug/rewrite my script for me" forum
    Friday, August 11, 2017 8:18 PM

All replies

  • That is not what it says.. Read the error carefully.

    Fails with object not found "Set-ADUser : A value for the attribute was not in the acceptable range of values"

    "Title" cannot be null or empty.


    \_(ツ)_/

    Friday, August 11, 2017 8:30 PM