locked
Edit CustomAttribute on exchange RRS feed

  • Question

  • Hello guys,

    I'm trying to update CustomAttribute, but it is always replacing it. So I was wondering if there is some way how to just add a new attribute without actually removing the old one.

    I'm using following command -

    set-mailbox -identity test@test.com -CustomAttribute11 ,test1

    I was also thinking to save the output of bellow command to variable in order to work with it later, but I'm not really sure how I can do it.

    get-Mailbox test@test.com | select "CustomAttribute11" 

    Saving upper command to $attribute is not really a way as I need just the value and not the whole command.

    Can you please advice how can I update the attribute directly or how can I store the value of it to the variable?

    Thanks a lot in advance.





    • Edited by LukasSt Friday, April 3, 2020 6:30 PM
    Friday, April 3, 2020 6:30 PM

Answers

  • $myvar = Get-Mailbox test@test.com | select -Expand CustomAttribute11

    Simple PowerShell 101 so take some time to read the manual


    \_(ツ)_/


    • Edited by jrv Friday, April 3, 2020 7:24 PM
    • Marked as answer by LukasSt Friday, April 3, 2020 7:54 PM
    Friday, April 3, 2020 7:23 PM
  • The answer is that you cannot update the value directly. If you want to assign the value JRV's given you the answer.

    Since you're already retrieving the mailbox, why not do something like this?

    $x = Get-Mailbox test@test.com
    $x.customattribute11 += ',test1'
    $x | Set-Mailbox


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    • Marked as answer by LukasSt Friday, April 3, 2020 7:54 PM
    Friday, April 3, 2020 7:34 PM

All replies

  • $myvar = Get-Mailbox test@test.com | select -Expand CustomAttribute11

    Simple PowerShell 101 so take some time to read the manual


    \_(ツ)_/


    • Edited by jrv Friday, April 3, 2020 7:24 PM
    • Marked as answer by LukasSt Friday, April 3, 2020 7:54 PM
    Friday, April 3, 2020 7:23 PM
  • The answer is that you cannot update the value directly. If you want to assign the value JRV's given you the answer.

    Since you're already retrieving the mailbox, why not do something like this?

    $x = Get-Mailbox test@test.com
    $x.customattribute11 += ',test1'
    $x | Set-Mailbox


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    • Marked as answer by LukasSt Friday, April 3, 2020 7:54 PM
    Friday, April 3, 2020 7:34 PM
  • thank you for your replies guys!
    • Edited by LukasSt Friday, April 3, 2020 7:54 PM
    Friday, April 3, 2020 7:54 PM