0 votes

Hi

I need to update some property patterns on a scheduled basis and am doing this via a powershell script. The particular attibute will be a drop down, but for ease of use I would like to set a default value if the list only has one option.

I've got the following which configures the attribute correctly, but is there a way to set the default value?

$item = $userPattern.Items.Create()
$item.PropertyName = "primaryTelexNumber"
$item.IsPropertyRequired = $True

$constraints = $item.GetConstraints()
$constraint = $constraints.Create("ADM_PROPERTYCONSTRAINTTYPE_VALUERANGE")
$constraint.AreValuesDenied = $False
$constraint.Values = @($dlList)
$constraints.Add($constraint)
if ($dlList.Count -eq 1) {$constraints.DefaultValue = $dlList[0]} #This doesn't work!
$item.SetConstraints($constraints)
$item.SetInfo()
$userPattern.Items.Add($item)

Thanks

Matt

by (1.2k points)

1 Answer

0 votes
by (227k points)

Hello,

Yes, it is possible. You need to use the IAdmPropertyPatternItem::DefaultValue property. The value set as default must also be present in the list of allowed values for the property.

0

Thanks, I've seen that page already which is what made me think that having

if ($dlList.Count -eq 1) {$constraints.DefaultValue = $dlList[0]}

would work but it comes up with an error. Is that command right? Do I need to use the SetInfo() for the values first then do the DefaultValue after?

Matt

+1

Hello,

You are using the property for an object that supports an interface that does not have the DefaultValue property. To achieve the desired, the code line should be as follows:

if ($dlList.Count -eq 1) {$item.DefaultValue = $dlList[0]}

There is no need to do any other changes.

0

Perfect, thank you as always for the quick responses.

Related questions

0 votes
1 answer

We are trying to enforce better consistency for user attribute values in a domain but without overly restricting user input when modifying/creating users. Is it possible to ... to these fields and create Custom Commands to change them which is very tedious.

asked Mar 21, 2019 by Staj (350 points)
0 votes
1 answer

We have a form to used by our HR Reps to create non-employee records. There are two fields on the form that are auto-generated via a property pattern: Full Name ( ... changed to cause this new behavior? Nothing has changed with our property pattern set-up...

asked Aug 30, 2016 by sandramnc (820 points)
+1 vote
1 answer

I see many questions regarding this in the Forum, and last solution is from 2014 - based on custom PS script, has something in the product come up that solves this ... outputs users that does not comply to property pattern in order to upkeep AD sanity. Thanks

asked Jan 21, 2021 by spinnetho (50 points)
0 votes
1 answer

Is it possible to update a Propery Pattern using a powershell script? If a new department OU is created, is it possible to automaticly update the User Pattern's Department property to reflect that a new department has been added?

asked Jan 28, 2013 by kjesoo (960 points)
0 votes
1 answer

My webform is not picking info based off the property pattern template specifically the logon name and the UPN

asked Mar 8 by Keonip (160 points)
2,803 questions
2,535 answers
6,605 comments
62,599 users