Is it possible to create a custom alert in SCCM 2012 R2. I want SCCM to alert me when computers in a certain group have a less than a certain percentage of available hard drive space. I know there is a report for this by default, but I cannot figure out how to make SCCM alert me of the issue. Any help would be appreciated.
2 Answers
That kind of task would bedone more often with SCOM (versus SCCM). I don't think you can get an official SCCM alert in the monitorign console, but I can think of a 2 ways to do it with SCCM.
First would be to create a Query for devices that meet the criteria. No alert would be sent, you would have to review the query members every so often. If you have reports for free space, you've probably already done this, but for other readers, you also need to enable the Client Settings/Hardware Inventory collection of the Freespace property from Win32_LogicalDisk (see screen). Set the query to limited by the group/collection in question. The Query select would be as follows:
select SMS_R_System.Name, SMS_G_System_LOGICAL_DISK.DeviceID, SMS_G_System_LOGICAL_DISK.FreeSpace from SMS_R_System inner join SMS_G_System_LOGICAL_DISK on SMS_G_System_LOGICAL_DISK.ResourceID = SMS_R_System.ResourceId where SMS_G_System_LOGICAL_DISK.DeviceID = "C:" and SMS_G_System_LOGICAL_DISK.FreeSpace < 1024 order by SMS_R_System.Name
The second menthod could be done via a Pacakge where you create a Program that is a Powershell sript, and schedule it to run once every 24 hours. This would send an actual email. Deploy the package to the group/collection in question.
$diskC = gwmi win32_logicaldisk | where {$_.deviceid -match 'C'} | select systemname, @{n='gbFree'; e={[int]($_.freespace/1gb)}}, @{n='gbSize'; e={[int]($_.size/1gb)}}, @{n='percentFree'; e={"{0:N2}" -f ($_.freespace/$_.size)}}
if ($diskC.percentfree -lt .10) {
send-mailmessage -subj "Low Disk" -to "who@where.com" -from "who@where.com" -smtpserver "mail.where.com" -body ($diskC | converto-html | out-string) -bodyashtml
}
With such large disks, percentages are somtimes not always ideal triggers, you could also trigger with an absolulte size like this
if ($diskC.gbFree -lt 1) {

- 4,523
- 17
- 24
-
Thanks, I will try this out. I was already planning on writing a custom task that would do this, but I was hoping that it was possible in SCCM. – joeg1ff Jul 16 '14 at 15:05
Ok guys i figured it out. I piggybacked off of @Craig620's post of just using a powershell script. I took it one step further and instead of just running that same script on all computers I used the info that SCCM pulls . Here is the script I used to pull the info from the database and send an email.
$dataSource = “.\”
$user = “someuser”
$pwd = “somepass"
$database = “yourdb"
$connectionString = “Server=$dataSource;uid=$user; pwd=$pwd;Database=$database;Integrated Security=False;”
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
$connection.Open()
$query = "SELECT
SYS.Name0,LDISK.DeviceID0,
LDISK.FreeSpace0*100/LDISK.Size0 as [Percentage Free]
FROM v_R_System as SYS
join v_GS_LOGICAL_DISK LDISK on SYS.ResourceID = LDISK.ResourceID
WHERE
LDISK.DriveType0 =3 AND
LDISK.Size0 > 0 AND
Primary_Group_ID0 = someservergroup AND
LDISK.FreeSpace0*100/LDISK.Size0 < 20
ORDER BY SYS.Name0, LDISK.DeviceID0"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $query
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$SqlCmd.Connection = $connection
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$connection.Close()
send-mailmessage -subj "Low Disk Report" -to "some@domain.here" -from "another@domain.here" -smtpserver "some.mail.server" -body ($DataSet.Tables[0] + "" + "Enter some line of text here." | out-string)

- 391
- 3
- 6