MOF Example – END – END

  Client_UserProfileSize.MOF :—–   #pragma namespace (“\.rootcimv2”)
#pragma deleteclass(“Win32Reg_UserProfileSize”,NOFAIL)
[ dynamic,
  provider(“RegProv”),
  ClassContext(“local|HKEY_LOCAL_MACHINESOFTWAREDesktopOptimizationUserProf”)
]
class Win32Reg_UserProfileSize
{
    [key]
    string    Profile;
    [PropertyContext(“Application Data”)]       
        string    ApplicationData;
    [PropertyContext(“Desktop”)]       
        string    Desktop;
    [PropertyContext(“My Documents”)]       
        string    MyDocuments;
    [PropertyContext(“Local Settings”)]       
        string    LocalSettings;
     [PropertyContext(“ScriptRunOn”)]  
        string    ScriptRunOn;
     [PropertyContext(“TotalSize”)]
        string    TotalSize;
    [PropertyContext(“RECYCLER”)]
        string    RECYCLER;
};     Server_side_sms_MOF .MOF :—   [ SMS_Report     (TRUE),
  SMS_Group_Name (“DiskActivity”),
  SMS_Class_ID   (“MICROSOFT|Disk_Activity|1.0”) ] class Win32Reg_DiskActivity : SMS_Class_Template

   [SMS_Report (TRUE) ]  
        string   Activity;
    [SMS_Report (TRUE) ]  
        string   CleanDate;
    [SMS_Report (TRUE) ]
        string    DefragAnalysis;
    [SMS_Report (TRUE)]
        string    DefragDate;
    [SMS_Report (TRUE)]
        string    DefragStatus;
    [SMS_Report (TRUE)]
        string    DiskClean_status;
    [SMS_Report (TRUE)]
        string    DiskCleanLast_CleanDate;
    [SMS_Report (TRUE)]
        string    DiskSpace;
    [SMS_Report (TRUE)]
        string    Last_DefragDate;
}; [ SMS_Report     (TRUE),
  SMS_Group_Name (“UserProfile”),
  SMS_Class_ID   (“MICROSOFT|UserProfileSize|1.0”) ] class Win32Reg_UserProfileSize : SMS_Class_Template

   [SMS_Report (TRUE) ]  
        string   Profile;
    [SMS_Report (TRUE) ]  
        string   ApplicationData;
    [SMS_Report (TRUE) ]
        string    Desktop;
    [SMS_Report (TRUE)]
        string    MyDocuments;
    [SMS_Report (TRUE)]
        string    LocalSettings;
    [SMS_Report (TRUE)]
        string    ScriptRunOn;
    [SMS_Report (TRUE)]
        string    TotalSize;
    [SMS_Report (TRUE)]
        string    RECYCLER;
};   VBSCRIPT :– UserProfileSize_Recycler.vbs     sNode = “.”
Const MBCONVERSION= 1048576
Const HKEY_LOCAL_MACHINE = &H80000002
dim oFS, oFolder Set oReg = GetObject(“winmgmts:{impersonationLevel=impersonate}!” _
           & sNode & “/root/default:StdRegProv”) sPath = “SOFTWAREMicrosoftWindows NTCurrentVersionWinlogon”
sValueName = “DefaultUserName” If oReg.GetStringValue(HKEY_LOCAL_MACHINE, sPath, sValueName, sValue) = 0 Then
  ‘WScript.Echo “DefaultUserName from Registry Retrieved Remotely: ” & sValue
End If ScriptRunOn=Replace(Now(),”#”,””) strKeyPath = “SOFTWAREDesktopOptimizationUserProf”
              oReg.CreateKey HKEY_LOCAL_MACHINE ,strKeyPath
strKeyPath1 = “SOFTWAREDesktopOptimizationUserProf”&sValue
              oReg.CreateKey HKEY_LOCAL_MACHINE ,strKeyPath1             path=”C:Documents and Settings”& sValue       
Set FSO = CreateObject(“Scripting.FileSystemObject”) Set Folder = FSO.GetFolder(Path)
    TotalSize=FormatNumber(Folder.Size/MBCONVERSION,0)
    ‘MsgBox (TotalSize)
    strValueName =”TotalSize”
    strValue = TotalSize
    oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath1,strValueName,strValue
    strValueName =”ScriptRunOn”
    strValue = ScriptRunOn
    oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath1,strValueName,strValue
Set colSubFolders = Folder.SubFolders
For Each subFolder In colSubFolders
                     FolderName = subFolder.Name
                       FolderSize = FormatNumber(subFolder.Size/MBCONVERSION,0)
                     ‘MsgBox(FolderName)
                     ‘MsgBox(FolderSize)
                     strValueName = FolderName
                     strValue = FolderSize
                     oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath1,strValueName,strValue
Next  GetRecycleBinSize() Function GetRecycleBinSize         dim oFS, oFolder         set oFS = WScript.CreateObject(“Scripting.FileSystemObject”)
        If oFS.FolderExists(“C:Recycler”)Then
           Set oFolder = oFS.GetFolder(“C:Recycler”)
           ‘wscript.echo oFolder.Name & “:Size=” & oFolder.Size
           RecycleBinSize=FormatNumber(oFolder.Size/MBCONVERSION,0)
           ‘wscript.echo RecycleBinSize
           strValueName = oFolder.Name
           strValue = RecycleBinSize
           oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath1,strValueName,strValue
        Else
           strValueName = “RECYCLER”
           strValue = “Folder C:RECYCLER Not Found”
           oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath1,strValueName,strValue
        End If
End Function

Leave a Comment