-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHealthCheck.ps1
31 lines (21 loc) · 1014 Bytes
/
HealthCheck.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#-----Set Vars to Null-----#
$Servernames = $null
#-----Store Creds in a Var-----#
$Credentials = Get-Credential
#-----Disk Utilization-----#
$File = get-content -path 'servers.txt'
$DiskReport = ForEach ($Servernames in ($File))
{Get-WmiObject win32_logicaldisk -Credential $Credentials -ComputerName $Servernames -Filter "Drivetype=3"
#return only disks with
#free space less
#than or equal to 0.1 (10%)
#Where-Object { ($_.freespace/$_.size) -le '0.1'}
}
$DiskReport |
Select-Object @{Label = "Server Name";Expression = {$_.SystemName}},
@{Label = "Drive Letter";Expression = {$_.DeviceID}},
@{Label = "Total Capacity (GB)";Expression = {"{0:N1}" -f( $_.Size / 1gb)}},
@{Label = "Free Space (GB)";Expression = {"{0:N1}" -f( $_.Freespace / 1gb ) }},
@{Label = 'Free Space (%)'; Expression = {"{0:P0}" -f ($_.freespace/$_.size)}} |
#Export report to CSV file (Disk Report)
Export-Csv -path "c:\temp\DiskReport\DiskReport_$(get-date -f yyyy-MM-dd).csv" -NoTypeInformation