{"id":519,"date":"2009-11-23T11:17:08","date_gmt":"2009-11-23T16:17:08","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=519"},"modified":"2014-10-27T08:38:45","modified_gmt":"2014-10-27T12:38:45","slug":"get-disk-quota","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/","title":{"rendered":"Get Disk Quota"},"content":{"rendered":"<p>During a recent class I was teaching, a student asked about a way to get disk quota reports from Windows file servers.\u00a0 I knew there was a WMI class, Win32_DiskQuota, and had some old VBScript files. However, they were pretty basic and not as robust as I would have liked. So I worked up PowerShell v2 function called Get-DiskQuota.<!--more--><\/p>\n<p>The function includes parameter help, as so almost all of my v2 scripts, so that\u00a0 you can get help and examples.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/captured_Image1.png1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;\" title=\"captured_Image.png\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/captured_Image1.png_thumb1.png\" alt=\"captured_Image.png\" width=\"480\" height=\"252\" border=\"0\" \/><\/a><\/p>\n<p>The function takes a computername as a parameter, although it defaults to the local computer. You can retrieve quota information for all volumes and users on the server, or only for a particular volume and\/or user. Because the function uses WMI, it also supports PSCredentials. Here\u2019s a sample using an alias, gdq, for the Get-DiskQuota function.<\/p>\n<p><span style=\"font-family: 'Lucida Console'; color: #0000ff;\">PS C:\\&gt; gdq -Computername jdhit-dc01 -Volume e: -credential $jdhit <\/span><\/p>\n<p><span style=\"font-family: 'Lucida Console'; color: #0000ff;\">Volume\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : E:<br \/>\nComputername\u00a0\u00a0\u00a0\u00a0 : JDHIT-DC01<br \/>\nUsername\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : jdhitsolutions\\jhicks<br \/>\nUsedSpaceMB\u00a0\u00a0\u00a0\u00a0\u00a0 : 73.228515625<br \/>\nPercentUsed\u00a0\u00a0\u00a0\u00a0\u00a0 : 1.43 %<br \/>\nLimitGB\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : 5<br \/>\nLimitRemainingGB : 4.93<br \/>\nWarningGB\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : 3<br \/>\nOverWarning\u00a0\u00a0\u00a0\u00a0\u00a0 : False<br \/>\nOverLimit\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : False<\/span><\/p>\n<p>The PSCredential must be passed as an object. I created the $jdhit object earlier with Get-Credential.<\/p>\n<p>Here\u2019s the code for you to look at and then I\u2019ll go over a few key steps.<\/p>\n<pre class=\"lang:ps decode:true \">Function Get-DiskQuota {\r\n#Requires -version 2.0\r\n\r\n&lt;#\r\n.Synopsis\r\n    Retrieve quota usage information for all users or a user from all volumes on a server or a single volume.\r\n.Description\r\n    This function connects to the specified computer, default is the localhost, and returns quota\r\n    usage information. Quota information will NOT be returned for the Domain Admins group or the \r\n    Administrator account. It will also exclude entries without a quota limit. Quota information for\r\n    all volumes is returned by default. Otherwise you can filter by volume, by user or by volume\r\n    and user. The Domain parameter is used to more accurately define the user account. If you want\r\n    to filter by domain alone, then run the function without any user filtering and pipe it to \r\n    Where-Object where you can filter by the domain name.\r\n    \r\n    This function uses WMI so you must have RPC connectivity and appropriate credentials. You do\r\n    not need PowerShell installed on the remote computer.\r\n    \r\n.Parameter Computername\r\n    The name of the computer to query.\r\n.Parameter Volume\r\n    Return quota information for a specific volume on the remote server such as E:.\r\n.Parameter Username\r\n    Return quota information for a specific user. Use the SAMAccountname.\r\n.Parameter Domain\r\n    The NETBIOS domain name of the user account you are querying. The default is the domain of the\r\n    current user running the function.  \r\n.Parameter Credential\r\n    A PSCredential object to use for alternate credential authentication. This must be a previously\r\n    created object.\r\n\r\n.Example\r\n    PS C:\\&gt; get-diskquota server02\r\n    \r\n    Get quota usage for all users on all volumes on SERVER02.\r\n.Example\r\n    PS C:\\&gt; get-diskquota server01 -volume F: -cred $admin\r\n    \r\n    In this example, quota information for all users on volume F: is returned. The query is made\r\n    using alternate credentials, previously saved as $admin.\r\n\r\n.Example\r\n    PS C:\\&gt; get-diskquota \"File01\",\"File02\" -user jfrost -domain MyCompany\r\n    \r\n    Query servers File01 and File02 for all quota entries for user mycompany\\jfrost on all volumes.\r\n    \r\n.Example\r\n    PS C:\\&gt; get-content servers.txt | get-diskquota -user Jhicks | Export-csv jhicks-quota.csv\r\n    \r\n    This example will take every server name in servers.txt and pipe it to the Get-Diskquota function\r\n    which searches all volumes for the jhicks user account. The quota usage information is then piped\r\n    to a CSV file using Export-CSV.\r\n    \r\n.Inputs\r\n    Accepts strings as pipelined input\r\n.Outputs\r\n    A custom object with quota entry information  \r\n\r\n.Link\r\nhttp:\/\/jdhitsolutions.com\/blog\/2009\/11\/get-disk-quota\/\r\n           \r\n.Link\r\n   Get-WmiObject\r\n         \r\n.Notes\r\n NAME:      Get-DiskQuota\r\n VERSION:   1.1\r\n AUTHOR:    Jeffery Hicks\r\n LASTEDIT:  12\/8\/2009\r\n\r\n\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\n\r\nParam (\r\n    [Parameter(\r\n    ValueFromPipeline=$True, Position=0, Mandatory=$False,\r\n    HelpMessage=\"The computername to query\")] \r\n    [string[]]$Computername=$env:computername,\r\n    \r\n    [Parameter(\r\n    ValueFromPipeline=$False,Mandatory=$False,\r\n    HelpMessage=\"The volume name on the remote server. Use a value like E:.\")] \r\n    [string]$Volume,\r\n    \r\n    [Parameter(\r\n    ValueFromPipeline=$False,Mandatory=$False,\r\n    HelpMessage=\"The samAccountname of a user such as JDOE\")] \r\n    [string]$Username,\r\n    \r\n    [Parameter(\r\n    ValueFromPipeline=$False,Mandatory=$False,\r\n    HelpMessage=\"The domain name of the queried user such as MyCompany\")] \r\n    [string]$Domain=$env:Userdomain,\r\n    \r\n    [Parameter(\r\n    ValueFromPipeline=$False,\r\n    Mandatory=$False,\r\n    HelpMessage=\"A previously created PSCredential object.\")] \r\n    [Parameter(ParameterSetName=\"Set2\")] \r\n    [management.automation.pscredential]$credential\r\n     \r\n    ) #end Parameter declaration\r\n\r\n\r\n    BEGIN {\r\n        Write-Verbose \"Starting function\"\r\n        \r\n        if ($Username) { Write-Verbose \"Looking for entries for $domain\\$username\"}\r\n               \r\n          #only retrieve quota entries that are limited\r\n          $query=\"Select * from win32_diskquota where limit &lt; 18446744073709551615\"\r\n        \r\n        if ($Volume -AND $Username) {\r\n            Write-Verbose \"Building volume and username query\"\r\n            $query=$query + \" AND QuotaVolume=\"\"Win32_LogicalDisk.DeviceID='$volume'\"\" AND User =\"\"Win32_Account.Domain='$domain',Name='$Username'\"\"\"\r\n        }\r\n        elseif ($Volume) {\r\n            Write-Verbose \"Building volume filter query\"\r\n             $query=$query + \" AND QuotaVolume=\"\"Win32_LogicalDisk.DeviceID='$volume'\"\"\"\r\n        }\r\n        elseif ($Username) {\r\n            Write-Verbose \"Building username filter query\"\r\n            $query=$query + \" AND User =\"\"Win32_Account.Domain='$domain',Name='$Username'\"\"\"\r\n        }\r\n        else {\r\n            Write-Verbose \"Getting all quota entries\"\r\n        }\r\n        \r\n        Write-Verbose \"Query = $query\"\r\n    } #end BEGIN\r\n\r\n    PROCESS {\r\n    \r\n        \r\n        $Computername | foreach {    \r\n        \r\n        \r\n            #define an error handling trap in the same scope\r\n            Trap {\r\n                Write-Warning \"There was an exception retrieving quota information from $computer)\"\r\n                Write-Warning $_.Exception.Message\r\n                #bail out\r\n                Return\r\n            }\r\n           \r\n            $computer=$_.ToUpper()\r\n            Write-Verbose \"Querying $computer\"\r\n            \r\n            if ($credential) {\r\n                $quotas=get-wmiobject -query $query -computer $computer -Credential $credential -ea Stop\r\n            }\r\n            else {\r\n                $quotas=get-wmiobject -query $query -computer $computer  -ea Stop\r\n               }\r\n            \r\n            #get quota entries and filter off local user accounts, administrator and domain admins\r\n            $entries = $quotas | where {$_.user -notmatch \"$computer|Administrator|Domain Admins\"}\r\n            \r\n            if ($entries) {\r\n                Write-Verbose \"Found $($entries.count) entries\"\r\n                foreach ($entry in $entries) {\r\n                  Write-Verbose \"Processing entry\"\r\n                  #remove quotes from user property and split the user entry at the comma\r\n                  #assuming no commas in the domain or username\r\n            \r\n                  $replaced=($entry.user).Replace('\"',\"\")\r\n                  Write-Verbose \"`$replace = $replaced\"\r\n            \r\n                  $userdata=$replaced.split(\",\")\r\n                      \r\n                  #item 0 will be the domain and item 1 will be the user. Each item needs\r\n                  #to be further split.  The domain and username values should be the same as any\r\n                  #values passed as paramters.  I'll override the default domain parameter value. \r\n                  #Otherwise, if it isn't specified and the admin running the script isn't in the domain\r\n                  #you'll get the wrong domain listed.\r\n                  $domain=$userdata[0].Split(\"=\")[1]\r\n                  $username=$userdata[1].Split(\"=\")[1]\r\n                   \r\n                  Write-Verbose \"Parsed out $domain and $username\"\r\n            \r\n                  #parse QuotaVolume and strip off quotes\r\n                  $Volume=($entry.quotavolume.split(\"=\")[1]).Replace('\"',\"\")    \r\n                  $Volume=$Volume.ToUpper()\r\n                  Write-Verbose \"`$volume=$volume\"\r\n                \r\n                  #calculate % of quota used\r\n                  $percentUsed=\"{0:P2}\" -f ([double]$entry.DiskSpaceUsed\/[double]$entry.Limit)\r\n                  Write-Verbose \"`$percentused = $percentused\"\r\n                  \r\n                  #calculate limit remaining space\r\n                  [double]$limitRemaining=\"{0:N2}\" -f (([double]$entry.limit - [double]$entry.DiskSpaceUsed)\/1GB)\r\n                  Write-Verbose \"`$limitRemaining = $limitRemaining\"\r\n                  \r\n                  #is user over the warning limit?\r\n                  if ($entry.diskspaceused -gt $entry.WarningLimit) {\r\n                \t$Warning=$True\r\n                   }\r\n                  else {\r\n                \t$Warning=$False\r\n                  }\r\n                  Write-Verbose \"`$Warning=$warning\"\r\n                  \r\n                 #is user over the hard limit?\r\n                  if ($entry.diskspaceused -gt $entry.Limit) {\r\n                \t$OverLimit=$True\r\n                   }\r\n                  else {\r\n                \t$OverLimit=$False\r\n                  }\r\n                  Write-Verbose \"`$overlimit=$overlimit\"\r\n                  Write-Verbose \"Creating blank object\"\r\n            \r\n                  #create a blank object\r\n                  $obj = New-Object PSObject\r\n                  Write-Verbose \"Adding properties to the object\"\r\n                \r\n                  #add some properties to the object\r\n                  $obj | Add-Member -membertype NoteProperty -Name Volume -Value $Volume\r\n                  $obj | Add-Member -membertype NoteProperty -Name Computername -Value $computer\r\n                  $obj | Add-Member -membertype NoteProperty -Name Username -Value \"$domain\\$username\"       \r\n                  $obj | Add-Member -membertype NoteProperty -Name UsedSpaceMB -Value (($entry.DiskSpaceUsed\/1MB) -as [double])\r\n                  $obj | Add-Member -membertype NoteProperty -Name PercentUsed -Value $percentUsed\r\n                  $obj | Add-Member -membertype NoteProperty -Name LimitGB -Value (($entry.Limit\/1GB) -as [int])\r\n                  $obj | Add-Member -membertype NoteProperty -Name LimitRemainingGB -Value $limitRemaining\r\n                  $obj | Add-Member -membertype NoteProperty -Name WarningGB -Value (($entry.WarningLimit\/1GB) -as [int])\r\n                  $obj | Add-Member -membertype NoteProperty -Name OverWarning -Value $Warning\r\n                  $obj | Add-Member -membertype NoteProperty -Name OverLimit -Value $OverLimit\r\n                \r\n                  #write object to the pipeline\r\n                  Write-Verbose \"Writing the object to the pipeline\"\r\n                  write $obj\r\n                \r\n                } #end ForEach \r\n                \r\n            } #end if\r\n            \r\n            else {\r\n              Write-Warning \"No quota entries found that match your query on $computer\"\r\n              Write-Warning $query\r\n            }\r\n        } #end ForEach Computername\r\n    } #end PROCESS\r\n\r\n    END {\r\n        Write-Verbose \"Exiting function\"\r\n    } #end END\r\n    \r\n} #end Function\r\n\r\nSet-Alias gdq    Get-DiskQuota\r\n\r\n#end Script\r\n# help gdq\r\n<\/pre>\n<p>The function only returns quota information for volumes which are configured with limits.<\/p>\n<p><span style=\"font-family: 'Lucida Console'; color: #0000ff;\">$query=\"Select * from win32_diskquota where limit &lt; 18446744073709551615\"<\/span><\/p>\n<p>The function builds a query based on the parameter values you pass. The filtering for user account is a little tricky because WMI retrieves an associated Win32_Account object<\/p>\n<p><span style=\"font-family: 'Lucida Console'; color: #0000ff;\">$query=$query + \" AND User =\"\"Win32_Account.Domain='$domain',Name='$Username'\"\"\"<\/span><\/p>\n<p>The function defaults to the current domain, but you can specify\u00a0 a domain. The Domain parameter is used to more accurately define the user account. If you want to filter by domain alone, then run the function without any user filtering and pipe it to Where-Object where you can filter by the domain name.<\/p>\n<p>All of the query string building in accomplished in the BEGIN script block. The query is executed in the PROCESS script block. You can pipe a collection of server names to the function.<\/p>\n<p><span style=\"font-family: 'Lucida Console'; color: #0000ff;\">PS C:\\&gt; get-content servers.txt | get-diskquota -user Jhicks | Export-csv jhicks-quota.csv<\/span><\/p>\n<p>The function takes the resulting WMI information, parses and massages and writes a custom object to the pipeline. The END script block isn\u2019t used, unless you include the \u2013Verbose common parameter. The function will display progress information which can be helpful when debugging or troubleshooting. I encourage you to use code like this in your PowerShell v2 scripts and function.<\/p>\n<p>Thanks to Wes Stahler, Aubrey Moren and Arnaud Petitjean for kicking my code around but of course any problems or bugs are mine and I hope you\u2019ll let me know.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/Get-DiskQuota-v2.txt\">Download Get-DiskQuota<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>During a recent class I was teaching, a student asked about a way to get disk quota reports from Windows file servers.\u00a0 I knew there was a WMI class, Win32_DiskQuota, and had some old VBScript files. However, they were pretty basic and not as robust as I would have liked. So I worked up PowerShell&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[75,8,135,19],"tags":[97,32,534,142,547],"class_list":["post-519","post","type-post","status-publish","format-standard","hentry","category-powershell-v2-0","category-scripting","category-windows-server","category-wmi","tag-filesystem","tag-functions","tag-powershell","tag-quotas","tag-wmi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get Disk Quota &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Disk Quota &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"During a recent class I was teaching, a student asked about a way to get disk quota reports from Windows file servers.\u00a0 I knew there was a WMI class, Win32_DiskQuota, and had some old VBScript files. However, they were pretty basic and not as robust as I would have liked. So I worked up PowerShell...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2009-11-23T16:17:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-10-27T12:38:45+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/captured_Image1.png_thumb1.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Get Disk Quota\",\"datePublished\":\"2009-11-23T16:17:08+00:00\",\"dateModified\":\"2014-10-27T12:38:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/\"},\"wordCount\":456,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/11\\\/captured_Image1.png_thumb1.png\",\"keywords\":[\"FileSystem\",\"functions\",\"PowerShell\",\"Quotas\",\"WMI\"],\"articleSection\":[\"PowerShell v2.0\",\"Scripting\",\"Windows Server\",\"WMI\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/\",\"name\":\"Get Disk Quota &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/11\\\/captured_Image1.png_thumb1.png\",\"datePublished\":\"2009-11-23T16:17:08+00:00\",\"dateModified\":\"2014-10-27T12:38:45+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/11\\\/captured_Image1.png_thumb1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2009\\\/11\\\/captured_Image1.png_thumb1.png\",\"width\":\"480\",\"height\":\"252\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/519\\\/get-disk-quota\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell v2.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-v2-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Disk Quota\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get Disk Quota &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/","og_locale":"en_US","og_type":"article","og_title":"Get Disk Quota &#8226; The Lonely Administrator","og_description":"During a recent class I was teaching, a student asked about a way to get disk quota reports from Windows file servers.\u00a0 I knew there was a WMI class, Win32_DiskQuota, and had some old VBScript files. However, they were pretty basic and not as robust as I would have liked. So I worked up PowerShell...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/","og_site_name":"The Lonely Administrator","article_published_time":"2009-11-23T16:17:08+00:00","article_modified_time":"2014-10-27T12:38:45+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/captured_Image1.png_thumb1.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Get Disk Quota","datePublished":"2009-11-23T16:17:08+00:00","dateModified":"2014-10-27T12:38:45+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/"},"wordCount":456,"commentCount":4,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/captured_Image1.png_thumb1.png","keywords":["FileSystem","functions","PowerShell","Quotas","WMI"],"articleSection":["PowerShell v2.0","Scripting","Windows Server","WMI"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/","name":"Get Disk Quota &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/captured_Image1.png_thumb1.png","datePublished":"2009-11-23T16:17:08+00:00","dateModified":"2014-10-27T12:38:45+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/captured_Image1.png_thumb1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/11\/captured_Image1.png_thumb1.png","width":"480","height":"252"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/519\/get-disk-quota\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell v2.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},{"@type":"ListItem","position":2,"name":"Get Disk Quota"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":6082,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6082\/searching-for-a-cim-wmi-class-with-powershell\/","url_meta":{"origin":519,"position":0},"title":"Searching for a CIM\/WMI Class with PowerShell","author":"Jeffery Hicks","date":"September 18, 2018","format":false,"excerpt":"I got a question on Twitter about an older function I has posted to get antivirus information via WMI. The function continues to work fine with Windows 10, although there's always room for improvement. However, the question was that the function did not seem to work when querying a server\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/image_thumb.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/image_thumb.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/image_thumb.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/09\/image_thumb.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5187,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5187\/get-antivirus-product-status-with-powershell\/","url_meta":{"origin":519,"position":1},"title":"Get Antivirus Product Status with PowerShell","author":"Jeffery Hicks","date":"July 22, 2016","format":false,"excerpt":"I expect that most of you with enterprise-wide antivirus installations probably have vendor tools for managing all of your clients. If so, don't go away just yet. Even though I'm going to demonstrate how to get antivirus product status with PowerShell, the scripting techniques might still be useful. Or you\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"antivirus information from WMI","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/07\/image_thumb-7.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/07\/image_thumb-7.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/07\/image_thumb-7.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2935,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2935\/get-ciminstance-from-powershell-2-0\/","url_meta":{"origin":519,"position":2},"title":"Get CIMInstance from PowerShell 2.0","author":"Jeffery Hicks","date":"April 10, 2013","format":false,"excerpt":"I love the new CIM cmdlets in PowerShell 3.0. Querying WMI is a little faster because the CIM cmdlets query WMI using the WSMAN protocol instead of DCOM. The catch is that remote computers must be running PowerShell 3 which includes the latest version of the WSMAN protocol and the\u2026","rel":"","context":"In &quot;Powershell 3.0&quot;","block_context":{"text":"Powershell 3.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},"img":{"alt_text":"get-ciminstance-error","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/04\/get-ciminstance-error-300x145.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":8541,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8541\/getting-ciminstance-by-path\/","url_meta":{"origin":519,"position":3},"title":"Getting CIMInstance by Path","author":"Jeffery Hicks","date":"August 20, 2021","format":false,"excerpt":"I am a member of the PowerShell Cmdlet Working Group. We've been looking into this issue and it is an intriguing one. Enough so that I spent some time looking into it and writing up some test code. If you work with WMI\/CIM this might be of interest to you.\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/add-ciminstancepath2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/add-ciminstancepath2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/add-ciminstancepath2.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/08\/add-ciminstancepath2.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":654,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/654\/new-wmi-object\/","url_meta":{"origin":519,"position":4},"title":"New WMI Object","author":"Jeffery Hicks","date":"May 17, 2010","format":false,"excerpt":"I have one more variation on my recent theme of working with WMI objects. I wanted to come up with something flexible and re-usable where you could specify a WMI class and some properties and get a custom object with all the classes combined. My solution is a function called\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3497,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3497\/resolving-sids-with-wmi-wsman-and-powershell\/","url_meta":{"origin":519,"position":5},"title":"Resolving SIDs with WMI, WSMAN and PowerShell","author":"Jeffery Hicks","date":"October 15, 2013","format":false,"excerpt":"In the world of Windows, an account SID can be a very enigmatic thing. Who is S-1-5-21-2250542124-3280448597-2353175939-1019? Fortunately, many applications, such as the event log viewer resolve the SID to an account name. The downside, is that when you are accessing that same type of information from PowerShell, you end\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"win32_sid-fail","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/10\/win32_sid-fail-1024x330.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/10\/win32_sid-fail-1024x330.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/10\/win32_sid-fail-1024x330.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=519"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/519\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}