Link to home
Start Free TrialLog in
Avatar of Jakob Digranes
Jakob DigranesFlag for Norway

asked on

need to set CustomAttribute based on mailboxGUID

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)}"
 }

 }
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jakob Digranes

ASKER

Absolutely spot-on !!! Thanks - the Powershell n00b -> getting smarter every day. Love it when you add explanation aswell :-)
Glad I could help.  Thanks for the feedback.  :)