114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/inspec/resources/filesystem.rb', line 114
def info(partition)
cmd = inspec.command " $disk = Get-WmiObject Win32_LogicalDisk -Filter \"DeviceID='\#{partition}'\"\n $disk.Size = $disk.Size / 1KB\n $disk.FreeSpace = $disk.FreeSpace / 1KB\n $disk | select -property DeviceID,Size,FileSystem,FreeSpace | ConvertTo-Json\n EOF\n\n raise Inspec::Exceptions::ResourceSkipped, \"Unable to get available space for partition \#{partition}\" if cmd.stdout == \"\" || cmd.exit_status.to_i != 0\n\n begin\n fs = JSON.parse(cmd.stdout)\n rescue JSON::ParserError => e\n raise Inspec::Exceptions::ResourceFailed,\n \"Failed to parse JSON from Powershell. \" \\\n \"Error: \#{e}\"\n end\n {\n name: fs[\"DeviceID\"],\n size_kb: fs[\"Size\"].to_i,\n free_kb: fs[\"FreeSpace\"].to_i,\n type: fs[\"FileSystem\"],\n }\nend\n".gsub(/^\s*/, "")
|