|
Replies:
5
-
Pages:
1
-
Last Post:
Mar 8, 2010 1:58 AM
by: Jitendra Kumar
|
|
|
Posts:
2
Registered:
12/3/09
|
|
|
|
Empty fields when importing from CSV
Posted:
Dec 3, 2009 5:52 AM
|
|
|
Dear All,
I'm trying to write a script for creating users in AD based on an import from CSV file.
The main point is that a number of fields in the file are EMPTY, and it looks like they should be processed correctly (according to http://dmitrysotnikov.wordpress.com/2008/10/07/skip-empty-csv-fields/).
In my case I get an error: The attribute syntax specified to the directory service is invalid. (Exception from HRESULT: 0x8007200B)
CSV file: firstname,lastname,name,alias,mail,department,title,description,phone,password Test,Tester,Tester Test,t.tester,,IT,Test administrator,IT,,87654321
Script excerpt: $data = import-csv $args[0] foreach ($i in $data) { New-QADUser -Service "server.domain.local" -ParentContainer "OU=Users,DC=domain,DC=local" -UserPassword $i.password -SamAccountName $i.alias -UserPrincipalName $upn -Name $i.name -City "Moscow" -Company "Company" -Department $i.department -Email $i.mail -FirstName $i.firstname -LastName $i.lastname -Office "Company" -PhoneNumber $i.phone -PostalCode "123456" -StreetAddress "Some St., 32" -Title $i.title -ObjectAttributes @{c="RU";co="Russia"} -Description $i.description -DisplayName $i.name | Enable-QADUser }
Problem is that different users have different empty fields, and it's mighty inconvenient to build up a command based on the value of the field.
Is this correct behaviour for empty fields?
|
|
|
Posts:
415
Registered:
9/4/07
|
|
|
|
Re: Empty fields when importing from CSV
Posted:
Dec 7, 2009 8:17 AM
in response to: karabatov
|
 |
Answered |
|
|
It's a bug in AD Cmdlets 1.3. Reference number: 109860 String parameters in New-* cmdlets can't be $null or empty. String parameters in Set-* cmdlets can't be empty (but can be $null).
This bug will be fixed in maintenance release. ETA is the end of January, 2010.
Workaround for Set-*: use $null values instead of "": Example: Use Set-QADUser testUser -Description $null instead of Set-QADUser testUser -Description ""
Workaround for New-*: use New-* | Set-* combination. Example: Use New-QADUser -ParentContainer my.domain.com/test -Name testUser | Set-QADUser -Description $null instead of New-QADUser -ParentContainer my.domain.com/test -Name testUser -Description $null
|
|
|
Posts:
2
Registered:
12/3/09
|
|
|
|
Re: Empty fields when importing from CSV
Posted:
Dec 7, 2009 10:15 AM
in response to: Andrey Moiseev ...
|
|
|
Thanks, Andrey, especially for a workaround.
Will be waiting for a fix!
|
|
|
Posts:
3
Registered:
1/26/10
|
|
|
|
Re: Empty fields when importing from CSV
Posted:
Jan 26, 2010 8:18 PM
in response to: karabatov
|
|
|
Any update on the release date? The $null method doesn't seem to work for me but if I use any character it works fine even a space.
|
|
|
Posts:
18
Registered:
3/9/07
|
|
|
|
Re: Empty fields when importing from CSV
Posted:
Feb 24, 2010 4:54 PM
in response to: butlerrc30
|
|
|
Workaround:
$PathCSV = "test2.csv" $OU = "OU=Users,DC=XYZ,DC=local" #---
$users = Import-Csv $PathCSV $props = $users[0] | gm -MemberType NoteProperty |? {$_.name -ne "Name"} $users |%{ $makenew = 'new-QADuser -Name $_.name -ParentOU $OU' foreach ($prop in $props){ if ($_.($prop.name)){$makenew += (" -" + $prop.name + " " + '$_.' + $prop.name)} } iex $makenew }
|
|
|
Posts:
1
Registered:
3/8/10
|
|
|
|
Re: Empty fields when importing from CSV
Posted:
Mar 8, 2010 1:58 AM
in response to: Andrey Moiseev ...
|
|
|
Is the fix ready for this? Can we download it. If so, please provide the link.
Thanks,
Jitendra.
|
|
|
|
Legend
|
|
MVP: 2501
+
pts
|
|
Guru: 2001
- 2500
pts
|
|
Expert: 751
- 2000
pts
|
|
Enthusiast: 31
- 750
pts
|
|
Novice: 0
- 30
pts
|
|
Moderators
|
|
Helpful answer
(5 pts)
|
|
Answered
(10 pts)
|
|