ebrown35
 New Member Posts:30

 |
| 30 Jul 2009 01:59 PM |
|
Import-Csv C:\scripts\groups_backup.csv | Get-QADGroup -Identity {$_.GroupName} | Select-Object SamAccountname,proxyaddresses | Export-Csv "C:\scripts\groups\cox_backup.csv"
But it returns this: System.Object[] for the proxyaddresses values. I know this is because proxyadddresses is multivalued, how can I use a foreach to list the group name with all of its proxyaddresses and export it? |
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
| 30 Jul 2009 11:04 PM |
|
Try this (not tested but should work), it will join the list of addresses into one string, each address will be seperated with a semicolon: Import-Csv C:\scripts\groups_backup.csv | Get-QADGroup -Identity {$_.GroupName} | Select-Object SamAccountname,@{n="proxyaddresses";e={[string]::join(";",$_.proxyaddresses)}} | Export-Csv "C:\scripts\groups\cox_backup.csv"
|
|
Shay Levy Windows PowerShell MVP
http://PowerShay.com
PowerShell Community Toolbar
Twitter: @ShayLevy |
|
|
ebrown35
 New Member Posts:30

 |
| 31 Jul 2009 07:17 AM |
|
This worked great, is there another way that you could list each proxyaddress on its on line with the the group repeated for each address like this: group1,proxy1 group1,proxy2 group1,proxy3 group1,proxy4 group2,proxy1 group2,proxy2 group2,proxy3 group2,proxy4 could'nt you use a foreach and pipe the result through multiple times (whoa gettin over my own head, lol)
|
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
| 31 Jul 2009 07:26 AM |
|
Yeap Import-Csv C:\scripts\groups_backup.csv | Get-QADGroup -Identity {$_.GroupName} | Foreach-Object{ $g = $_.name $_.proxyaddresses | select @{n="Group";e={$g}},@{n="ProxyAddress";e={$_}} } |
|
Shay Levy Windows PowerShell MVP
http://PowerShay.com
PowerShell Community Toolbar
Twitter: @ShayLevy |
|
|
ebrown35
 New Member Posts:30

 |
| 01 Dec 2009 12:36 PM |
|
Is there a way to adapt this to users? I have tried to no avail. |
|
|
|
|
ebrown35
 New Member Posts:30

 |
| 01 Dec 2009 12:48 PM |
|
Import-Csv C:\scripts\users_backup.csv | Get-QADUser -Identity {$_.SamAccountName} | Foreach-Object{ $g = $_.name $_.proxyaddresses | select @{n="User";e={$g}},@{n="ProxyAddress";e={$_}} }
why doesn't the above work, it seems that it should but it returns no result? |
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
ebrown35
 New Member Posts:30

 |
| 02 Dec 2009 05:25 AM |
|
Well I wanted to have the ouput in similar format as in the post above:
user1,proxy1
user1,proxy2
user1,proxy3
user1,proxy4
user2,proxy1
user2,proxy2
user2,proxy3
user2,proxy4
|
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
| 02 Dec 2009 05:35 AM |
|
Import-Csv C:\scripts\users_backup.csv | Get-QADUser -Identity {$_.SamAccountName} -ip proxyAddresses | foreach { $userName = $_.Name $_.proxyAddresses | where {$_ -like 'smtp:*'} | select @{n="DisplayName";e={$userName}},@{n="Email";e={$_.substring(5)}} } |
|
Shay Levy Windows PowerShell MVP
http://PowerShay.com
PowerShell Community Toolbar
Twitter: @ShayLevy |
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
ebrown35
 New Member Posts:30

 |
| 02 Dec 2009 05:39 AM |
|
Posted By Shay on 02 Dec 2009 05:36 AM By the way, what Exchange version? The above is for 2003.
Yes, 2003.
|
|
|
|
|
cameronove
 Basic Member Posts:332

 |
| 24 Dec 2009 04:23 AM |
|
Posted By Shay on 02 Dec 2009 05:35 AM
Import-Csv C:\scripts\users_backup.csv | Get-QADUser -Identity {$_.SamAccountName} -ip proxyAddresses | foreach { $userName = $_.Name $_.proxyAddresses | where {$_ -like 'smtp:*'} | select @{n="DisplayName";e={$userName}},@{n="Email";e={$_.substring(5)}} }
Hi Shay, All through the examples on this post in the select portion in the hash table you use the variables n and e. Are those arbitrary names or are they names that are required for the select to work with hash tables? |
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|