Get database properties with Powershell


Based on the previous article “Get Database and database file properties” I wanted to get these values from multiple servers with the results in an single and a combined comma separated file.
That why I created a script to get the database properties with Powershell.

The script below takes two arguments:

  1. input: full path to input file with SQL server instance(s)
  2. output: full path to directory to output files to

Make sure that the output directory doesn’t end with a “\”!

The format for the input file is easy. Just enter a SQL Server instance with the full name. For a default instance use the name of the servers. For a named instance use the servername plus the instance name i.e. “dbserver1\inst1”.
Make sure that every servers is on a new line.

The script outputs a file per server and a file with all the results combined.

If you like the script please leave a comment

Leave a Reply