From cc42c23bedc6ee1456e1627aafd3902b8431277a Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 5 Sep 2024 15:38:26 +1000 Subject: [PATCH] Improve partition to disk index in powershell audit. --- other/audit_windows.ps1 | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/other/audit_windows.ps1 b/other/audit_windows.ps1 index 338d29c0e..cfbd031ae 100755 --- a/other/audit_windows.ps1 +++ b/other/audit_windows.ps1 @@ -1010,13 +1010,7 @@ Get-WmiObject -Class Win32_LogicalDisk -Filter 'DriveType = "2" or DriveType = " $item.used = [Math]::Round($item.size - $item.free) $Win32_LogicalDiskToPartition | ForEach { if ($_.Dependent.IndexOf($item.device) -ne "null") { - $replace = "\\" + $_.PSComputerName + "\root\cimv2:Win32_DiskPartition.DeviceID=" - $item.device = $_.Antecedent.Replace($replace, "") - $item.device = $item.device.Replace('"', "") - $temp = $item.device.Split("#") - $temp1 = $temp[1] - $temp1 = $temp1.Split(",") - $item.hard_drive_index = [int]$temp1[0] + $item.hard_drive_index = ((($_.Antecedent.split('"'))[1].split('#'))[1].split(','))[0] } } $result.partition += $item