Solved

Set EXchange Custom Attributes related to company with hash table?

Posted on 2013-05-24
4
468 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_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 40

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

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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