• A solution using PrimaryFilePath will only account for the location of the primary data file for the database specified. If that database has multiple data files and one of those files is not located in the same path the solution, or if another database on the instance has files in a different location, then the script will not report all the required details.

    To be more complete I think you will want to iterate over the databases collection. Then for each database iterate over the filegroups collections. Within that iterate over the files collection and capture the database name and directory. Do the same for log files collection of database object.

    Once you have a complete list of where all data or log files reside per your instance you can use Get-ACL on each one and deliver the results.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato