|
Guy recommends :
Find out which of your VMs are a waste of space and which VMs need more resources.
|
PowerShell Import-CsvPowerShell's Import-Csv with New-QADUser
|
||||||||||||
| Name | sAMAccountName |
| Bush | gbush |
| Obama | bobama |
| Clinton | hclinton |
Note 8: The first row holds the vital property names. You could think of these 'fields', as LDAP properties, or import-Csv parameters.

Solarwinds' Orion performance monitor will help you discover what's happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.
Perhaps the NPM's best feature is the way it suggests solutions to network problems. Its second best feature is the ability to monitor the health of individual VMWare virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you take advantage of Solarwinds' offer.
Download a free trial of the Network Performance Monitor.

In the master plan we will employ the import-Csv cmdlet to read the spreadsheet. Then we will feed in the values held in the columns, so that they become the properties of the new-QADUser.
Preparation: Edit $OuBorn. The value of 'OU=PowerShell,DC=cp2,DC=mosel' will not work with your domain.
Where is the path to your spreadsheet? Edit $Freshmen.
# PowerShell script create users in a named OU
# Author: Guy
Thomas
# Version 2.4 August 2008 tested on PowerShell v 1.0
$OuBorn = 'OU=PowerShell,DC=cp2,DC=mosel'
$Freshmen =
'E:\powershell\QAD\bunch4.csv'
import-csv $Freshmen |`
where
{new-QADUser -ParentContainer $OuBorn `
-name $_.name -sAMAccountName
$_.sAMAccountName}
Note 9: The two crucial cmdlets are: import-Csv and new-QADUser. Observe how PowerShell pipes the output of import-Csv into new-QADUser. Incidentally, (|) is an important method in PowerShell, learn it here and employ this pipe in future scripts.
Note 10: I have introduced two variables, $OuBorn and $Freshmen. To be brutally honest, the script will not work unless you change the values held by these $Variables to reflect your environment.
Note 11: $_. is a special PowerShell variable which says, 'In this stream', hence $_.name means use the name column from the spreadsheet. I hope that you can now see the importance of the first row in your .csv file.
Note 12: Observe the backtick (`). Perhaps the best way of seeing what this word-wrap symbol achieves is to remove it, and type the command all on one line:
import-csv $Freshmen | where {new-QADUser -ParentContainer $OuBorn -name $_.name -sAMAccountName $_.sAMAccountName}

Import users from a spreadsheet. Just provide a list of the users with their fields in the top row, and save as .csv file. Then launch this FREE utility and match your fields with AD's attributes, click to import the users. Optionally, you can provide the name of the OU where the new accounts will be born.
There are also two bonus tools in this free download, and all 3 have been approved by Microsoft:
Download your FREE bulk import tool.
My speciality is getting you started. Once you can create a basic user, then it will be a labour of love to research more properties to include in your spreadsheet. For example, if you have a real-life task of creating dozens of users, then adding values for LastName, and UserPrincipalName would result in better users! See more examples of PowerShell Import-CSV
Two more things that you might like to do with your users
For example:
# PowerShell script create users in a named OU
# Author: Guy
Thomas
# Version 2.4 August 2008 tested on PowerShell v 1.0
$OuBorn = 'OU=PowerShell,DC=cp2,DC=mosel'
$Freshmen =
'E:\powershell\QAD\bunch4.csv'
import-csv $Freshmen |`
where
{new-QADUser -ParentContainer $OuBorn `
-name $_.name -sAMAccountName
$_.sAMAccountName `
; enable-QADUser $_.name }
Tip: Try an Export-Csv for a user that you created manually in Active Directory User and Computers. Then research the LDAP names in the first row. Naturally, the more property boxes that you add information, the more sense that you can make of the resulting export.
In order to import user accounts into active directory you need to be multi-talented. In addition to PowerShell skills, you need to be a veteran of spreadsheets and a professor of LDAP properties. What makes a difficult task achievable is the QADUser object which you obtain with the QAD snap-in.
If you like this page then please share it with your friends
• PowerShell Home • Quest QAD • QADUser • QADGroup • QADComputer
• Export-CSV • Import CSV • QAD Password • Add-PSSnapin
• Get-AdUser -filter • Windows PowerShell • Windows PowerShell .Net
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.

You get 36 topics organized into these 3 sections:
1) Getting Started
2) Real-life tasks
3) Examples of Syntax.
In addition to the ebook, you get a PDF version of this Introduction to PowerShell ebook It runs to 120 pages of A4.
*
Custom Search
|
Guy Recommends: WMI Monitor and It's Free!
|
|
Home Copyright © 1999-2012 Computer Performance LTD All rights reserved Please report a broken link, or an error. | |