$disksize = $null
$limitGB = $null
$freeSpaceGB = $null
#Parameter
$limitGB = 150
$disksize = Get-WmiObject -ComputerName servername-SharepointDB -Class Win32_LogicalDisk | Where-object Name -eq “F:”
$freeSpaceGB = [math]::round($disksize.FreeSpace/1GB, 2)
If ($freeSpaceGB -lt $limitGB) {
Copy
$options = @{
‘SmtpServer’ = “server.smtp.com”
‘To’ = “Recipient”
‘From’ = “sender”
‘Subject’ = “F: Drive space threshold reached – $freeSpaceGB GB Free”
‘Body’ = “The F: drive is below 150 GB and only at $freeSpaceGB GB – Please resolve”
}
Here is the code and I am getting email The F: drive is below 150 GB and only at 0 GB – Please resolve, but that is not true. F drive is not low in space