James is right, this is not a particularly scripting question. I would categorize it as an NTFS file system question (I'm assuming this is on an NTFS formatted volume).
At any rate, Powershell cmdlets and tools may not show you everything that's on disk. There are several reasons for that. Mainly 2 groups of reasons:
1) PS is .NET based, it runs and uses .NET objects and classes in the background. Many legacy apps and systems use COM and older technologies that .NET may not fully work with
2) NTFS file system issues, details, and exceptions
A typical NTFS volume will have properties like:
Max Component Length : 255
File System Name : NTFS
Is ReadWrite
Supports Case-sensitive filenames
Preserves Case of filenames
Supports Unicode in filenames
Preserves & Enforces ACL's
Supports file-based Compression
Supports Disk Quotas
Supports Sparse files
Supports Reparse Points
Supports Object Identifiers
Supports Encrypted File System
Supports Named Streams
Supports Transactions
Supports Hard Links
Supports Extended Attributes
Supports Open By FileID
Supports USN Journal
For example, take NTFS junction points (AKA directory hard link). Its simply a pointer to a directory/volume/partition. This will show up in the system GUI tools, command line tools, and via PS comdlets. But each set of tools will handle it differently depending
on its capabilities.
$MountPoint = "C:\mount"
$ISO = 'Y:\Install\ISO\Server2012R2\WS2012_r2_with_update_x64_dvd_4065220.iso'
$Image = Mount-DiskImage -ImagePath $ISO -NoDriveLetter -PassThru
$Drive = Get-WmiObject win32_volume -Filter "Label = '$($Vol.FileSystemLabel)'" -ErrorAction Stop
if (-not (Test-Path -Path $MountPoint)) { New-Item -Path $MountPoint -ItemType Directory -Force }
$Drive.AddMountPoint($MountPoint)
$Drive.Put()
Get-Volume | FT -AutoSize
This short script illustrates creating an NTFS junction point via PS. In other words, it mounts an ISO file as c:\mount folder instead of mounting it as a drive letter as you might usually do. This has the practical benefit of overcoming the 26 drive letter
limitation for example. This could easily mount a VHD(x) disk from a local or remote system as well. As a matter of fact Failover Clustering CSVs (Cluster Shared Volumes) use the same exact technique to mount shared volumes on Hyper-V hosts - typically under
c:\ClusterStorage folder. So you could have a c: drive that's 50GB with one ore more mount points that are several TBs each. This may lead to inconsistent results when getting drive space total/free information depending on what tool/method you use to monitor
disk space.
The icon in this examples, gives a clue to the untrained eye that this is not a typical folder. But icons can be changed, and are different by default on different operating systems (this test is on Windows 8.1)
Now, to show you how different tools will work differently with NTFS features like junction points, try to delete that mount point we just created with PS, like:
Remove-Item c:\mount -Force
That will fail.
However you can delete c:\mount in Windows Explorer. That will not delete the ISO file of course, it will simply remove the mount point.
Going back to Powershell, Get-Volume will STILL show this phantom volume, even in a new PS session. It only goes away after a reboot..
Long story short, this is mainly an NTFS question. The vendor documentation may be most helpful here. In most cases GUI tools like Windows Explorer will provide more functionality than Powershell.