BikeBoy2020
IS-IT--Management
I am trying to modify existing script to list all the drives/luns, including mounts. It outputs ok, BUT... Size is always in 0.000 and so Percent = Infinity.
If I use win32_logicaldisk I get good result, but I need mounts as well, so I need win32_volume.
Any ideas?
param ( [string]$computer = "MyServer" , [switch]$all)
# Formatting
$size = @{ l = "Size (MB)"; e = { $_.size/1mb}; f = "{0:N}"}
$free = @{ l = "free (MB)"; e = { $_.freespace/1mb}; f = "{0:N}"}
$perc = @{ l = "percent"; e = { 100.0 * ([double]$_.freespace/[double]$_.size)}; f="{0:f}" }
$name = @{ e = "name"; f = "{0,-20}" }
$fields = $name,$size,$free,$perc
$filter = "DriveType = '3'"
if ( $all ) { $filter = "" }
get-wmiobject -class win32_volume -filter $filter -comp $computer |
format-table $fields -auto
If I use win32_logicaldisk I get good result, but I need mounts as well, so I need win32_volume.
Any ideas?
param ( [string]$computer = "MyServer" , [switch]$all)
# Formatting
$size = @{ l = "Size (MB)"; e = { $_.size/1mb}; f = "{0:N}"}
$free = @{ l = "free (MB)"; e = { $_.freespace/1mb}; f = "{0:N}"}
$perc = @{ l = "percent"; e = { 100.0 * ([double]$_.freespace/[double]$_.size)}; f="{0:f}" }
$name = @{ e = "name"; f = "{0,-20}" }
$fields = $name,$size,$free,$perc
$filter = "DriveType = '3'"
if ( $all ) { $filter = "" }
get-wmiobject -class win32_volume -filter $filter -comp $computer |
format-table $fields -auto