Solved

Set EXchange Custom Attributes related to company with hash table?

Posted on 2013-05-24
4
466 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

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

825 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