Database File Info

Mike Fal shows us how to get database file information using Powershell:

To do this, I dove into the SMO object model. This gets a little /Net-y, but the good news is there’s lots of properties we can use to get the information we are looking for. If we look at both the DataFile and LogFile classes, there are properties readily available for us. Both classes have UsedSpace and Size properties (both measured in KB), from which we can derive both available space and percentage used. All it takes is wrapping some collection and formatting logic around these objects and we’re good to go. You can see my full function up on GitHub.

This is a nice example of using the Powershell pipeline to build an end product, in this case an HMTL report of log and file usage.

Related Posts

Failing Pester Tests Can Still Show Green

Shane O’Neill walks us through an oopsie moment: In modifying the template, I forgot to take out the original It block and just put my It block inside it. This lead to my block “pass by deafult” failed (as it should cause of that typo) but the original, parent block it was in “does something useful” passed! Click […]

Read More

Quick Thoughts on Dot-Sourcing in Powershell Modules

Cody Konior wants to speed up module loading: One of the more heated ideas is that you should combine all of your scripts into a massive file and execute it once instead. Currently dbatools uses a mix of these techniques in great detail and to great success. I don’t want to use a single file because I […]

Read More

Categories

March 2016
MTWTFSS
« Feb Apr »
 123456
78910111213
14151617181920
21222324252627
28293031