{"id":15,"date":"2019-01-03T00:50:11","date_gmt":"2019-01-03T05:50:11","guid":{"rendered":"http:\/\/itblog.ldlnet.net\/?p=15"},"modified":"2019-01-27T03:50:03","modified_gmt":"2019-01-27T08:50:03","slug":"getting-drive-space-through-powershell-for-a-server","status":"publish","type":"post","link":"https:\/\/itblog.ldlnet.net\/index.php\/2019\/01\/03\/getting-drive-space-through-powershell-for-a-server\/","title":{"rendered":"Getting Drive Space Through PowerShell for a Server"},"content":{"rendered":"<pre class=\"lang:PowerShell\" Title=\"Get All Volume Free Space\">Get-WmiObject -ComputerName \"ServerName\" Win32_Volume | select Name,FileSystem,FreeSpace,BlockSize,Capacity | % {$_.BlockSize=(($_.FreeSpace)\/($_.Capacity))*100;$_.FreeSpace=($_.FreeSpace\/1GB);$_.Capacity=($_.Capacity\/1GB);$_} | Sort-Object Name | Format-Table Name,@{n='Free,GB';e={'{0:N2}'-f $_.FreeSpace}},@{n='Free,%';e={'{0:N2}'-f $_.BlockSize}},@{n='Capacity,GB';e={'{0:N3}' -f $_.Capacity}},@{n='FS';e={$_.FileSystem}} -AutoSize<\/pre>\n\n\n\n<p>This cmdlet will list all your mounted volumes, their size, the file system used, and the available free space. You can modify the code to have a where-object statement: <em>? {$_.Name -like &#8220;*logs*&#8221;}.<\/em> This helps if you have an exchange server that has multiple database volumes for DBs and logs and need to quickly find which volume is the culprit.<\/p>\n\n\n\n<p>I also use a lot of these scripts to gather the information quickly so that I can post the output into my incidents that I am working. It&#8217;s good to have these handy. <\/p>\n\n\n\n<p><strong>Here is an example output:<\/strong><\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>Name<\/td><td>Free, GB<\/td><td>Free, %<\/td><td>Capacity, GB<\/td><td>FS<\/td><\/tr><tr><td>C:\\ExchangeDB\\DAG2DB01\\DB\\  <\/td><td>456.80<\/td><td>37.45<\/td><td>1,219.873<\/td><td>NTFS<\/td><\/tr><tr><td>C:\\ExchangeDB\\DAG2DB01\\LOG\\ <\/td><td>39.49<\/td><td>99.03<\/td><td>39.873<\/td><td>NTFS<\/td><\/tr><\/tbody><\/table>\n","protected":false},"excerpt":{"rendered":"<p>This cmdlet will list all your mounted volumes, their size, the file system used, and the available free space. You can modify<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/itblog.ldlnet.net\/index.php\/2019\/01\/03\/getting-drive-space-through-powershell-for-a-server\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":147,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[11,9,10,8,13,12],"class_list":["post-15","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange","category-powershell","tag-disk","tag-exchange","tag-free-space","tag-powershell","tag-script","tag-volumes","odd"],"_links":{"self":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":3,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":164,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions\/164"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media\/147"}],"wp:attachment":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}