Hi @Avyayah ,
is there an "F:-Drive"?
Please check the value of $disksize
in your script if there is a "F:-Drive" found:
$disksize = $null
$limitGB = 150
$disksize = Get-WmiObject -ComputerName localhost -Class Win32_LogicalDisk | Where-object Name -eq "F:"
if ($disksize) {
$freeSpaceGB = [math]::round($disksize.FreeSpace/1GB, 2)
if ($freeSpaceGB -lt $limitGB) {
Write-Output "running out of space - $freeSpaceGB GB free"
} else {
Write-Output "enough space - $freeSpaceGB GB free "
}
} else {
Write-Output "No F: drive found "
}
You can run this to get the disks and check which drives are found:
Get-WmiObject -ComputerName localhost -Class Win32_LogicalDisk
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten