December 2013
Intermediate to advanced
1872 pages
153h 31m
English
Using the object retrieved in the $sql_server variable, you can create a quick report of database usage using the databases property of that object, as shown here:
PS SQLSERVER:\SQL\<servername>\<instancename>>$sql_server.databases| Format-Table -autosize Name,@{ Label= "% Used" Expression={[math]::round((($_.spaceavailable/1kb)/$_.size),2)} }Name % Used---- ------AdventureWorks2012 0.27Empty_Db 0.07master 0.14model 0.22msdb 0.01my_database 0.23tempdb 0.8
Using the Format-Table cmdlet, you can easily and quickly create all kinds of reports. Some capabilities we haven’t discussed ...