Converting the FileSystemObject's AvailableSpace Property

Definition: The amount of space available on the specified drive or share.

AvailableSpace

Available drive space is just one of the properties you can retrieve from the DriveInfo .NET Framework object. Use the New-Object cmdlet to retrieve a reference to the object, passing the drive letter as the argument. Once you have a reference to the DriveInfo object, you can check the AvailableFreeSpace property.

$d = New-Object -typename System.IO.DriveInfo -argumentlist "C:"
$d.AvailableFreeSpace

Note that this does not work with network shares (i.e., \\atl-fs-01\scripts), it works only with mapped drives letters.

See conversions of other FileSystemObject methods and properties. Return to the VBScript to Windows PowerShell home page