Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Powershell to update Office365 user attributes

Posted on 2015-02-19
15
Medium Priority
?
606 Views
Last Modified: 2015-02-21
Hi,

I am looking for a way to use powershell to insert a value into "custom attribute 1" for all users using a value found in the "Office" attribute.  

Can this be done with 1 ForEach script somehow?  

Please see attached screen shots that detail exactly which fields I am referring to.   The attachment is in the comment below.

Thanks
0
Comment
Question by:AD1080
[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
  • 7
  • 6
  • 2
15 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40619261
You can do this via powershell. Use the below command...
This will add the value of 40 to the CustomAttribute1 for all mailboxes.
$Mailboxes = get-mailbox -resultsize "unlimited"
foreach ($Mailbox in $Mailboxes) {
Set-Mailbox -Identity $Mailbox -CustomAttribute1 40
}

Open in new window


Will.
0
 

Author Comment

by:AD1080
ID: 40619268
Hi Will,

Thanks very much.  Can you take this a step further, and make the value for "CustomAttribute1" whatever each user has for in the field "Office".

i.e. can we load whatever they have for "Office" into a variable, and use that in place of the hardcoded "40".

Sorry, I'm very new to powershell.  I dont have a handle on it yet.
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40619331
You can do this, however i do not have o365 setup. What is the cmdlet to get this Office attribute using powershell. If you can provide that for me i can add it to the above.

Will.
0
 
LVL 43

Expert Comment

by:Vasil Michev (MVP)
ID: 40619662
It's again "Office", if it's populated that is.
0
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40619722
@Vasil - Right but what cmdlet would populate this attribute? Does Get-Mailbox populate this info? Or is it another cmdlet?

Will.
0
 
LVL 43

Expert Comment

by:Vasil Michev (MVP)
ID: 40619787
Get-Mailbox, Get-Recipient, Get-User, Get-MsolUser, all of them :)
0
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 2000 total points
ID: 40623368
Sorry for the delay...

If that is all that is needed all you need is the following changed see below...
$Mailboxes = get-mailbox -resultsize "unlimited"
foreach ($Mailbox in $Mailboxes) {
Set-Mailbox -Identity $Mailbox -CustomAttribute1 $Mailbox.Office
}

Open in new window


Make sure you test this with a couple users first as i have not tested this part but i am sure it will work.

Will.
0
 

Author Comment

by:AD1080
ID: 40623410
Hi, Thanks a lot.  Sorry for the delay on my part  as well.   We'll test this out.  

Actually just came up with the following a moment ago after spending a few hours getting  more familiar with Powershell.  Does this look to achieve the same result.  Granted your solution is cleaner.

$Mailboxes = get-mailbox -resultsize "unlimited"
foreach ($Mailbox in $Mailboxes)

{
$Office = (Get-User $MailBox.name).office
}
{
Set-Mailbox -Identity $Mailbox -CustomAttribute1 $Office
}
0
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40623416
You should not have to add the $Office var because it is already part of the $Mailboxes var because Office is an attribute of Get-Mailbox cmdlet. So all you need to do is just (.) dot source the var using the office attribute $Mailbox.Office which is what i did in the most recent script I posted.

I guess yours could work to but it is just redundant.

Will.
0
 

Author Comment

by:AD1080
ID: 40623417
Thanks again, I'll try yours.
0
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40623420
Excellent!

Will.
0
 

Author Comment

by:AD1080
ID: 40623425
Actually would you mind showing us how to add the filter too?
0
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40623429
Just open a new question and let me know what the link is. I will provide the solution.

Will.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

650 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