Active Directory User Creation tool 1.2

One task that every systems administrator has to go through at some point is the creation of new user accounts. Powershell makes this process simple and adds additional functionality, such as the ability to set defaults and import users from CSV.

ANUC.ps1
 
 
 
 
 
(121)
66,751 times
Add to favorites
Active Directory
12/4/2012
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Add samaccount\upn
    2 Posts | Last post Fri 1:52 PM
    • I need to add the option to have firstnamelastname for a samaccount and upn.  I am not sure how to achieve this. can someone please advise how?
    •   <sAMAccountName Generate="True">
         <Style Format="FirstNameLastName" Enabled="True" />
        </sAMAccountName>
        <UPN Generate="True">
         <Style Format="FirstNameLastName" Enabled="True" />
        </UPN>
      
      Function Set-sAMAccountName {
          Param([Switch]$Csv=$false)
          if(!$Csv)
              {
              $GivenName = $txtFirstName.text
              $SurName = $txtLastName.text
              }
          else{}
          Switch($XML.Options.Settings.sAMAccountName.Style | Where{$_.Enabled -eq $True} | Select -ExpandProperty Format)
              {
              "FirstNameLastName"    {"{0}{1}" -f $GivenName,$Surname}
              }
          }
      Function Set-UPN {
          Param([Switch]$Csv=$false)
          if(!$Csv)
              {
              $GivenName = $txtFirstName.text
              $SurName = $txtLastName.text
              $Domain = $cboDomain.Text
              }
          else{}
          Switch($XML.Options.Settings.UPN.Style | Where{$_.Enabled -eq $True} | Select -ExpandProperty Format)
              {
              "FirstNameLastName"    {"{0}{1}@{2}" -f $GivenName,$Surname,$Domain}
              }
          }
  • How to change the sAMAccountName format?
    4 Posts | Last post September 15, 2014
    • I want to use format "SixLettersSurNameOneLetterGivenName". I tried things like ($SurName)[0..5], or .substring(0,5) with no success. Thank you in advance.
    • pc2013, I haven't fully tested this and not even sure if its the right way, but I tried using SubString and it kept throwing errors.  I got it to at least display in the form correctly using the following:
      
      "FirstInitialFirstFiveLastName"	{"{0}{1}{2}{3}{4}{5}" -f ($GivenName)[0],$Surname[0],$Surname[1],$Surname[2],$Surname[3],$Surname[4]}
      
    • Same question. I'm interested in finding out how to limit this to 5 characters from the last name.
    • Hi, could you send me some pattern of CSV file with some supplemented data ? 
  • sAMAccountName
    3 Posts | Last post September 03, 2014
    • How do we allow a custom sAMAccountName?
      
      I ask because we format ours differently. We typically use the first initial, middle initial, and first five characters of the last name with a 1 at the end. eg. Captain A. Morgan = camorga1.
      
      Any ideas on how to style this or allow a custom entry from either the field or a CSV.
    • If not how to place this in where it pulls FirstInitial, MiddleInitial, First5ofLastName, 1 with a result as shown above.
    • Current this is what we have (works for everything but the number at the end).
      
      Function Set-UPN {
          Param([Switch]$Csv=$false)
          if(!$Csv)
              {
              $GivenName = $txtFirstName.text
              $Initials = $txtInitials.text
              $SurName = $txtLastName.text
              $Domain = $cboDomain.Text
              }
          else{}
          Switch($XML.Options.Settings.UPN.Style | Where{$_.Enabled -eq $True} | Select -ExpandProperty Format)
              {
              "FirstName.LastName"    {"{0}.{1}@{2}" -f $GivenName,$Surname,$Domain}
              "FirstInitialInitialsLastName"  {"{0}{1}{2}@{3}" -f ($GivenName)[0],($Initials)[0],$SurName,$Domain}
              "LastNameFirstInitial"  {"{0}{1}@{2}" -f $SurName,($GivenName)[0],$Domain}
              Default                 {"{0}.{1}@{2}" -f $GivenName,$Surname,$Domain}
              }
          }
      
      Function Set-DisplayName {
          Param([Switch]$Csv=$false)
          if(!$Csv)
              {
              $GivenName = $txtFirstName.text
              $Initials = $txtInitials.text
              $SurName = $txtLastName.text
              }
          else{}
          Switch($XML.Options.Settings.DisplayName.Style | Where{$_.Enabled -eq $True} | Select -ExpandProperty Format)
              {
              "FirstName Initials LastName"    {"{0} {1} {2}" -f $GivenName,$Initials,$Surname}
              "LastName, FirstName"   {"{0}, {1}" -f $SurName, $GivenName}
              Default                 {"{0} {1}" -f $GivenName,$Surname}
              }
          }
  • PrimalForms File
    4 Posts | Last post August 22, 2014
    • Hello Rich,
      
      is there a possibility to provide the PrimalForms GUI File?
      I want to have some additional features on my own.
      
      It would be nice to do this with help of the tool instead of editing the GUI components in source code.
      
      Thank you very much!
    • My intension is:
      
      I want to select a Department, for example "IT".
      
      there should be an additional box which content is dynamically loaded by the choose of the Department. 
      
      I already added further information to the XML file:
      
       <Groups>
      	<Group Name="IT">
      		<Entry>value1</Entry>
      		<Entry>value2</Entry>
      		<Entry>value3</Entry>
      	</Group>
       </Groups>
      
      The </Entry> contents should be loaded into a new Box in the GUI. (Maybe a checkedListBox?)
      
      Afterwards i should be able to select or deselect the values inside that box. All selected values have to be proceeded within a new funktion / loop for example.
      
      I am very new to powershell and it would be nice to receive a little advice.
      
      (Especially how to load the content from the XML file into a new box dependent on the selection of the "departments field")
      
      
    • Did an solution on my own (Connected User to predefined AD Group Templates inside the XML file):
      
      1) Created a checkedListBox
      
      	#
      	# clbGroups
      	#
      	$clbGroups.Anchor = 'Top, Left, Right'
      	$clbGroups.FormattingEnabled = $True
      	$clbGroups.Location = '118, 620'
      	$clbGroups.Name = "Groups"
      	$clbGroups.Size = '173, 100'
      	$clbGroups.TabIndex = 88
      
      2) Made a "SelectIndex_Changed" for the "Department" Box:
      
      $cboDepartment_SelectedIndexChanged={ 
      		$clbGroups.Items.Clear()
      		$XML.Options.Groups.ADGroup | ?{$_.Name -match $cboDepartment.Text} | Select -ExpandProperty Entry | %{$clbGroups.Items.Add($_)}	
      }
      
      3) Now if I select "IT" as department, the following attributes are collected by the XML file and presented as checkbox Items in the Checkbox itself:
      
       <Groups>
      	<Group Name="IT">
      		<Entry>value1</Entry>
      		<Entry>value2</Entry>
      		<Entry>value3</Entry>
      	</Group>
       </Groups>
      
      4) The AD Groups are automatically connected to the new user:
      
      $ldapUserpath= "LDAP://" + $Path
      		
      foreach($ADValue in $clbGroups.CheckedItems)
          {
          $Connection = "LDAP://CN="+$ADValue+",OU=Unit2,OU=Unit1,DC=company,DC=de"
          $Group = [adsi] $Connection
          $UserAD = 'LDAP://CN="'+$Name+'",'+ $Path
          $Group.Add($UserAD)
          }
      
      Hope these snippets are helpfull for someone with the same problem!
    • Could you elaborate a little more on this? I'm getting errors saying that it can't find all the properties in the whole clbGroups piece. 
  • Path format
    2 Posts | Last post July 23, 2014
    • HI I'm trying to import from CSV. What is the path format to use?  the delimitation for the CSV file are comma so if I put my path(OU=employeNR,DC=groupetci,DC=com)in the CVS file then the system takes the comma in the path in consideration. hope im clear  
    • I think you have to put Quotes around any entries like the OU path, so "OU=employeNR,DC=groupetci,DC=com" should work.
  • Import-Csv : The member "" is already present
    1 Posts | Last post July 07, 2014
    • Trying to setup a test and have anytime there are duplicate entries it throws the The member "" is already present
      
      Seems like it does it when adding duplicate items to any of the following in the csv
      
      Office	Title	Description	Department	Company
      
      Any thoughs
      
  • password viewable?
    1 Posts | Last post June 12, 2014
    • Hi Rich,
       
      I am wondering if is possible to change the setting to make the password viewable upon entry?
  • add-adgroupMember "GroupName"
    1 Posts | Last post June 06, 2014
    • Hi Rich,
      
      Do you know if it is possible to add a group membership line in the script...
      
      Something like
      add-adgroupMember "GroupName"
      
      Thanks!
  • How to add attributes to the script.
    1 Posts | Last post May 13, 2014
    • I'm looking to add the following AD attributes to this script as well as use them in CSV mode.
      
      employeeNumber
      homeDirectory
      homeDrive
      
      Any help would be greatly appreciated.
      
      Thanks!!
  • email id field
    1 Posts | Last post April 29, 2014
    • Hi,
      
      is there any possibility to populate Active Directory smtp email id field?
      
      Thanks.
1 - 10 of 95 Items