0 votes

Hello All,

I would like to update the property "Home Directory" from it's current value, to a new value.

Right now it's referencing %username% and I would like to change it to %samAccountName% for all user property patterns.

I've found a few scripts that are performing somewhat similar tasks, but they all add constraints which I do not need. I just need this value generated when the user is created.

I appreciate any help.

ago by (20 points)
0

Hello Steve,

What exactly do you mean by update the property "Home Directory" from it's current value? Do you need to change the default template specified in the property pattens?

Also, please, provide a screenshot of the Multi-server environment dialog. The dialog displays how many Adaxes services you have and what their versions are. For information on how to view it, see https://www.adaxes.com/help/MultiServerEnvironment. You can post the screenshot here or send to us at support@adaxes.com.

0

I'm in a single server environment, I'll attach the screen showing the version though.

I have 450 User patterns, each of them have a property called "home directory" which is their mapped user drive. We previously derived the value of that folder from the username property, but can no longer utilize that since the username value has changed.

So I need to update all 450 of these user patterns to instead reference "sAMaccountName" in their Home Directory field.

I hope this makes sense.

0

adaxesSS.jpg

0

Hello,

Please, post here or send us (support@adaxes.com) a screenshot of the current setup for the Home Directory property in one of the property patterns that need to be updated.

0

image.png

I need to update all patterns to use %samAccountName% instead

1 Answer

0 votes
ago by (302k points)

Hello,

Thank you for clarifying. Please, find the script below. You can execute it is a scheduled task or custom command. The target object does not matter for the script. In the script, the $propertyName variable specifies the schema name of the property to update default value for.

$propertyName = "homeDirectory" # TODO: modify me

# Bind to the property patterns container
$propertyPatternsPath = $Context.GetWellKnownContainerPath("PropertyPatterns")

# Search parameters
$searcher = $Context.BindToObject($propertyPatternsPath)
$searcher.Criteria = New-AdmCriteria "adm-PropertyPattern"
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"

try
{
    # Execute search
    $searchResultIterator = $searcher.ExecuteSearch()
    $searchResults = $searchResultIterator.FetchAll()

    foreach ($searchResult in $searchResults)
    {
        # Bind to the property pattern
        $propertyPattern = $Context.BindToObjectBySearchResult($searchResult)

        if ($propertyPattern.ObjectType -ne "user")
        {
            continue
        }

        foreach ($item in $propertyPattern.Items)
        {
            if ($item.PropertyName -ne $propertyName)
            {
                continue
            }

            # create new default value
            $currentDefaultValue = $item.DefaultValue
            $newDefaultValue = $currentDefaultValue.Replace("username", "sAMAccountName")

            # Update property pattern item
            $item.DefaultValue = $newDefaultValue
            $item.SetInfo()
        }
    }
}
finally
{
    # Release resources
    if ($searchResultIterator){ $searchResultIterator.Dispose() }
}
0

I created a custom command and pasted the script in as a powershell script, then created a scheduled task to run it, but there are no results, nothing has been changed.

I opened the custom command, and hit the "RUN" button from there, and it worked.

image.png

Why would it not work when I ran it the other way?

Thanks

0

Hello,

Did you specify the activity scope for the scheduled task? If no objects are specified in the activity scope, the actions will not be executed.

Related questions

0 votes
1 answer

Hi team, I would like to update allowed values of a property pattern and found this script: https://www.adaxes.com/script-repository/add-new-allowed-property-value-to-a- ... multiple new values? I tried already a foreach around it, but not working properly :/

asked Sep 2, 2024 by wintec01 (1.8k points)
0 votes
1 answer

In the web interface, I would like to display the "Distinguished Name" property but it is not showing it as it would when using ADUC or even in the Adaxes Admin Console. Is ... I would like it to display like this: CN=Mark Smith,OU=Sales,DC=Fabrikam,DC=COM

asked Jan 15, 2020 by mark.it.admin (2.3k points)
0 votes
1 answer

We have users with a value of a space for their mobile number and telephone number. I would like to figure out who these users are and null the value. Or if the value contains a number leave it alone. if it does not have a number then null the value.

asked Nov 15, 2022 by B_Witmer (40 points)
0 votes
1 answer

We are wanting to display all values entered into a multi value text attribute in an email sent by Adaxes. What we've found is that only the first entry into the array ... Entry" Is there a way to reference the variable so that it displays all entries? Thanks

asked Dec 12, 2024 by msheppard (790 points)
0 votes
1 answer

Hi, would it be possible to script a workstation in AD and also directly from our local SCCM environment ?

asked Oct 28, 2024 by ddesmedt (40 points)
3,699 questions
3,383 answers
8,549 comments
549,737 users