A bit more complex version of the last script…
Requires a parameter for servername.
inboxcount.vbs
Option Explicit
Const cMinNofFiles = 1
Dim oFso, oArgs
Dim sPartOfPath, sServername, sSiteCode
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oArgs = WScript.Arguments
If oArgs.Count < 1 Then
WScript.echo "ERROR: Missing argument!"
WScript.Echo ""
WScript.Echo "cscript.exe inboxCount.vbs SERVERNAME "
WScript.Quit -1
End If
sServername = uCase(oArgs.Item(0))
If oArgs.Count-1 = 1 Then
sPartOfPath = oArgs.Item(1)
Else
sPartOfPath = ""
End If
sSiteCode = getSccmSiteCode(sServername)
WScript.Echo "=============================================================================="
WScript.Echo " SCCM Inbox Counter Rikard Ronnkvist / snowland.se"
WScript.Echo "------------------------------------------------------------------------------"
WScript.Echo " Server: " & sServerName
WScript.Echo " SiteCode: " & sSiteCode
WScript.Echo " Path: \\" & sServername & "\SMS_" & sSiteCode & "\inboxes"
WScript.Echo "------------------------------------------------------------------------------"
ListFolders "\\" & sServername & "\SMS_" & sSiteCode & "\inboxes", "\\" & sServername & "\SMS_" & sSiteCode & "\inboxes"
WScript.Echo "=============================================================================="
WScript.Quit
Function getSccmSiteCode(sServername)
Dim oWMIService, oLocator, oSites, currentSite
Set oLocator = CreateObject("WbemScripting.SWbemLocator")
Set oWMIService = oLocator.ConnectServer(sServername, "root\sms", "", "")
' Now figure out the site code for this server.
Set oSites = oWMIService.ExecQuery("SELECT SiteCode FROM SMS_ProviderLocation WHERE ProviderForLocalSite=true")
For each currentSite in oSites
getSccmSiteCode = Trim(currentSite.SiteCode)
Exit Function
Next
End Function
Sub ListFolders(sPath, sRoot)
Dim oFolder, oFldr
Set oFolder = oFSO.GetFolder(sPath)
If (oFolder.Files.Count >= cMinNofFiles) AND (InStr(oFolder.Path, sPartOfPath) > 0) Then
wscript.echo Left(oFolder.Files.Count & " ", 6) & vbTab & Replace(uCase(oFolder.Path), uCase(sRoot), "")
End If
For Each oFldr In oFolder.SubFolders
ListFolders oFldr.Path, sRoot
Next
End Sub