Part 1 of the series dealt with 'set' cmdlets with respect to multi-valued attributes.
Now in part 2, we are going to look at the challenges faced when retrieving multi-valued attributes using 'Get' cmdlets and workarounds for them. If the number of the values stored in the attribute is high, then displaying the entire list on screen is not possible as powershell tends to append the list with “. . . “ implying that there are more values in the property than displayed on screen.
Get-DistributionGroup "Test DL" | fl Name, AcceptMessagesOnlyFrom
The pipeline can be manipulated to export all the attributes as shown below:
Now in part 2, we are going to look at the challenges faced when retrieving multi-valued attributes using 'Get' cmdlets and workarounds for them. If the number of the values stored in the attribute is high, then displaying the entire list on screen is not possible as powershell tends to append the list with “. . . “ implying that there are more values in the property than displayed on screen.
Get-DistributionGroup "Test DL" | fl Name, AcceptMessagesOnlyFrom
Exporting the values to a CSV/ text file is also a concern, since the actual values in the attribute are not exported to the file as seen below.
Get-DistributionGroup "Test DL" | Select-Object Name, AcceptMessagesOnlyFrom | Export-Csv "C:\DL.csv" -Notype
Get-DistributionGroup "Test DL" | Select-Object Name, AcceptMessagesOnlyFrom | Export-Csv "C:\DL.csv" -Notype
The pipeline can be manipulated to export all the attributes as shown below:
Get-DistributionGroup "Test DL" | Select-Object Name,@{Name="AcceptMessagesOnlyFrom";Expression={[string]::join(";",$_.AcceptMessagesOnlyFrom)}} | Export-Csv c:\DL.csv –NoTypeInformation
The output is shown below :
The text in image above has been altered to confine within the image size to display all the values contained in the CSV file.
No comments:
Post a Comment