Jakob Digranes
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) }"
}
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad I could help. Thanks for the feedback. :)
ASKER