New CyberDrain Scripts Available In The Community Library

CyberDrain has just added four additional scripts to our Community Scripting Library, as well as an output update to the Detect Failed Logins script!

  1. Monitor VHDX Files

Monitors VHDX files vs actual size available on disk, if disks are in danger of being overprovisioned it generates an alert. Requires path of VHDX files

  1. Automatic Network Map

Generate an automatic network map to import on Draw.io. Enter a network range in CIDR format(192.168.1.0/24).

  1. Monitor Bitdefender Last Scan State

Monitors the last scan state of BitDefender and alerts if issues have been found.

  1. Monitor Bitdefender Quarantine

Alerts if files on the local device have been moved to quarantine and are still there.

2 Likes

Here’s my modified version of the VHDX check. I’ve fixed a typo, reversed variables to correct the percentage, added alert for no files found, exit codes for error/fail and more output.

# Check for overprovisioned VHDx
$VHDPath = "C:\Users\Public\Documents\Hyper-V\Virtual hard disks"
$VHDXFiles = Get-ChildItem $VHDPath -Filter "*.vhd*" -Recurse
if (!$VHDXFiles) {
    Rmm-Alert -Category 'Monitor - Server Hosts' -Body "No VHD(x) files found. Please change the path to a location that stores VHD(x) files."
    exit 2
}

if (!(Get-Module 'hyper-v' -ListAvailable)) { Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell }
$VHDInfo = foreach ($VHD in $VHDXFiles) {
    $info = Get-VHD -Path $VHD.FullName
    [PSCustomObject]@{
        MaxSize        = ($info.Size / 1gb)
        CurrentVHDSize = ($info.FileSize / 1gb)
        MinimumSize    = ($info.MinimumSize / 1gb)
        VHDPath        = $info.path
        Type           = $info.vhdtype
        PercentageFull = ($info.FileSize / $info.size * 100)
    }
}

$CombinedSize = (($VHDINFO | Where-Object { $_.type -eq 'Dynamic' }  ).Maxsize | Measure-Object -Sum).sum
$DiskSize = [math]::round((Get-Volume ($VHDPath.Split(':') | Select-Object -First 1)).size / 1gb)
Write-Host "Combined Size: $CombinedSize GB"
Write-Host "Disk Size: $DiskSize GB"
$vhdinfo

if ($CombinedSize -gt $DiskSize) {
    Rmm-Alert -Category 'Monitor - Server Hosts' -Body "The combined VHD(x) is greater than the disk: VHD: $($combinedSize)GB - Disk: $($DiskSize)GB"
    exit 1
}
5 Likes