Tagged: Inboxes

PSOL: Count files in SCCM-inboxes – Version 3

A bit more simple version of the last script… this time as a PowerShell oneliner.

Get-ChildItem \\MYSERVER\SMS_C01\inboxes -Recurse | Group-Object Directory | Where { $_.Count -gt 1 }  | Sort-Object Count -Descending | Format-Table Count, Name -AutoSize

Count files in SCCM-inboxes – Version 2

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 <part of path>"
	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

Count files in SCCM-inboxes

Working on some problems with old DDR-files and googled up a script that exported count of files to excel… did a small hack to it and it’s a nice-to-have tool.

Set oFSO = CreateObject("Scripting.FileSystemObject")
ListFolders("\\MyServername\SMS_C01\inboxes")

Sub ListFolders(sPath)
	Set oFolder = oFSO.GetFolder(sPath)
	if oFolder.Files.Count <> 0 then
		wscript.echo Left(oFolder.Files.Count & "        ", 6) & vbTab & oFolder.Path
	End if
	For Each oFldr In oFolder.SubFolders
		ListFolders oFldr.Path
	Next
End Sub

Original script: http://myitforum.com/cs2/blogs/dhite/archive/2006/07/23/22467.aspx