I am trying to determine the free and total disk space on fixed drives. I found the relevance on the Bigfix site but some of the machines are reporting the data, some are reporting “none” and others “Singular expression refers to nonexistent object”
Here is the relevance…
Free space
(name of it & " - " & (free space of it / 1000 / 1000) as string & " MB") of drives whose (type of it = “DRIVE_FIXED”)
Total space
(name of it & " - " & (total space of it / 1000 / 1000) as string & " MB") of drives whose (type of it = “DRIVE_FIXED”)
Can anyone explain why it will work for some and not others?
It is likely that some drives are having problems reporting their free space or total space. For example, a drive of type CDROM cannot report free/total space if there is no media inserted.
So we can try making sure that the attributes exist:
Free space
(name of it & " - " & (free space of it / 1000 / 1000) as string & " MB") of drives whose (type of it = “DRIVE_FIXED” and exists free space of it)
Total space
(name of it & " - " & (total space of it / 1000 / 1000) as string & " MB") of drives whose (type of it = “DRIVE_FIXED” and exists total space of it)
This might give some insight as to what piece is failing:
((if (exists name of it) then (name of it) else (“Drive has no Name”)) & " - " & (if (exists free space of it) then ((free space of it /1024/1024)as string & " MB") else (“Drive has no Free Space”)) & " - " & (if (exists type of it) then (type of it as string) else (“Drive has no Type”))) of drives
We can even take it one step further and make sure at least one drive exists:
if (exists drive) then (((if (exists name of it) then (name of it) else (“Drive has no Name”)) & " - " & (if (exists free space of it) then ((free space of it /1024/1024)as string & " MB") else (“Drive has no Free Space”)) & " - " & (if (exists type of it) then (type of it as string) else (“Drive has no Type”))) of drives ) else (“No drives found”)
(name of it & " - " & (free space of it / 1000 / 1000) as string & " MB free of " & (total space of it / 1000 / 1000) as string & " MB total") of drives whose (type of it = “DRIVE_FIXED”)
I got this from the following web page on the BigFix Support site. Scroll to the File section.