title: PowerShell Get-DiskUsage CmdLet: how to list from a different drive/directory?
body: <p>I'm a relative newbie on PowerShell, wanted to know a bit more about functions, CmdLet and human readable values. Usually for learning new things, looking at what others do works well.</p>
  
  <p>So I went looking and bumped into the source for a <a href="http://poshcode.org/3905" rel="nofollow">Get-DiskUsage</a> CmdLet.</p>
  
  <p>I can . source this into PowerShell, then call the function.</p>
  
  <p>Somehow, it always uses the current directory for getting the results no matter how I call it.</p>
  
  <p>What am I missing that it will not take the given -Path parameter?</p>
  
  <pre><code>PS D:\bin&gt; . .\DiskUsage.ps1
  PS D:\bin&gt; Get-DiskUsage -Path D:\ -h
  
  Size Folder
  ---- ------
  405M
  
  
  PS D:\bin&gt; Get-DiskUsage -Path C:\ -h
  
  Size Folder
  ---- ------
  405M
  
  
  PS D:\bin&gt; C:
  PS C:\&gt; Get-DiskUsage -Path C:\ -h
  
  Size Folder
  ---- ------
   18G
  
  
  PS C:\&gt;
  </code></pre>
  
  <p>The script output is not right, as this is what the <a href="http://technet.microsoft.com/en-us/sysinternals" rel="nofollow">SysInternals</a> DiskUsage tool <a href="http://technet.microsoft.com/en-us/sysinternals/bb896651.aspx" rel="nofollow">du</a> shows:</p>
  
  <pre><code>D:\bin&gt;du C:\
  
  Du v1.4 - report directory disk usage
  Copyright (C) 2005-2011 Mark Russinovich
  Sysinternals - www.sysinternals.com
  
  Files:        93367
  Directories:  22541
  Size:         21.817.875.778 bytes
  Size on disk: 22.127.992.832 bytes
  
  
  D:\bin&gt;du D:\
  
  Du v1.4 - report directory disk usage
  Copyright (C) 2005-2011 Mark Russinovich
  Sysinternals - www.sysinternals.com
  
  Files:        132832
  Directories:  15125
  Size:         130.137.231.457 bytes
  Size on disk: 54.992.396.288 bytes
  
  
  D:\bin&gt;du D:\bin
  
  Du v1.4 - report directory disk usage
  Copyright (C) 2005-2011 Mark Russinovich
  Sysinternals - www.sysinternals.com
  
  Files:        3118
  Directories:  222
  Size:         424.866.944 bytes
  Size on disk: 288.858.112 bytes
  </code></pre>