mirror of
https://github.com/NetSPI/PowerHuntShares.git
synced 2025-05-05 03:38:42 +02:00
Update PowerHuntShares.psm1
Small updates to computer os chart.
This commit is contained in:
parent
21f5248b65
commit
3549144507
@ -2522,6 +2522,9 @@ function Invoke-HuntSMBShares
|
|||||||
$myObject
|
$myObject
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Save to file
|
||||||
|
$DomainComputerFull | Export-Csv -NoTypeInformation "$OutputDirectory\$TargetDomain-Domain-Computers-Open445-OSVer.csv"
|
||||||
|
|
||||||
# Get count of all computer objects
|
# Get count of all computer objects
|
||||||
$DomainComputerFullCount = $DomainComputerFull | measure | select count -ExpandProperty count
|
$DomainComputerFullCount = $DomainComputerFull | measure | select count -ExpandProperty count
|
||||||
|
|
||||||
@ -2531,28 +2534,28 @@ function Invoke-HuntSMBShares
|
|||||||
# Get count of unique operating systems
|
# Get count of unique operating systems
|
||||||
$DomainComputerOSCount = $DomainComputerOSList | measure | select count -ExpandProperty count
|
$DomainComputerOSCount = $DomainComputerOSList | measure | select count -ExpandProperty count
|
||||||
|
|
||||||
# Get percentage of each operating system
|
# Get count of each operating system - the counts are off
|
||||||
$DomainComputerOSSum = $DomainComputerOSList |
|
$DomainComputerOSSum = $DomainComputerOSList |
|
||||||
Foreach {
|
Foreach {
|
||||||
|
|
||||||
$TargetComputerOS = $_.OperatingSystem
|
$TargetComputerOS = $_.OperatingSystem
|
||||||
|
|
||||||
# Get count
|
# Get count
|
||||||
$TargetComputerOSCount = $DomainComputers | where OperatingSystem -eq "$TargetComputerOS" | measure | select count -ExpandProperty count
|
$TargetComputerOSCount2 = $DomainComputerFull | where OperatingSystem -eq "$TargetComputerOS" | measure | select count -ExpandProperty count
|
||||||
|
|
||||||
# Calculate percentage
|
# Calculate percentage
|
||||||
$TargetComputerOSP = [math]::Round($TargetComputerOSCount/$DomainComputerFullCount,2) * 100
|
$TargetComputerOSP = [math]::Round($TargetComputerOSCount2/$DomainComputerFullCount,2) * 100
|
||||||
|
|
||||||
# Return powershell object os,count,percent
|
# Return powershell object os,count,percent
|
||||||
$object = New-Object psobject
|
$object = New-Object psobject
|
||||||
$object | add-member noteproperty os $TargetComputerOS
|
$object | add-member noteproperty os $TargetComputerOS
|
||||||
$object | add-member noteproperty count $TargetComputerOSCount
|
$object | add-member noteproperty count $TargetComputerOSCount2
|
||||||
$object | add-member noteproperty percent $TargetComputerOSP
|
$object | add-member noteproperty percent $TargetComputerOSP
|
||||||
$object
|
$object
|
||||||
}
|
}
|
||||||
|
|
||||||
# Save results to a csv
|
# Save results to a csv - accurate
|
||||||
$DomainComputerOSSum | Export-Csv -NoTypeInformation "$OutputDirectory\$TargetDomain-Domain-Computers-Open445-OSVer.csv"
|
$DomainComputerOSSum | Export-Csv -NoTypeInformation "$OutputDirectory\$TargetDomain-Domain-Computers-Open445-OSVerSum.csv"
|
||||||
|
|
||||||
# Create java script chart objects - names
|
# Create java script chart objects - names
|
||||||
$DomainComputerOSListJsNames = ""
|
$DomainComputerOSListJsNames = ""
|
||||||
@ -10495,6 +10498,7 @@ const sortedNames = sortedData.map(item => item.name);
|
|||||||
const sortedValues = sortedData.map(item => item.value);
|
const sortedValues = sortedData.map(item => item.value);
|
||||||
|
|
||||||
// Initialize ApexCharts with sorted data
|
// Initialize ApexCharts with sorted data
|
||||||
|
const maxCount = Math.max(...sortedValues); // Get the maximum count from sorted values
|
||||||
const ChartComputersOSOptions = {
|
const ChartComputersOSOptions = {
|
||||||
series: [{
|
series: [{
|
||||||
name: 'Count',
|
name: 'Count',
|
||||||
@ -10534,10 +10538,16 @@ const ChartComputersOSOptions = {
|
|||||||
show: false
|
show: false
|
||||||
},
|
},
|
||||||
xaxis: {
|
xaxis: {
|
||||||
|
min: 0, // Ensure x-axis starts at 0
|
||||||
|
max: maxCount, // Dynamically set the max value based on the data
|
||||||
|
tickAmount: maxCount + 1, // Ensure there are tick marks up to the max count
|
||||||
categories: sortedNames, // Use sorted names for categories
|
categories: sortedNames, // Use sorted names for categories
|
||||||
labels: {
|
labels: {
|
||||||
style: {
|
style: {
|
||||||
fontSize: '12px'
|
fontSize: '12px'
|
||||||
|
},
|
||||||
|
formatter: function (value) {
|
||||||
|
return value.toFixed(1); // Show the count as is, no fractional increments needed
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
@ -10567,7 +10577,7 @@ const ChartComputersOSOptions = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
text: 'Computer Count by OS',
|
text: 'Live Computer Count by OS',
|
||||||
align: 'center', // Aligns the title
|
align: 'center', // Aligns the title
|
||||||
margin: 10, // Space between the title and the chart
|
margin: 10, // Space between the title and the chart
|
||||||
style: {
|
style: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user