Skip to content

Instantly share code, notes, and snippets.

@Dalmirog-zz
Last active November 2, 2016 15:47
Show Gist options
  • Save Dalmirog-zz/2559b333b990b10ad841cef175a1b124 to your computer and use it in GitHub Desktop.
Save Dalmirog-zz/2559b333b990b10ad841cef175a1b124 to your computer and use it in GitHub Desktop.
Checks Tentacle's health but skipping a few drives
$freeDiskSpaceThreshold = 5GB
$skipdrives = ("D:")
Try {
Get-WmiObject win32_LogicalDisk -ErrorAction Stop | ? { ($_.DriveType -eq 3) -and ($_.FreeSpace -ne $null) -and ($SkipDrives -notcontains $_.DeviceID)} | % { CheckDriveCapacity @{Name =$_.DeviceId; FreeSpace=$_.FreeSpace} }
} Catch [System.Runtime.InteropServices.COMException] {
Get-WmiObject win32_Volume | ? { ($_.DriveType -eq 3) -and ($_.FreeSpace -ne $null) -and ($_.DriveLetter -ne $null) -and ($SkipDrives -notcontains $_.driveletter) } | % { CheckDriveCapacity @{Name =$_.DriveLetter; FreeSpace=$_.FreeSpace} }
Get-WmiObject Win32_MappedLogicalDisk | ? { ($_.FreeSpace -ne $null) -and ($_.DeviceId -ne $null)} | % { CheckDriveCapacity @{Name =$_.DeviceId; FreeSpace=$_.FreeSpace} }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment