Skip to content

Commit

Permalink
Improve partition to disk index in powershell audit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-unwin committed Sep 5, 2024
1 parent 9529001 commit cc42c23
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions other/audit_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc42c23

Please sign in to comment.