Set-ADUser for attribute that is NULL

Welcome Forums General PowerShell Q&A Set-ADUser for attribute that is NULL

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 year, 10 months ago.

  • Author
    Posts
  • #73093

    Participant
    Topics: 108
    Replies: 233
    Points: 58
    Rank: Member

    How do I run Set-ADUser for a property (msExchRecipientDisplayType) that is currently set to NULL?

    Tried this:

    $users = Import-Csv -Path .\TestUsers.csv
    foreach ($user in $users) {                        
     Get-ADUser -Identity $($user.DN) -Properties msExchRecipientDisplayType -Server Domain.parent.com |            
      Set-ADUser -msExchRecipientDisplayType $($user.Value)
    }

    My error is:

    Set-ADUser : A parameter cannot be found that matches parameter name 'msExchRecipientDisplayType'.

    I thought I would have the parameter in the pipeline to set.

  • #73094

    Participant
    Topics: 8
    Replies: 1190
    Points: 639
    Helping Hand
    Rank: Major Contributor

    Exchange Active Directory attributes should only be set with Exchange cmdlets.

    https://blogs.technet.microsoft.com/johnbai/2013/09/11/o365-exchange-and-ad-how-msexchrecipientdisplaytype-and-msexchangerecipienttypedetails-relate-to-your-on-premises/

    Exchange Recipient Types and Office 365 – Setting Active Directory attribute values

    I'm not an Exchange SME, but my guess would be that those values are set when you do something like Enable-Mailbox for a user would associate the attribute with a User Mailbox. To reiterate (also by the first link), Exchange sets those values, they should not be directly modified

    • #74485

      Participant
      Topics: 108
      Replies: 233
      Points: 58
      Rank: Member

      this worked:

      $users = import-csv 
      Foreach ($u in $users) {set-ADUser $u.DN -replace @{msexchrecipientdisplaytype="0"}

The topic ‘Set-ADUser for attribute that is NULL’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort