This function will allow you to query any server hosting SQL and return the file sizes for the each Database file(MDF) and Transaction Log file(LDF). This does not return back the file locations for each database. I have tested this on SQL 2000, 2005 and 2008.

Ex.

Get-SQLFileSize -comp dc1

Computer                      Database                      FileType                                            Size_MB
--------                      --------                      --------                                            -------
dc1                           susdb                         MDF                                                  391.36
dc1                           tempdb                        MDF                                                   8.192
dc1                           msdb                          MDF                                                   4.992
dc1                           model                         MDF                                                   1.216
dc1                           mssqlsystemresource           MDF                                                   39.36
dc1                           master                        MDF                                                   4.096
dc1                           susdb                         LDF                                                   5.176
dc1                           tempdb                        LDF                                                   7.608
dc1                           msdb                          LDF                                                   3.448
dc1                           model                         LDF                                                   0.504
dc1                           mssqlsystemresource           LDF                                                   0.504
dc1                           master                        LDF                                                   1.016

 

PowerShell
Edit|Remove
. .\Get-SQLFileSize.ps1