• opc.three is correct the PrimaryFilePath won't help much here, apologies.

    However doing something like this

    $server = "svr"

    $sqlserver = new-object “Microsoft.SqlServer.Management.Smo.Server” $server

    Invoke-Sqlcmd -Query "SELECT a.name ,

    b.filename

    FROM sys.sysdatabases a

    INNER JOIN sys.sysaltfiles b ON a.dbid = b.dbid

    WHERE fileid <> 2

    ORDER BY name ;" -ServerInstance $sqlserver

    should be closer to get the data file paths..just don't forget to add the snapins required.

    And I also suggest using the Get-acl cmdlet.

    edit: typo