Basic PowerShell Script, Check Disk Space and Send Alert #sysadmin #powershell #techtips #scripting

preview_player
Показать описание
Learn the basics of PowerShell scripting with these quick, practical examples! From checking file existence to monitoring services, these tutorials are perfect for beginners and those looking to automate tasks with PowerShell. Each video shows you how to create simple scripts to boost productivity and streamline your workflows.

$drive = Get-PSDrive -Name C

$totalSpace = $drive.Used + $drive.Free
$usedPercentage = ($drive.Used / $totalSpace) * 100

Write-Output "Disk Used Percentage: $usedPercentage"

if ($usedPercentage -gt 50) {
Write-Output "Warning: Disk space above 90%!"
} else {
Write-Output "Disk space is fine."
}
Рекомендации по теме
Комментарии
Автор

You can do this with any programming language. I prefer bash over powershell though

lamborghinigamer