ebrown35
 New Member Posts:30

 |
| 22 Jul 2009 07:26 AM |
|
Import-Csv C:\scripts\delete_groups.csv | Get-QADGroup -Identity {$_.SamAccountName} -SizeLimit 0 -DontUseDefaultIncludedProperties -IncludedProperties dn | Select-Object dn | Export-Csv -Path "C:\scripts\delete_groups_dn.csv"
The script above is returning the following error:
Get-QADGroup : The (&(objectClass=*)(sAMAccountName=TSR))) search filter is invalid. At line:1 char:55 + Import-Csv C:\scripts\delete_groups.csv | Get-QADGroup <<<< -Identity {$_.SamAccountName} -SizeLimit 0 -DontUseDefa ultIncludedProperties -IncludedProperties dn | Select-Object dn | Export-Csv -Path "C:\scripts\delete_groups_dn.csv" + CategoryInfo : NotSpecified: (:) [Get-QADGroup], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Quest.ActiveRoles.ArsPowerShellSnapIn.Cmdlets.GetGroupCmdlet2
All I am trying to do is import a list of list of groups (sAMAccountName) and return the DN and export the list. What am I missing? |
|
|
|
|
Ayth
 Basic Member Posts:232

 |
| 22 Jul 2009 07:35 AM |
|
Try this: Import-Csv C:\scripts\delete_groups.csv | Foreach {Get-QADGroup -Identity $_.SamAccountName -SizeLimit 0 -DontUseDefaultIncludedProperties -IncludedProperties dn | Select-Object dn} | Export-Csv -Path "C:\scripts\delete_groups_dn.csv" Essentially missing the foreach loop to actually go through the contents of the csv. Cheers. |
|
| My Blog about Powershell http://poweroftheshell.blogspot.com/
Follow me on twitter @darrinhenshaw |
|
|
ebrown35
 New Member Posts:30

 |
| 22 Jul 2009 07:43 AM |
|
that returned a similar error:
Get-QADGroup : The (&(objectClass=*)(sAMAccountName=TSR))) search filter is invalid. At line:1 char:64 + Import-Csv C:\scripts\delete_groups.csv | Foreach {Get-QADGroup <<<< -Identity $_.SamAccountName -SizeLimit 0 -DontU seDefaultIncludedProperties -IncludedProperties dn | Select-Object dn} | Export-Csv -Path "C:\scripts\delete_groups_dn. csv" + CategoryInfo : NotSpecified: (:) [Get-QADGroup], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Quest.ActiveRoles.ArsPowerShellSnapIn.Cmdlets.GetGroupCmdlet2 |
|
|
|
|
Ayth
 Basic Member Posts:232

 |
| 22 Jul 2009 07:59 AM |
|
Interesting it works for me. I created a csv with a couple groups in it. For curiousities sake, what happens if you run Get-QADGroup -Identity $_.SamAccountName -SizeLimit 0 -DontUseDefaultIncludedProperties -IncludedProperties dn Does it generate output? Also, how was the csv generated? |
|
| My Blog about Powershell http://poweroftheshell.blogspot.com/
Follow me on twitter @darrinhenshaw |
|
|
ebrown35
 New Member Posts:30

 |
| 22 Jul 2009 08:04 AM |
|
Get-QADGroup : Cannot validate argument on parameter 'Identity'. The argument cannot be null or empty. At line:1 char:23 + Get-QADGroup -Identity <<<< $_.SamAccountName -SizeLimit 0 -DontUseDefaultIncludedProperties -IncludedProperties dn + CategoryInfo : InvalidData: (:) [Get-QADGroup], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Cmdlets.GetGroupC mdlet2
|
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
| 22 Jul 2009 08:34 AM |
|
I assume there is a column header in your csv file named 'SamAccountName', the following should work: Import-Csv C:\scripts\delete_groups.csv | Get-QADGroup -Identity {$_.SamAccountName} | Select-Object name,dn | Export-Csv "C:\scripts\delete_groups_dn.csv" |
|
Shay Levy Windows PowerShell MVP
http://PowerShay.com
PowerShell Community Toolbar
Twitter: @ShayLevy |
|
|
ebrown35
 New Member Posts:30

 |
| 30 Jul 2009 11:54 AM |
|
Yeah Shay there was an incorrect group name in the.csv towards the bottom of the list that was causing it to fail, once I resolved that everything was fine. Now I have to export the members of each one of the groups on the C:\scripts\delete_groups.csv list. |
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
ebrown35
 New Member Posts:30

 |
| 31 Jul 2009 07:05 AM |
|
Shay I found one of your examples in another thread and made on small modification:
Import-Csv C:\scripts\delete_groups.csv | Get-QADGroup -Identity {$_.Name} | foreach {
$group = $_
$group | Get-QADGroupMember | select Name,SAMAccountName,Description,Office,Type,@{n="GroupName";e={$group.name}} | export-csv "c:\scripts\groups\$($group.name).csv" -noType
}
It works perfectly!
|
|
|
|
|