title: Batch Script check folder Size with powershell command
body: <p>I am very new to batch scripting and there is one part that I miss on my script.</p>
  
  <p>Basically I want to check if a specific folder(with sub-folders) is in between a specific size range. The normal size of the folder is around 200GB, so I read that you can not check the size in batch commands since cmd only works up to 2GB. So I would need to use a power-shell command in the batch script. 
  So in the batch script I would check the folder size >190GB &amp; &lt;250GB with a power-shell command and the command would give back a return value if it is in the wanted range or not.</p>
  
  <p>I found the following command:</p>
  
  <pre><code>powershell -ExecutionPolicy Unrestricted -c "{0:N2} MB" -f ((Get-ChildItem C:\patch\to\file -Recurse | Measure-Object -Property Length -Sum -ErrorAction Stop).Sum / 1MB)
  </code></pre>
  
  <p>If you just type in the code in the Powershell you get a return value with the MB of the specific folder but I don't know how to go from there.</p>