Solved

Set EXchange Custom Attributes related to company with hash table?

Posted on 2013-05-24
4
461 Views
Last Modified: 2013-05-27
hi,

My problem is to create a hash-table to set the correct custom attributes.

Set-Mailbox -CustomAttribute3 'Q' -CustomAttribute12 'ER' -CustomAttribute11 'EMC' -SingleItemRecoveryEnabled $true -Identity $User.userid

Open in new window


The C_attribute 3 related to the company attribute.  1 company should set to value "D"
1 company to value "F" all other to "Q"

The C_attribute 12 should set for about 6 different companies to "ZE" for 3 companies
to KU and to all other to "ER".

$compattrib3 = @{

 "contoso" = ''D"
 "contoso2" = "F"
 "All other" = 'Q'
 
$compattrib12 = @{
"contoso" = ''ZE"
 "contoso2" = "KU"
 "All other" = "ER"

Thank you so much for your help.


Mandy!
0
Comment
Question by:Mandy_
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39195917
$compattrib3 = @{
"contoso" =  "D"
"contoso2" = "F"
"All other" = "Q"
}

$compattrib12 = @{
"contoso" = "ZE"
"contoso2" = "KU"
"All other" = "ER"
}

Set-Mailbox -CustomAttribute3 $compattrib3."All other" -CustomAttribute12 $compattrib12."All other" -CustomAttribute11 'EMC' -SingleItemRecoveryEnabled $true -Identity $User.userid

Open in new window

0
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 39198009
So, you've already got the hash table, you just need If statements (or possibly a Switch) to check for all the possibilities and execute the Set-Mailbox command with the different values accordingly.  An example is shown below.

If ($user.company -eq "EMC")
{
    Set-Mailbox -CustomAttribute3 $compattrib3."contoso" -CustomAttribute12 $compattrib12."contoso" -CustomAttribute11 'EMC' -SingleItemRecoveryEnabled $true -Identity $User.userid
}
ElseIf ($user.company -eq "LDE" -or $user.company -eq "DMB" -or $user.company -eq "REX")
{
    Set-Mailbox -CustomAttribute3 $compattrib3."contoso2" -CustomAttribute12 $compattrib12."contoso2" -SingleItemRecoveryEnabled $true -Identity $User.userid
}
Else
{
    Set-Mailbox -CustomAttribute3 $compattrib3."All other" -CustomAttribute12 $compattrib12."All other" -SingleItemRecoveryEnabled $true -Identity $User.userid
}

Open in new window

0
 
LVL 2

Author Comment

by:Mandy_
ID: 39198820
Thank you so much. mandy
0
 
LVL 2

Author Closing Comment

by:Mandy_
ID: 39198821
thank you
0

Join & Write a Comment

Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now