0

I'm using Get-Diskfree function described here: https://binarynature.blogspot.com/2010/04/powershell-version-of-df-command.html

I want to sum all values from Used column, but as I try to call out a specific properties of Get-Diskfree output, I've got nothing, null.

Function is showing output like this:

FileSystem : NTFS
Type       : Local Fixed Disk
Volume     : C:
Available  : somevalue
Computer   : somevalue
Used       : somevalue
Size       : somevalue

FileSystem : NTFS
Type       : Local Fixed Disk
Volume     : D:
Available  : somevalue
Computer   : somevalue
Used       : somevalue
Size       : somevalue

I want to be able to call out Used property by parsing Get-Diskfree output into variable like this:

function {...}
$variable = Get-Diskfree
$variable.Used

Last line don't give me any output, in comparision to for example:

$variable = get-service
$variable.Name
long list of service names

Is function (or functions overall) designed in a way, that this method is impossible to use?

I plan to sum them by using more less the method I used in this script Powershell: System.Object[] in export-csv file

What I want to achieve is to sum Used column for first 8 disks (there are 20 of them on VM), export an output as csv and send an html email based on that csv file.

6
  • $variable = Get-Diskfree;$variable.Used worked for me Commented Nov 29, 2018 at 16:40
  • To get the first 8 objects from Get-Diskfree, use $variable = Get-Diskfree | Select-Object -First 8. To get the sum of the Used column, this should do it: $totalUsed = $variable | Measure-Object Used -sum | Select-Object -ExpandProperty Sum Commented Nov 29, 2018 at 17:08
  • does the code @ line 55-57 work when you call it against your VM? just that code, not any other part - this is for diagnostic testing. [grin] Commented Nov 29, 2018 at 17:21
  • @Lee_Dailey yes it works when run locally on vm. Commented Nov 30, 2018 at 12:22
  • @ArcSet Okay my bad, it actually works when I run it locally on this vm. Doesn't work when connected to Azure supscription on my local pc. Commented Nov 30, 2018 at 12:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.