Only Numeric Characters and Symbols Updating

This topic contains 3 replies, has 2 voices, and was last updated by  Dave Wyatt 3 years, 9 months ago.

  • Author
  • #19834

    Allen Rohl


    I have a strange issue with importing AD attributes from a .CSV file. It was working a couple of days ago. Now, when importing the data, it looks like all data is going through (no errors) but only the rows from the .csv file with numerals and symbols (#) are importing. String data like names, initials and home addresses and telephone numbers and not importing.

    I'm using quest active roles free management shell for interaction with AD and the powershell ISE for testing.

    Again, this was working a couple of days ago.

  • #19835

    Dave Wyatt

    Does the file look okay when you open it in Notepad? This one's going to be hard to troubleshoot without being able to see the CSV file and the code that's reading it.

    • #19837

      Allen Rohl

      The code and .csv file is attached. I put together the code with help from other moderators in this forum.

  • #19843

    Dave Wyatt

    I'm not sure if this is the only problem with this code, but one thing that jumps out at me is that you're constantly overwriting the value of $Params.ObjectAttributes with new hashtables. When that happens, only the last value to be assigned will wind up getting passed on to Set-QADUser, which may be the problem here. Try this revision:

    Add-PSSnapin -Name Quest.ActiveRoles.ADManagement
    $OU = " and Workstations"
    $userinfo = Import-csv -path "C:\xxHR_EMPLID_EXP20141017.csv" -Delimiter "|"
    foreach ($user in $userinfo) {
        $Params = @{}
        $objectAttributes = @{}
        if ($user.manager) {
            $Params.manager = Get-QADUser -SearchRoot $OU -Sizelimit 0 -ObjectAttributes @{employeeID=$user.manager} |
            Select-Object -ExpandProperty DN
        if ($user.assistant) {
            $assistant = Get-QADUser -SearchRoot $OU -Sizelimit 0 -ObjectAttributes @{employeeID=$user.assistant} |
            Select-Object -ExpandProperty DN
            $objectAttributes.assistant = $assistant
        if ($user.extensionAttribute12) {
            $extensionAttribute12 = $user.extensionAttribute12
            $objectAttributes.extensionAttribute12 = $extensionAttribute12
        if ($user.homePostalAddress) {
            $homePostalAddress = $user.homePostalAddress
            $objectAttributes.homePostalAddress = $homePostalAddress
        if ($user.generationQualifier) {
            $generationQualifier = $user.generationQualifier
            $objectAttributes.generationQualifier = $generationQualifier
        if ($user.middleName) {
            $middleName = $user.middleName
            $objectAttributes.middleName = $middleName
        if ($ {
            $sn = $
            $ = $sn
        if ($user.telephoneNumber) {
            $telephoneNumber = $user.telephoneNumber
            $Params.telephoneNumber = $telephoneNumber
        if ($user.ipPhone) {
            $ipPhone = $user.ipPhone
            $objectAttributes.ipPhone = $ipPhone
        if ($user.facsimileTelephoneNumber) {
            $facsimileTelephoneNumber = $user.facsimileTelephoneNumber
            $Params.facsimileTelephoneNumber = $facsimileTelephoneNumber
        if ($ {
            $mobile = $
            $ = $mobile
        if ($user.homePhone) {
            $homePhone = $user.homePhone
            $Params.homePhone = $homePhone
        if ($user.department) {
            $department = $user.department
            $Params.department = $department
        if ($user.extensionAttribute13) {
            $extensionAttribute13 = $user.extensionAttribute13
            $objectAttributes.extensionAttribute13 = $extensionAttribute13
        if ($objectAttributes.Count -gt 0)
            $Params.objectAttributes = $objectAttributes
        Get-QADUser -SearchRoot $OU -Sizelimit 0 -ObjectAttributes @{employeeID=$user.EmployeeID} |
        Set-QADUser @Params

    Here, you're only assigning a value to $Params.ObjectAttributes once, with the hashtable that was built up in the $objectAttributes variable throughout the rest of the code.

You must be logged in to reply to this topic.