We help IT Professionals succeed at work.
Get Started

need to set CustomAttribute based on mailboxGUID

Jakob Digranes
on
213 Views
Last Modified: 2015-11-13
Experts ... .rather basic PowerShell skills - I need a way to get GUID value from a set of mailboxes, and put that value into CustomAttribute1 for exchange. I've got this:

The problem is that the GUID inserted into CustomAttribute1 is the GUID from the first mailbox, so all get the same error.
Something here... ??? (set-mailbox $user -CustomAttribute1 "iXOS-EXLK:/{$($GUID.Guid)}" ???)
 ####################################################################################################
 #
 # Script for retrieving members of  group, extract  GUID and set
 # CustomAttribute1 generated from iXOS-EXLK:/+GUID
 #
 #
 ######################################################################################################

 # Get users from AD-Group
 # Alternatively - Group can be entered by user
 #
 # $AdGroup = Read-Host "Enter group name"
 # $users = Get-ADGroupMember $AdGroup | select -ExpandProperty name
 #
 # Selecting Users from Group Test_MBX_Permission

 $users = Get-ADGroupMember Test_MBX_Permission | Select-Object -ExpandProperty name
 foreach ($user in $users)
{
 # Extract Mailbox GUID and pipe to variable $GUID
$GUID = Get-Mailbox $user | select GUID
}
# Set CustomAttribute1 based on iXOX-EXLK:/ + Users unique MailboxGUID
 foreach ($user in $Users)
 {
 $customAttrib1 = Get-Mailbox -Identity $user -CustomAttribute1 -ErrorAction SilentlyContinue | select CustomAttribute1
 if($customAttrib1)
 {
 #If customattribute1 have value - do nothing
 }
 else
 {
#set-mailbox with value CustomATtribute1
 set-mailbox $user -CustomAttribute1 "iXOS-EXLK:/{$($GUID.Guid)}"
 }

 }
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE