This page will show all the disk space info from all the SCCM servers. You just need to specify all the sccm servers you have in the parameters part in the PowerShell script. It will auto search all the physical drivers inside the sccm server and display the disk capacity, free space, and used space in both text and graphic way.
If you don't have PowerShell Universal and just want to display them with HTML code. you can modify the last part of the code. (The HTML code is with variable $sum)
# SCCM Server Storage Status
# Rui Qiu
# 9/3/2021
# List all the servers need to calculate storage status
$servers = @('xxx','xxx','xxx','xxx','xxx','xxx','xxx')
# Setting up storage thresholds percentage
$script:Thresholds = @{}
$Thresholds.Warning = 80
$Thresholds.Critical = 90
# Function to set the percentage color
Function Set-PercentageColour {
param([int]$Value)
If ($Value -lt $Thresholds.Warning)
{$Hex = "#00ff00" # Green
}
If ($Value -ge $Thresholds.Warning -and $Value -lt $Thresholds.Critical)
{$Hex = "#ff9900" # Amber
}
If ($Value -ge $Thresholds.Critical)
{$Hex = "#FF0000" # Red
}
Return $Hex
}
# Calculate storage on each server and generate HTML Code
foreach ($server in $servers){
$diskinfo = gwmi win32_logicaldisk -ComputerName $server –Property Size,FreeSpace,DeviceId -Filter "DriveType = 3"
foreach($disk in $diskinfo) {
$total = [math]::Round(($disk.Size / 1GB),2)
$used = [math]::Round((($disk.Size / 1GB) – ($disk.FreeSpace / 1GB)),2)
$usedpercent = [math]::Round((($disk.Size – $disk.FreeSpace) * 100 / $disk.Size),2)
$free = [math]::Round(($disk.FreeSpace / 1GB),2)
$drive = $disk.DeviceId
$sum = @"
<table cellpadding="0" cellspacing="0" width="700">
<tr>
<td style="background-color:$(Set-PercentageColour –Value $usedpercent);padding:10px;color:#ffffff;" width="$usedpercent%">
$used GB ($usedpercent%)
</td>
<td style="background-color:#eeeeee;padding-top:10px;padding-bottom:10px;color:#333333;" width="$usedpercent%">
</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" width="700">
</table>
"@
# Display storage info in text
New-UDTypography -Text "Server: $server, Drive: $drive, Total Space: $total GB, Used Space: $used GB, Free Space: $free GB"
# One line for spacing
New-UDElement -tag 'div' -attributes @{
style = @{
height = '10px'
}
}
# Display storage info in graphic
New-UDHtml -Markup $sum
# One line for spacing
New-UDElement -tag 'div' -attributes @{
style = @{
height = '10px'
}
}
}
}