Fun with WMIC

(When preparing to write this brief post, I see that my MVP colleague Sherry Kissinger also has a post on WMIC and Windows Installer. Check it out – it’s a good read too.) 

Here are a couple more examples to add to your tool belt, especially when working with teammates in remote offices, and you need information from WinPE. My perfect example is that a tech reports in that OSD isn’t working, the symptom is that no fixed disks appear to be present on the system. This error usually means that you don’t have a mass storage driver in WinPE for the hardware. Of course, this error can also mean that you have a hard disk error, or that it’s not connected to your system.

Back to task, here are two example command lines for querying win32_pnpentity to display all Plug-and-Play information for a system.

Wmic /namespace:\\ROOT\cimv2 path win32_pnpentity get /format:hform >”c:\temp\data.htm”

Wmic /namespace:\\ROOT\cimv2 path win32_pnpentity get /format:csv >”c:\temp\test.csv”

The first example writes the information to a .htm file, and the second writes the information to a .csv file.

Once you have the PNP IDs, you can begin your journey to find the appropriate mass storage drivers.

More info: Creating and editing formats in WMIC.

Greg

How to: Enable Incremental Collection Updates With PowerShell

ConfigMgr 2007 R3 shipped with a feature called Incremental Updates for collections, and ConfigMgr 2012 also supports this feature. From the official docs, here’s what incremental updates do for you:

Select this option to periodically scan for only new or changed resources from the previous collection evaluation and update the collection membership with only these resources, independently of a full collection evaluation. By default, incremental updates occur at 10 minute intervals.

This post will demonstrate how to identify collections with incremental updates enabled, as well as how to enable incremental updates for a collection.

Here’s an example to list all collections that have incremental updates enabled:

#display collections with incremental updates enabled
#replace mycfgmgrlab with site server name, LAB with Site code
gwmi sms_collection -computer mycfgmgrlab `
  -namespace root\sms\site_LAB | foreach {
  $Coll = [wmi] $_.__Path
  if ($Coll.RefreshType -eq 6) {
        write-host $Coll.CollectionID "`t" $Coll.Name
    }
}

Since RefreshType is a lazy property, you must take some extra steps. use get-wmiobject (alias is gwmi) to get all collections, then perform a for-each loop to use query the instance directly using the [wmi] accelerator for PowerShell. Finally, check to see if RefreshType = 6.

Here’s an example to enable incremental updates on a collection:


#enable incremental updates on a collection
#replace mycfgmgrlab with site server name, LAB with Site code,
#and LAB007DE with desired collecitonid
$a = [wmi] "\\mycfgmgrlab\root\sms\site_LAB:SMS_Collection.CollectionID='LAB007DE'"
$a.RefreshType = 6
$a.put()

Use the [WMI] accelerator to grab the specific instance with lazy properties, and set RefreshType = 6

Valid values for RefreshType:

  • 6 = Incremental and Periodic Updates
  • 4 = Incremental Updates Only
  • 2 = Periodic Updates only
  • 1 = Manual Update only

For more information about Incremental Updates, review’ the Microsoft page for Creating Collections in ConfigMgr 2012 (expand the node “To Create a Device Collection” to see the details.) Also note that the following classes do not support incremental updates:

  • SMS_G_System_CollectedFile
  • SMS_G_System_LastSoftwareScan
  • SMS_G_System_AppClientState
  • SMS_G_System_DCMDeploymentState
  • SMS_G_System_DCMDeploymentErrorAssetDetails
  • SMS_G_System_DCMDeploymentCompliantAssetDetails
  • SMS_G_System_DCMDeploymentNonCompliantAssetDetails
  • SMS_G_User_DCMDeploymentCompliantAssetDetails (for collections of users only)
  • SMS_G_User_DCMDeploymentNonCompliantAssetDetails (for collections of users only)
  • SMS_G_System_SoftwareUsageData
  • SMS_G_System_CI_ComplianceState
  • SMS_G_System_EndpointProtectionStatus
  • SMS_GH_System_*
  • SMS_GEH_System_*

More information about Lazy Properties:

Greg

 

[edit 6/18/2012 to add 4=Incremental Updates Only – Thanks Josef!]