نمایش نتایج: از شماره 1 تا 2 از مجموع 2

موضوع: Script to Create Lab Users – Powershell

  
  1. #1
    نام حقيقي: 1234

    مدیر بازنشسته
    تاریخ عضویت
    Jul 2009
    محل سکونت
    5678
    نوشته
    5,634
    سپاسگزاری شده
    2513
    سپاسگزاری کرده
    272

    Script to Create Lab Users – Powershell

    کد:
    http://www.telnetport25.com/component/content/article/15-powershell/321-quick-post-script-to-create-lab-users-powershell-version.html
    A long time ago I posted a VBSCRIPT and CSV file which when executed created over 300 user accounts in Active Directory which was designed to give you a number of test accounts which could be used within a LAB environment to test Exchange Server.
    As mentioned the original script was based around VBSCRIPT and Exchange 2003 and also required a little bit of manual intervention in order for it to work within your specific environment.
    Predominantly it was designed to work against Windows 2000 / 2003 server AD environments – however as time has elapsed its underling functionality has been superseded with the advent of Powershell / Windows 2008 and Exchange 2007 and 2010 to the point that under certain system configurations it will no longer work.
    Therefore given the above (and that I have been rebuilding my test lab) I am pleased to present to you with an updated CSV file and script (where the script is now Powershell based) – which supports the following scenarios:

    • Can be executed via Powershell versions 1.0 and 2.0
    • Can be run on the following Operating Systems: Windows 2008 and Windows 2008 R2 (will also support Windows 2003 with Powershell installed)
    • The accounts created can be configured with mailboxes for Exchange 2007 and Exchange 2010

    So, if you are creating a test lab which is based around the above technologies and would like an easy way to get over 300 unique accounts into your Active Directory environment please feel free to download the following file to either your LAB Domain Controller or Exchange Server:
    Create-Users.exe [ 142KB ]
    The above file is a self extracting ZIP which when executed with extract two files to you Exchange Server / Windows 2008 Domain Controller.
    When you have downloaded and extracted the scripts to your server – open a Powershell Console and navigate to the location where they are located – when there type in:
    .\CreateUsersFromCSV.ps1 and then press – see below;

    When the script executes you will be presented with a Windows “Open” dialog box – navigate to the location where you extracted the files and then choose the sample CSV – see below;

    The script will then execute creating each user in your Active Directory Lab environment – the Default password is “Password1” – see below;

    When the script has completed – open Active Directory Users and Computers – you will see a new OU called “ExchangeUsers” – within this OU are the new accounts that you can play with – see below;

    I hope that you find the above useful




    موضوعات مشابه:

  2. #2
    نام حقيقي: 1234

    مدیر بازنشسته
    تاریخ عضویت
    Jul 2009
    محل سکونت
    5678
    نوشته
    5,634
    سپاسگزاری شده
    2513
    سپاسگزاری کرده
    272

    Populating Test Labs with User Accounts

    کد:
    http://www.telnetport25.com/component/content/article/2-catexchange2003/241-populating-test-labs-with-user-accounts.html
    Those of you that have been following this blog will know that recently I have made a number of posts that are either based around the virtues of Test Labs or indeed that work that I have been doing in relation to them – for information my posts on the subject are here, here, here, here and finally here.
    Now one of the most daunting things about test labs, is not always the construction of the Domain, or indeed the creation of the servers within them, but how to you populate them with any meaningful user data as part of the Directory (e.g. creating a number of users).
    In this article I would like to provide all of you with the following tools that will help you construct the users in your test lab:

    • A CSV file with 389 unique users within it – this files contains the following data FirstName, Surname, samAccountName, Display Name, Password, and a UserPrincipleName
    • A VBSCRIPT that will parse the data in the CSV file and create 389 users account in your test LAB which are ready to be used as part of either an Exchange 2003 or Exchange 2007 test lab


    Before I begin (and if you are interested in using this article) you will need to download the following files to your Exchange server or domain controller in your LAB:
    LabUsers.csv – 389 Fictonal People just for you!
    LAB_CreateUsers.vbs – the script that parses the CSV file and creates the file in your directory.
    When you have downloaded them place them in a Directory Called “LBUsers
    Then create a new Organizational Unit in Active Directory called “ExchangeUsers” – it is easier to make this OU in the root of your AD structure, however, the script can handle nested OU’s as well.
    What you will need to do now is modify the UPN (User Principle Name) for all users within the csv file – now, don’t panic you do not have to go through all 389 users – all you need to do is:
    Open the CSV file on your server in NOTEPAD – then go to the Edit menu and select the replace option – see below

    When the replace dialog box appears in the “Find What” area type in: “@ldn.com” (without quotes) and then in the “Replace with” area type in the name of your test domain – “@” (without quotes) – so if you had a test domain called @billy.com, billy.com is what you would type into the “Replace with” area – see below

    Click on the “Replace All” button, NOTEPAD will then go away and replace all entries with the values that are relevant to your test lab domain.
    When NOTEPAD is finished – save the file.
    When you are happy with the content of the CSV file you can begin by double clicking on the Lab_CreateUsers.vbs file – which when first launched will prompt you for the following information:

    Enter in the full path to the CSV file (do not enter in the file name) and ensure that you add in the trailing slash for the path – then click the “OK” button.

    You will then be presented CSV filename dialog box – enter in LabUsers.csv and then click on the “OK” button.

    Then you will be prompted for the target OU that you wish to use this should be entered in the format of “OU=ExchangeUsers” (without quotes) – if you have placed your OU inside a parent OU then the format will change to “OU=ExchangeUsers,OU= ” – again without quotes.
    When you are happy with your OU settings click on the “OK” button.

    When the script has completed, you will be presented with the dialog box above – go to Active Directory Users and Computers and navigate to the OU that you created and you should see something similar to the following:

    At the end of this process you should now have 389 users, in an OU called “ExchangeUsers” ready to be part of your test lab.
    For reference the following is the contents of the LAB_CreateUsers.vbs script:
    کد:
    strCSVPath  = InputBox(”Please enter in the full path to your CSV (PLEASE INCLUDE  THE END SLASH \)”)
    strCSVName = InputBox(”Please Enter in the  FileName”)
    strOU = InputBox(”Please Enter in the destination OU  (FORMAT: OU=,OU=”)
     set  csvInputConn = createobject(”ADODB.connection”)
    set csvInputRS =  createobject(”ADODB.recordset”)
     csvInputConn.Open  “Provider=Microsoft.Jet.OLEDB.4.0;” & “Data Source=” &  strCSVPath & “;” & “Extended  Properties=”"text;HDR=NO;FMT=Delimited”"”
    csvInputRS.open “SELECT *  FROM ” & strCSVName,csvInputConn
     Set  RootLDAP = GetObject(”LDAP://rootDSE“)
    Set ADLocation =  GetObject(”LDAP://” & strOU & “,” &  RootLDAP.Get(”defaultNamingContext”))
     do  until csvInputRS.EOF 
     On Error Resume Next
      strFirstName =  csvInputRS.Fields.Item(0).value
      strSurName =  csvInputRS.Fields.Item(1).value
      strSam =  csvInputRS.Fields.Item(2).value
      strDisplayName =  csvInputRS.Fields.Item(3).value
      strPassword =  csvInputRS.Fields.Item(4).value
      strUPN =  csvInputRS.Fields.Item(5).value
     
      Set strUser =  ADLocation.Create(”User”,”cn=” & strSam)
       strUser.put  “sAMAccountName”,strSam
      strUser.put “givenName”,strFirstName
      strUser.put  “sn”,strSurname
      strUser.put “UserPrincipalName”,strUPN
      strUser.put  “DisplayName”,strDisplayName
      strUser.put “name”,strDisplayName
      strUser.put  “mail”,strUPN
      strUser.SetInfo
      strUser.SetPassword sPassword
     
      strUser.Put  “userAccountControl”, 512
      strUser.SetInfo
      
      csvInputRS.movenext
     Loop
     WScript.Echo  “Script Completed - Hit F5 in the OU that you selected”
    WScript.Quit




کلمات کلیدی در جستجوها:

LAB_CreateUsers.vbs

open csv file adodb windows 2008

برچسب برای این موضوع

مجوز های ارسال و ویرایش

  • شما نمی توانید موضوع جدید ارسال کنید
  • شما نمی توانید به پست ها پاسخ دهید
  • شما نمی توانید فایل پیوست ضمیمه کنید
  • شما نمی توانید پست های خود را ویرایش کنید
  •