Database EXtendedProperty is not displaying in excel sheet

  • AKP

    SSCommitted

    Points: 1753

    Hi guys,

    I am trying to export all the database properties into .csv file using Powershell script. But the extendedProperty which i added into database is not displaying in csv file. I am getting those property from powershell prompt but not in csv file ( in csv file, the extenededProperties column displays this value: Microsoft.SqlServer.Management.Smo.ExtendedPropertyCollection

    I am using following script:

    foreach ($srv in get-content "D:\PS\Server3.txt") -- this server3.txt consists of servernames.

    {

    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null

    $cn = new-object system.data.SqlClient.SqlConnection("Data Source=$inst;Integrated

    Security=SSPI;Initial Catalog=master");

    $s = New-Object ('Microsoft.SqlServer.Management.Smo.Server') $srv

    $dbs=$s.databases

    $dbs | select * | Export-Csv -path "D:\PS\dbdetails.csv"

    }

    Plz help me how to display extended property of each database into csv file.

    I appreciate your kind help.

    thanks

    AKP

  • MG-148046

    SSCrazy Eights

    Points: 9945

    channge this

    $dbs | select * | Export-Csv -path "D:\PS\dbdetails.csv"

    to

    $dbs.ExtendedProperties | select Name, Value | Export-Csv -path "D:\PS\dbdetails.csv"

    and see if that helps

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply