Get Network share information in a powershell oneliner

Hey All

yeah, 100th post

Quick one but a good one.  This essentially a one liner to get the available GB in a drive share.

$ComputerShare = "<\\Server\ShareName>"

(new-object -com scripting.fileSystemObject).getdrive($ComputerShare).availablespace / 1GB

There is many other attributes you could pull instead of just available space although the highlighted are most useful of the entries.


  • Path
  • DriveLetter
  • ShareName
  • DriveType
  • RootFolder
  • AvailableSpace
  • FreeSpace
  • TotalSize
  • VolumeName
  • FileSystem
  • SerialNumber
  • IsReady
And you can format the output to allow only round numbers (yes this is one line)

[system.Math]::Round((new-object -com scripting.fileSystemObject).getdrive($ComputerShare).availablespace / 1GB, 0)

I hope you enjoy

C

Comments