diff --git a/CHANGELOG.md b/CHANGELOG.md index f36ccb0..c105116 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,4 +12,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Fix option ```Use LastHWScan``` that no longer worked. +- Fix the disk space units for `TOTAL` and `FREE`. diff --git a/inc/sccm.class.php b/inc/sccm.class.php index 5cf6f1c..a9c1867 100644 --- a/inc/sccm.class.php +++ b/inc/sccm.class.php @@ -49,6 +49,26 @@ public function showHome() echo __('Please, read the documentation before using that.', 'footprints'); } + public function getSccmBuildNumber() + { + $PluginSccmSccmdb = new PluginSccmSccmdb(); + $res = $PluginSccmSccmdb->connect(); + if (!$res) { + die; + } + + $query = "SELECT TOP 1 BuildNumber FROM dbo.Site;"; + + $result = $PluginSccmSccmdb->exec_query($query); + + $version = null; + if ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { + $version = Sanitizer::sanitize($row['BuildNumber']); + } + + return (int) $version; + } + public function getDevices($where = 0, $limit = 99999999) { diff --git a/inc/sccmxml.class.php b/inc/sccmxml.class.php index 6ca1b82..ecf0964 100644 --- a/inc/sccmxml.class.php +++ b/inc/sccmxml.class.php @@ -418,8 +418,13 @@ public function setStorages() $CONTENT = $this->sxml->CONTENT[0]; $i = 0; foreach ($PluginSccmSccm->getStorages($this->device_id) as $value) { - $value['gld-TotalSize'] = intval($value['gld-TotalSize']) * 1024; - $value['gld-FreeSpace'] = intval($value['gld-FreeSpace']) * 1024; + // since SCCM 2409 (Version: 5.0.9132.1000) (BuildNumber 9132) + // is total and freespace are no more in KB but in MB + $multiplier = ($PluginSccmSccm->getSccmBuildNumber() > 9132) ? 1 : 1024; + + $value['gld-TotalSize'] = intval($value['gld-TotalSize']) * $multiplier; + $value['gld-FreeSpace'] = intval($value['gld-FreeSpace']) * $multiplier; + $CONTENT->addChild('DRIVES'); $DRIVES = $this->sxml->CONTENT[0]->DRIVES[$i]; $DRIVES->addChild('DESCRIPTION', $value['gld-Description']);