• Products
    • View all products
    • Free trials
  • Solutions
    • All Solutions
    • All Integrations
  • Resources
    • All Resources
    • Learning Hub
  • Trials
  • Support
    • Support Home
    • By Product
      • All Products
      • Active Roles
      • Authentication Services
      • Cloud Access Manager
      • Defender
      • Identity Manager
      • Password Manager
      • Safeguard
      • Starling Identity Analytics & Risk Intelligence
      • Starling Two-Factor Authentication
      • TPAM Appliance
    • Contact Support
      • Overview
      • Customer Service
      • Licensing Assistance
      • Renewal Assistance
      • Technical Support
    • Download Software
    • Knowledge Base
    • My Account
      • My Products
      • My Service Requests
      • My Licenses
      • My Groups
      • My Profile
    • Policies & Procedures
    • Professional Services
    • Technical Documentation
    • One Identity University
    • User Forums
    • Video Tutorials
  • Partners
    • Overview
    • Partner Circle Log In
    • Become a Partner
    • Find a Partner
    • Partner Community
  • Communities
    • Home
    • Blogs
      • Blogs A to Z
      • One Identity Community
      • AD Account Lifecycle Management
      • Cloud
      • Identity Governance & Administration
      • Privileged Access Management
      • syslog-ng Community
    • Forums
      • All Product Forums
      • Active Roles
      • Identity Manager
      • Password Manager
      • Safeguard
      • Unix Access Management
    • Social Networks
      • Facebook
      • LinkedIn
      • Twitter
      • YouTube
One Identity Community
One Identity Community
  • Site
  • User
  • Site
  • Search
  • User
Active Roles Community
Active Roles Community
Wiki Renaming a user post-creation
  • Forum
  • Ideas
  • Wiki
  • More
  • Cancel
  • New
  • -Active Roles Script Center
    • +Active Roles Script Policy Best Practices
    • Active Roles SDK
    • +C#
    • +JavaScript
    • -PowerShell
      • PowerShell Library Source Code
      • -PowerShell samples
        • Alert on pending approval request expiration
        • Building a Managed Unit Dynamically
        • Calculate user mailbox size
        • Checking the uniqueness of a property
        • Create Dynamic Group in PowerShell
        • Export Domain Users to a .csv file
        • Functions for creation of Policy links
        • Get Active Roles Management Shell Module version (with build number)
        • Home Folder Move with User Moves
        • How to schedule the Active Roles Management shell
        • Populating a custom Virtual Attribute with a readable accountExpires timestamp using an Active Roles Policy Script
        • PowerShell: Update Property Generation and Validation policy with a new possible value list
        • Random Password Generation
        • Renaming a user post-creation
        • Working with the mS-DS-ConsistencyGuid attribute
    • +VBScript

You are currently reviewing an older revision of this page.

  • History View current version

Renaming a user post-creation

Back to PowerShell Policies

DESCRIPTION

The purpose of this script is to rename a user immediately post-creation to include the description (or any other arbitrary attribute) as part of the name.

This cannot be enforced in the ARS MMC client prior to creation since the description attribute is not populated until after the logon name is specified/generated. Moreover, ARS does not allow renames during the on PreCreate event handler.

The Start-Job technique is being employed here to introduce a delay between the completion of the user creation wizard and the actual rename of the account. If the user is renamed immediately, the ARS client will return an error message since the object that the wizard is actively attempting to display to the user no longer exists by the name that the wizard is aware of. Despite that error message, the user will have been successfully renamed. Executing the rename as a background job eliminates this problem.

Note that if the MMC/Web interface option to "Display the object properties when this wizard closes" is selected, an error message is likely. The user properties will likely be displayed prior to the rename being completed. This is easily alleviated by closing the properties window and re-selecting the properties of the newly renamed account.

Note This code may use functions from the ARS Script Policy Best Practices. Please, follow the link to obtain instructions and code for those functions.

SCRIPT

#*********************************************************************************

# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,

# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED

# WARRANTIES OF MERCHANTBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

#

# IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,

# PLEASE CONTACT QUEST PROFESSIONAL SERVICES.

#*********************************************************************************

#

# This code is published on the ActiveRoles Script Center:

#

#

# This code may use functions from the ARS Script Policy Best Practices:

#

#

# Please, follow the link to obtain instructions and code for those functions.

#*********************************************************************************

#*********************************************************************************

# User Renaming

# Version: 1.0

# Author: Shawn Ferrier [Quest]

# Date: Oct 14, 2010

#*********************************************************************************

#*********************************************************************************

# Description

#

# The purpose of this script is to rename a user immediately post-creation to

# include the description (or any other arbitrary attribute) as part of the name.

#

# This cannot be enforced in the ARS MMC client prior to creation since the

# description attribute is not populated until after the logon name is

# specified/generated. Moreover, ARS does not allow renames during

# the on PreCreate event handler.

#

# The Start-Job technique is being employed here to introduce a delay between

# the completion of the user creation wizard and the actual rename of the

# account. If the user is renamed immediately, the ARS client will return an

# error message since the object that the wizard is actively attempting to

# display to the user no longer exists by the name that the wizard is aware of.

# Despite that error message, the user will have been successfully renamed.

# Executing the rename as a background job eliminates this problem.

#

# Note that if the MMC/Web interface option to "Display the object properties

# when this wizard closes" is selected, an error message is likely. The user

# properties will likely be displayed prior to the rename being completed.

# This is easily alleviated by closing the properties window and re-selecting the

# properties of the newly renamed account.

#

#*********************************************************************************

function onPostCreate($Request) {

if ($Request.Class -ne "user") { return }

if ($Request.Parameter("RequestSource") -ne $Constants.EDST_MOD_SOURCE_CLIENT) { return }

$UserDesc = $DirObj.Get("description")

if (($UserDesc -eq $null) -or ($UserDesc -eq "")) { return }

$UserCN = $DirObj.Get("cn")

$UserCN = $UserCN + " ($UserDesc)"

Start-Job -InitializationScript { Add-PSSnapin -Name "Quest.ActiveRoles.ADManagement" } `

-ScriptBlock { param($User, $NewName) Rename-QADObject $User -NewName $NewName -proxy } `

-ArgumentList $Request.GUID, $UserCN

}

#***** END OF CODE ***************************************************************

 

COMPATIBILITY

Script compatible with the following version(s): <Not specified>

Back to PowerShell Policies

  • Company
    • About Us
    • Buy
    • Careers
    • Contact Us
    • News
  • Resources
    • Blogs
    • Customer Stories
    • Documents
    • Events
    • Videos
  • Support
    • Professional Services
    • Renew Support
    • Technical Support
    • One Identity University
    • Support Service
  • Social Networks
    • Facebook
    • Instagram
    • LinkedIn
    • Twitter
    • YouTube
  • © 2025 One Identity LLC. ALL RIGHTS RESERVED.
  • Legal
  • Terms of Use
  • Privacy
  • Community Feedback & Support
  • Cookie Preference Center