November 2009 - Posts

Hardware Inventory - FolderSize on a Client

This is a script + mof edit, might be helpful for people needing to find "how much space" is used by specific folders on clients.  fyi, it's not currently designed to look at 'my documents', which is what I've had people ask me for in the past.  I had this script + mof edit for a different, specifically named folder.  But it might be a starting point for someone.

 

Save the below as a .vbs.  What to add to sms_def.mof is below.

 

On Error Resume Next
'----------------------------------------
'Syntax:   FolderSize.vbs "Path to Folder" "Another Folder" "Another folder up to 50"
'   Example:   cscript.exe FolderSize.vbs "c:\temp" "d:\some folder with spaces" "c:\program files\Really Important"
'----------------------------------------
'Add the following to sms_def.mof (remove the ' comment at the beginning of each line!
'//  <:[-<>>>>>>>>>>>Start>>-Folder Size-<<Start<<<<<<<<<>-]:>
'//`'`*._.*`'`*-
'//  Folder Size Reporting Class
'//`'`*._.*`'`*-
'#pragma namespace("\\\\.\\root\\cimv2\\SMS")
'#pragma deleteclass("SCCM_FolderSize",NOFAIL)
'
'[ SMS_Report     (TRUE),
'  SMS_Group_Name ("FolderSize"),
'  SMS_Class_ID   ("CUSTOM|FolderSize|1.0") ]
'class SCCM_FolderSize : SMS_Class_Template
'{
'  [SMS_Report (TRUE), key ] string Path;
'  [SMS_Report (TRUE), SMS_Units("KiloBytes")] uint32 KB;
'  [SMS_Report (TRUE), SMS_Units("Megabytes")] Uint32 MB;
'  [SMS_Report (TRUE)      ] string ScriptLastRan;
'};
'//  <:[-<>>>>>>>>>>>END>>-Folder Size-<<END<<<<<<<<<>-]:>

'----------------------------------------
'Initially created by Sherry Kissinger 6/10/2009
'Logic of the Script
'1) Grab the folder names from the wscript arguments
'2) For each folder, gather the data into an array
'3) Create the WMI Namespaces
'4) Populate WMI with the array data
'-----------------------------------------
'****************************************
'1) Grab the folder names from the wscript arguments
If Wscript.Arguments.Count = 0 Then
 'nothing to do
 wscript.quit(0)
End If

CountFolders = Wscript.Arguments.Count

Dim strObjects(50,3)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set sho = Wscript.CreateObject("Wscript.Shell")
'--------------------------------------------
'2) For each folder, gather the data into an array
'--------------------------------------------
For i = 0 To CountFolders-1
 Err.Clear
 Set objFolder = objFSO.GetFolder(WScript.Arguments(i))
 If Err.Number = 0 Then
  strObjects(i,0) = objFolder.Path  'folder path, value 1 of 4
  strObjects(i,1) = FormatNumber((objFolder.Size/1024), 2) 'KB, value 2 of 4
  strObjects(i,2) = FormatNumber((objFolder.Size/1024)/1024, 2) 'MB, value 3 of 4
  strObjects(i,3) = Now  'DateScriptRan, value 4 of 4
 Else
  strObjects(i,0) = WScript.Arguments(i) & " : Path not found"
  strObjects(i,3) = Now  'DateScriptRan, value 4 of 4
 End if
Next
'----------------------------
'3) Create the WMI Namespaces
'----------------------------

Dim wbemCimtypeSint16
Dim wbemCimtypeSint32
Dim wbemCimtypeReal32
Dim wbemCimtypeReal64
Dim wbemCimtypeString
Dim wbemCimtypeBoolean
Dim wbemCimtypeObject
Dim wbemCimtypeSint8
Dim wbemCimtypeUint8
Dim wbemCimtypeUint16
Dim wbemCimtypeUint32
Dim wbemCimtypeSint64
Dim wbemCimtypeUint64
Dim wbemCimtypeDateTime
Dim wbemCimtypeReference
Dim wbemCimtypeChar16

wbemCimtypeSint16 = 2
wbemCimtypeSint32 = 3
wbemCimtypeReal32 = 4
wbemCimtypeReal64 = 5
wbemCimtypeString = 8
wbemCimtypeBoolean = 11
wbemCimtypeObject = 13
wbemCimtypeSint8 = 16
wbemCimtypeUint8 = 17
wbemCimtypeUint16 = 18
wbemCimtypeUint32 = 19
wbemCimtypeSint64 = 20
wbemCimtypeUint64 = 21
wbemCimtypeDateTime = 101
wbemCimtypeReference = 102
wbemCimtypeChar16 = 103
Set oLocation = CreateObject("WbemScripting.SWbemLocator")

'Remove classes
Set oServices = oLocation.ConnectServer(, "root\cimv2")
set oNewObject = oServices.Get("SCCM_FolderSize")
oNewObject.Delete_

Set oServices = oLocation.ConnectServer(, "root\cimv2\SMS")
set oNewObject = oServices.Get("SCCM_FolderSize")
oNewObject.Delete_

'Create data class structure
Set oServices = oLocation.ConnectServer(, "root\cimv2")
Set oDataObject = oServices.Get
oDataObject.Path_.Class = "SCCM_FolderSize"
oDataObject.Properties_.add "Path", wbemCimtypeString
oDataObject.Properties_.add "KB", wbemCimtypeUint32
oDataObject.Properties_.add "MB", wbemCimtypeUint32
oDataObject.Properties_.add "ScriptLastRan", wbemCimtypeString
oDataObject.Properties_("Path").Qualifiers_.add "key", True
oDataObject.Put_


'------------------------------
'Add Instances to data class
Set oServices = oLocation.ConnectServer(, "root\cimv2")

For i=0 To CountFolders-1
 Set oNewObject = oServices.Get("SCCM_FolderSize").SpawnInstance_
        oNewObject.Path = strObjects(i,0)
        oNewObject.KB = strObjects(i,1)
        oNewObject.MB = strObjects(i,2)
        oNewObject.ScriptLastRan = strObjects(i,3)
        oNewObject.Put_
'Uncomment the following 4 lines to for troubleshooting interactively
 WScript.Echo strObjects(i,0) & ", " &_
              strObjects(i,1) & ", " &_
              strObjects(i,2) & ", " &_
              strObjects(i,3)
Next


'Create reporting class structure
Set oServices = oLocation.ConnectServer(, "root\cimv2\SMS")
Set oRptObject = oServices.Get("SMS_Class_Template").SpawnDerivedClass_

'Set Class Name and Qualifiers
oRptObject.Path_.Class = "SCCM_FolderSize"
oRptObject.Qualifiers_.Add "SMS_Report", True
oRptObject.Qualifiers_.Add "SMS_Group_Name", "FolderSize"
oRptObject.Qualifiers_.Add "SMS_Class_ID", "Custom|FolderSize|1.0"
          
'Add Reporting Class Properties
oRptObject.Properties_.Add("Path", wbemCimtypeString).Qualifiers_.Add "SMS_Report", True
oRptObject.Properties_.Add("KB", wbemCimtypeUint32).Qualifiers_.Add "SMS_Report", True
oRptObject.Properties_.Add("MB", wbemCimtypeUint32).Qualifiers_.Add "SMS_Report", True
oRptObject.Properties_.Add("ScriptLastRan", wbemCimtypeString).Qualifiers_.Add "SMS_Report", True
oRptObject.Properties_("Path" ).Qualifiers_.Add "key", True
oRptObject.Put_

WScript.quit

Posted by skissinger | with no comments

Troubleshooting: Advertisement Status for a Specific Advertisement not updating from child site assigned clients

 Issues observed:  

  1. Component Status no longer displays most recent results in "Last Status Message" -- date is old
  2. The report "Advertisement Status for a specific advertisement" does not correctly reflect clients at child sites' Last Status Message for new advertisements  (they just say "No Status").  That's because the data behind v_clientAdvertisementStatus isn't getting updated.

Cause:  Status Filter Rule, "Write all other messages to the site database and specify the period after which the user can delete messages", on the Actions tab in there, do NOT check on the box "Do not forward to status summarizers". That change was inadvertently done, and that broke the summary data getting into v_clientadvertisementstatus .

If you're having this issue, (or something similar), also check the "Write audit Messages..." status filter rule as well.

PS: Just writing this up mostly for myself.  It was one of those wierd things that took a while to track what changed between a Friday and a Monday (didn't notice the problem over the weekend!).  So since I'm afraid this will end up being one of those nuggets of knowledge where one day I'll say to myself "hmm...I remember seeing that before... now what was it?!) If I blog it, I have a chance of maybe remembering.  Or at least letting a search engine remember for me.

Posted by skissinger | with no comments
Filed under:

Book Review: System Center Configuration Manager 2007 Unleashed

I've had this book for a while, and have meant to write a review.  Finally took a few minutes to write out my thoughts!

I really like it.  It covers well all of the aspects of SP1, including some of the newer elements, which a current SMS2003 administrator might have little previous knowledge of, like Native mode, and DCM.  And has some really great step-by-step guides for the most-often used reasons for ConfigMgr, like patching and Software Distribution.  I especially appreciated the "Real World" and other tips when you are planning or configuring--the gotcha's that you might not see as obvious, but are obvious once you read their explanation.

As with any technical book, I always learn something new when reading a tech book.  For me, I haven't had a work-related reason (yet) to dive deep into App-v with ConfigMgr, so reading that section gave me a good grounding for when that project comes up (because you know it will eventually).

Posted by skissinger | with no comments
Filed under: ,