Can you write me a powershell script to monitor diskspace on domain joined windows 10…
- User
Can you write me a powershell script to monitor diskspace on domain joined windows 10 clients?
- Assistant
Sure! Here's a PowerShell script that you can use to monitor disk space on domain-joined Windows 10 clients:
powershell# Define the list of target computers $computers = "Computer1", "Computer2", "Computer3" # Iterate through each computer and get disk space information foreach ($computer in $computers) { Write-Host "Checking disk space on $computer..." $disks = Get-WmiObject -ComputerName $computer -Class Win32_LogicalDisk -Filter "DriveType=3" foreach ($disk in $disks) { $driveLetter = $disk.DeviceID $freeSpaceGB = [math]::Round($disk.FreeSpace / 1GB, 2) $totalSpaceGB = [math]::Round($disk.Size / 1GB, 2) $percentFree = [math]::Round(($disk.FreeSpace / $disk.Size) * 100, 2) Write-Host "$driveLetter - $freeSpaceGB GB free out of $totalSpaceGB GB ($percentFree% free)" } Write-Host "" }