AD User Creation Tool

Welcome Forums General PowerShell Q&A AD User Creation Tool

This topic contains 3 replies, has 4 voices, and was last updated by

 
Participant
9 months, 1 week ago.

  • Author
    Posts
  • #93103

    Participant
    Points: 0
    Rank: Member

    Hello,

    I am a complete "fish out of water" here, but have been given the task to assist our AD/Desktop team with the creation of a tool, with a GUI for them to use for creating new users in AD. Giving credit where it is due, below is the .ps1 I came across and am using.

    Source: https://gallery.technet.microsoft.com/scriptcenter/New-User-Creation-tool-14fa73cd

    I am having issues with the samAccount, as our organization uses "First6LastNameFirstInitialMiddleInitial" (i.e. JohnsoSB for Scott B. Johnson). I am doing my best to read up on substrings and how I might be able to modify the provided script to get this working, but I am stuck. More than willing to do the leg work, but would greatly appreciate the assistance from someone more versed with PowerShell.

    If you need more information, please let me know.

    Thank you in advance,
    Justin

  • #93106

    Keymaster
    Points: 1,619
    Helping HandTeam Member
    Rank: Community Hero

    Are you just having problems coming up with the code to create that user name from its components?

  • #93108

    Participant
    Points: 134
    Helping Hand
    Rank: Participant

    Justin,
    welcome to the powershell.org forum. Unfortunately it is beyond the scope of this forum to support scripts found at the internet. Luckily there is a Q & A section on the gallery site for each script where you can ask the author for help. If you have a specific question to some code you wrote you're welcome to post this code here and we will try to help as good as we can.

  • #93115

    Participant
    Points: 205
    Helping Hand
    Rank: Participant

    You know you just could have given them access to the Windows Server ADAC UI using AD RBAC limited them o only be able to create accounts. The ADAC even creates the PoSH code for you, that you can tweak for repurpose, etc. Just saying. Though that does nto really address your SamAccountName policy effort.

    But you can take this Q&D (quick and dirty approach) with substrings and operators, or strive for something more elegant.

        Clear-Host
    
        # Grab user full display name
        'User display name is:'
        ($UserDisplayName = 'Scott B. Johnson')
    
        "`n"
        # Use substring to construct anew SamAccountName
        'Use new SamAccoutnName is:'
    
    
        If ($UserDisplayName.Split('').Count -eq 3)
        {
            (
                $SameAccountName = ($UserDisplayName.Split(''))[2].Substring(0,6) +
                                   ($UserDisplayName.Split('')[0].Substring(0,1)) +
                                   ($UserDisplayName.Split('')[1].Substring(0,1))
            )
        }
        Else
        {
            (
            $SameAccountName = ($UserDisplayName.Split(''))[1].Substring(0,6) +
                               ($UserDisplayName.Split(''))[0].Substring(0,1)
            )
        }
    
        User display name is:
        Scott B. Johnson
    
    
        Use new SamAccoutnName is:
        JohnsoSB
    
    
        # Grab user full display name
        'User display name is:'
        ($UserDisplayName = 'Scott Johnson')
    
        "`n"
        # Use substring to construct anew SamAccountName
        'Use new SamAccoutnName is:'
    
    
        If ($UserDisplayName.Split('').Count -eq 3)
        {
            (
                $SameAccountName = ($UserDisplayName.Split(''))[2].Substring(0,6) +
                                   ($UserDisplayName.Split('')[0].Substring(0,1)) +
                                   ($UserDisplayName.Split('')[1].Substring(0,1))
            )
        }
        Else
        {
            (
            $SameAccountName = ($UserDisplayName.Split(''))[1].Substring(0,6) +
                               ($UserDisplayName.Split(''))[0].Substring(0,1)
            )
        }
    
    
        User display name is:
        Scott Johnson
    
    
        Use new SamAccoutnName is:
        JohnsoS
    

The topic ‘AD User Creation Tool’ is closed to new replies.