locked
Export Sitelinks so that "SitesIncluded" is exported in the correct format RRS feed

  • Question

  • so when I use the below command I get all info as below, But if I chuck in an |Export-Csv I don’t get the data for SitesIncluded, instead I get "Microsoft.ActiveDirectory.Management.ADPropertyValueCollection" what do I need to add to this command to get it to export in right format?

    PS C:\Windows\system32> Get-ADReplicationSiteLink -Filter *


    Cost                          : 100
    DistinguishedName             : CN=DEFAULTIPSITELINK,CN=IP,CN=Inter-Site
                                    Transports,CN=Sites,CN=Configuration,DC=XXXXXX,DC=govt,DC=nz
    Name                          : DEFAULTIPSITELINK
    ObjectClass                   : siteLink
    ObjectGUID                    : de7676ce-595e-41d4-a56a-2544f5fa9804
    ReplicationFrequencyInMinutes : 15
    SitesIncluded                 : {CN=Auckland,CN=Sites,CN=Configuration,DC=XXXXXX,DC=govt,DC=nz,
                                    CN=Wellington,CN=Sites,CN=Configuration,DC=XXXXXX,DC=govt,DC=nz}

    Sunday, November 8, 2015 10:13 PM

Answers

  • Get-ADReplicationSiteLink -Filter *|select -expand SitesIncluded |Export-Csv sites.csv


    \_(ツ)_/

    • Marked as answer by wesley35 Monday, November 9, 2015 10:28 PM
    Sunday, November 8, 2015 10:24 PM

All replies

  • Get-ADReplicationSiteLink -Filter *|select -expand SitesIncluded |Export-Csv sites.csv


    \_(ツ)_/

    • Marked as answer by wesley35 Monday, November 9, 2015 10:28 PM
    Sunday, November 8, 2015 10:24 PM
  • To me, it seems you'd like to keep the properties you're already returning, and better handle the SiteIncluded property. If so, take a look at the example below. I've joined the SitesIncluded with a semi-colon. Using the -join operator this way, will help you get you the proper results in your Csv file.

    Get-ADReplicationSiteLink -Filter * | 
        Select-Object Cost,DistinguishedName,Name,ObjectClass,ObjectGUID,ReplicationFrequencyInMinutes,@{N='SitesIncluded';E={($_.SitesIncluded) -join ';'}} | 
        Export-Csv -Path .\sites.csv -NoTypeInformation




    Monday, November 9, 2015 5:21 PM