locked
Import-CSV | New-ADGroup not working as expected with Powershell RRS feed

  • Question

  • I've looked all over and I can't seem to find an explanation for why this command works perfectly with New-ADUser but not with New-ADGroup.

    These are commands I'm using:

    For Users:

    Import-CSV C:\Imports\adusers.csv | New-ADUser

    This works great. All 500+ users imported with all fields.

    For Groups:

    Import-CSV C:\Imports\adgroups.csv | New-ADGroup

    Only the first line is run correctly. Then I get this error: The specified group already exists

    Here is a snip of my CSV for Groups:

    Name,DisplayName,Description,GroupCategory,GroupScope,Path
    DB Users,DB Users,Group for DB users,Global,"OU=Security Groups,OU=ABC Users,DC=domain,DC=local"
    Accounting,Accounting,Access to the Accounting folder,Security,Global,"OU=Security Groups,OU=ABC Users,DC=domain,DC=local"

    Am I missing something here or is this not possible?

    THanks.





    • Edited by jayIT8 Wednesday, December 3, 2014 9:51 PM
    Wednesday, December 3, 2014 8:52 PM

Answers

  • I knew I would figure this out as soon as I posted it...

    This is the behavior you see if the SamAccountName field is not included.

    • Proposed as answer by jrv Wednesday, December 3, 2014 9:43 PM
    • Marked as answer by jayIT8 Wednesday, December 3, 2014 9:49 PM
    Wednesday, December 3, 2014 9:21 PM