Tag Archive: SCCM inbox monitor

PowerShell – Manage SCCM Inbox counts

A good practice in SCCM is to check your Inbox folder file counts daily for any backlog that may point to a potential component problem.  This task is easily achieved through a simple PowerShell command.  The SMS_Inbox_Monitor information is found in WMI.  If you would like to get an Inbox file count you can run the following PowerShell command.

Get-WmiObject -Class Win32_PerfFormattedData_SMSINBOXMONITOR_SMSInbox -ComputerName SERVERNAME1, SERVERNAME2, SERVERNAME3 | Select-Object -Property PSComputerName, Name, FileCurrentCount

This will work for both SCCM 2007 and SCCM 2012.  I like to save this information to my SQL database so that I can keep track of the weekly counts.  Here is a sample script how to import this information into your database.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Import SCCM Inbox Counts
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

 

$events = Get-WmiObject -Class Win32_PerfFormattedData_SMSINBOXMONITOR_SMSInbox -ComputerName SERVERNAME1, SERVERNAME2, SERVERNAME3 | Select-Object -Property PSComputerName, Name, FileCurrentCount
$connectionString = “Data Source=SCCM_SQL_SERVER;Integrated Security=true;Initial Catalog=SCCM_Support;”
$bulkCopy = new-object (“Data.SqlClient.SqlBulkCopy”) $connectionString
$bulkCopy.DestinationTableName = “SCCM_Inbox_Count”
$dt = New-Object “System.Data.DataTable”

# build the datatable
$cols = $events | get-member -MemberType NoteProperty | select -Expand Name
foreach ($col in $cols) {$null = $dt.Columns.Add($col)}

foreach ($event in $events)
{
$row = $dt.NewRow()
foreach ($col in $cols) { $row.Item($col) = $event.$col }
$dt.Rows.Add($row)
}

# Write to the database!
$bulkCopy.WriteToServer($dt)