We are currently working on automating the property patterns. So far we were able to add all the needed properties to a Property Pattern via PowerShell script apart from the Value Selection for the "Exchange Mailbox Store" property.

We tried to add the "homeMDB" property in the script but were unable to add a default value of 1 Mailbox DB and the constraints that only one selection can be made (like in the screenshot).

This is what it should look like: image.png

We tried different approaches and in the code block bellow is the latest. Also we could't find any information for this in the SDK.

$DBS = @()
$DBS += "MBDB_DB1"

$item = $pattern.Items.Create()
$item.PropertyName = "homeMDB"
$item.IsPropertyRequired = $true

$constraints = $item.GetConstraints()
$constraint = $constraints.Create("ADM_PROPERTYCONSTRAINTTYPE_VALUERANGE")
$constraint.Values = $DBS
$constraints.Add($constraint)
$item.SetConstraints($constraints)


# Save the changes
$item.SetInfo()
$pattern.Items.Add($item)

The following image shows the result of the code above, which doesn't quite match the "should be" screenshot. image.png

Any help would be much appriciated.

by (60 points)

1 Answer

by (307k points)
Best answer
+1 vote

Hello Michael,

You need to use the following code block in your script. In the code, the $dbGUIDs variable specifies GUIDs of databases that will be available for selection.

$dbGUIDs = @("0904298E-F6B8-4BAB-8A54-1B055F0EFA98") # TODO: modify me

# Create item
$item = $pattern.Items.CreateEx("adm-MailboxStoragePropertyPatterntItem")
$item.PropertyName = "homeMDB"
$item.IsPropertyRequired = $true

$item.MailboxStorageSelectionType = "ADM_MAILBOXSTORAGESELECTIONTYPE_ROUNDROBIN"
$item.AllowedMailboxStorageDatabases = $dbGUIDs

# Save the changes
$item.SetInfo()
$pattern.Items.Add($item)

Related questions

Or is there another solution to solve this?

asked Sep 15, 2022 by boris (570 points)
0 votes
1 answer

I want to make a custom field in which you can select a person from the active directory, is this possible? For example, as in the field manager

asked Nov 18, 2022 by Alvares (100 points)
0 votes
1 answer

I need to connect to Exchange Online using specific service principal, but I am getting error I am trying to authenticate via Connect-ExchangeOnline -AccessToken $token - ... btw aka 3.8.0 version of the ExchangeOnlineManagement module is used automatically.

asked Nov 18 by KIT (1.0k points)
0 votes
1 answer

I want to disable exchange mail account via script. This script will run in custom command. I write a script like this. "Disable-Mailbox -identity %mailNickname% - ... module that it is recognize this command. Any one suggest something Thanks in advanced.

asked Jul 1, 2013 by Erkan.Ozturk (40 points)
0 votes
1 answer

When I add the property MsExchActiveSyncEnabled it seems to always be blank. How to fix?

asked Apr 22, 2022 by nate2 (90 points)
0 votes
1 answer