New Whitepaper – Configuring Microsoft® System Center Configuration Manager 2007 Inventory to utilize Dell™ OpenManage™ Client Instrumentation 8.0.1 for WakeOnLan Reporting

My teammate Mike Shuman just published a whitepaper on how to inventory WoL status on Dell Client systems with ConfigMgr 2007- download here:

Configuring Microsoft® System Center Configuration Manager 2007 Inventory to utilize Dell™ OpenManage™ Client Instrumentation 8.0.1 for WakeOnLan Reporting

 

Greg

Using DateDiff and GetDate in WQL for SMS and ConfigMgr Queries and Collections

Another classic from my old blog (flash back to 2007) – I had to use DateDiff and GetDate in my new ConfigMgr 2012 infrastructure today, so I thought I’d re-post on my new blog…

Queries and collections based on time stamps with DateDiff and GetDate - That’s the best thing that’s happened to collections since. . .well, as long as I can remember. I use these every day, and you should too. A couple years ago, my good friend Warren Byle ran across the following bullet in the SMS 2003 SDK, in a section titled “Extended WMI Query Language”:

  • In SMS 2003 the WHERE clause now supports GetDate(), DateDiff(), and DateAdd().

That’s it. . one small bullet, yet it adds so much functionality to SMS, and makes writing some of my collections much easier, and very low maintenance.

From our book, SMS 2003 Recipes: A Problem-Solution Approach, recipe 9-27 Creating a Date-Based Query:

SMS 2003 supports the following date functions in the WHERE clause of WQL queries.

GetDate(): This function will return the current date and time on the system. The data is returned in date-time format (e.g., 12:56 AM 12/02/2006).

DateDiff(): This function will return the difference between two date-time values in the increment that you specify (e.g., minute, hour, day). In our testing, the DateParts listed in Table 9-1 are supported when using DateDiff in a WHERE clause in SMS WQL.

DateDiff ( DatePart, StartDate, EndDate )

DatePart is the part of the date you want to calculate (e.g., minute, day, month, etc.).

StartDate is the begin date.

EndDate is the ending date.

DateAdd(): Returns a new date-time value based on adding an interval to the specified date. In our testing, the DateParts listed in Table 9-1 are supported when using DateAdd in a WHERE clause in SMS WQL. The proper syntax for DateAdd follows:

DateAdd ( DatePart, Number, Date )

DatePart is the part of the date you want to calculate (e.g., minute, day, month, etc.).

Number is the value to increment DatePart.

Date is a valid date-time value that will be used to calculate the new date.

Note In SMS WQL queries, never put the abbreviation in quotes—this is different than when using DateParts with date functions in VBScript.

Also mentioned in this section is GetDate(), which simply returns the current date-time from the server.

And now for some examples:

All systems that have reported a LastHardwareScan date within the last 30 days:

select *  from  SMS_R_System inner join SMS_G_System_SYSTEM on SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_WORKSTATION_STATUS on SMS_G_System_WORKSTATION_STATUS.ResourceId = SMS_R_System.ResourceId where DATEDIFF(dd,SMS_G_System_WORKSTATION_STATUS.LastHardwareScan,GetDate()) < 30

All systems that have been discovered since midnight:

SELECT SMS_R_System.ResourceID,SMS_R_System.ResourceType,SMS_R_System.Name,  SMS_R_System.SMSUniqueIdentifier,  SMS_R_System.ResourceDomainORWorkgroup,SMS_R_System.Client FROM SMS_R_System WHERE (DateDiff(day, CreationDate, GetDate()) < 1)

Combine these queries with the power of setting the query update interval (by default is 24 hours), and you have a very dynamic query to help you with troubleshooting.  You could also combine my previous blog post on How to Create a Collection Based on Advertisement Status, using DateDiff and the LastStatusTime property from the SMS_ClientAdvertisementStatus class.

Converting to/from WMI Date Time

You will find many posts for how to convert a wmi date-time string to a human-friendly date time here’s one example from Don Jones.

First, here’s an example of the wmi date-time string:

Get-WmiObject -class Win32_OperatingSystem  | select __Server, LastBootUpTime

The value for LastBootUpTime will look something like this: 20120718141700.473048-300. This output is very handy for alpha-sort, by the way…
And Here’s Don’s code:

Get-WmiObject -class Win32_OperatingSystem | Select-Object __SERVER,@{label='LastRestart';expression={$_.ConvertToDateTime($_.LastBootUpTime)}}

Notice how Don elegantly converts the string on the fly with the label and expression arguments.

Now here’s an example of using a COM object to convert the current date time to a wmi date-time string.

$wmidate = new-object -com Wbemscripting.swbemdatetime
$date = get-date -format g
$wmidate.SetVarDate($date,$true)
$wmidate.value

Not nearly as elegant, but it gets the job done. When you create objects in ConfigMgr that require a date-time field, you will usually enter a wmi date-time string.

 

Happy Scripting!

 

Greg

 

How To: List Task Sequence Environment Variables and Values

(another encore presentation from my old blog site…)

From the TechNet forums, this is an example for how to display Task Sequence Environment Variables and Values using VBScript:

Set oTSEnv = CreateObject(“Microsoft.SMS.TSEnvironment”)
For Each oVar In oTSEnv.GetVariables
WScript.Echo oVar & “=” & oTSEnv(oVar)
Next

You could save those two lines of code to “ShowTSVars.vbs”, and then when you want, simply run “cscript //nologo ShowTSVars.vbs >vars.txt” to write all variables to vars.txt.

Fix for error in IIS log on MP – (bits_error:,501,0×80070005)

On one of my accounts, we found that hw/sw inventory seems to no longer update.

We found this error in IIS logs on the MP:

(bits_error:,501,0×80070005)

We also noticed that if you go to Server Manager, and open Roles->Web Server (IIS), and select Default Web Site (or the WSUS Administration site), then select BITS Uploads, and then Open Feature, you receive the following message:

“BITS server was unable to read from the IIS Meta-base as it is corrupt. The settings for this virtual Directory have been reset to the BITS defaults. Parameter count mismatch.”

I installed KB2587894, but the error still occurred.

Next, I decided to follow the wisdom of the myITforum and TechNet forums, and reinstall BITS on the server (restart required).  After reinstall, I confirmed that I can open the BITS properties on each web site, and then had to launch mp.msi to get the MP configured properly (the WSUS site seemed to be working OK).  All is well now – inventory is reprorting fine.

Greg

Hotfix Watch: Hotfix rollup for Asset Intelligence compatibility issues in System Center Configuration Manager 2007 SP2: March 2012

http://support.microsoft.com/kb/2691428/en-us?sd=rss&spid=1060

Show Software Update Compliance State for each System in a Collection

We had an internal request to “Show me software update compliance state for each system in a collection, based on an Update List”. There are a couple canned web reports available that got me close, but not exactly what I need.  So here it is in case anyone else is interested.

Here’s a shot of the report:


Here’s the SQL:

declare @CI_ID int; select @CI_ID=CI_ID from v_ConfigurationItems where CIType_ID=9 and CI_UniqueID=@AuthListID 

SELECT rs.Name0 AS MachineName, rs.User_Name0 AS LastLoggedOnUser, asite.SMS_Assigned_Sites0 AS AssignedSite, rs.Client_Version0 AS ClientVersion, 
(CASE cs.Status WHEN 0 THEN 'Compiance State Unknown' WHEN 1 THEN 'Compliant' WHEN 2 THEN 'Non-Compliant' WHEN 3 THEN 'Conflict Detected' ELSE 'Null' END) 
AS State, cs.StatusTime 
FROM v_ClientCollectionMembers AS ccm INNER JOIN 
v_UpdateListStatus_Live AS cs ON cs.CI_ID = @CI_ID AND cs.ResourceID = ccm.ResourceID INNER JOIN 
v_R_System AS rs ON rs.ResourceID = ccm.ResourceID LEFT OUTER JOIN 
v_RA_System_SMSAssignedSites AS asite ON asite.ResourceID = ccm.ResourceID 
WHERE (ccm.CollectionID = @CollID) 
order by rs.Name0

 

Download the report

Greg

ramseyg@hotmail.com

How to: Set Sending Priority of All ConfigMgr Driver Packages with PowerShell

Here’s a quick answer to a post yesterday on myITForum’s ConfigMgr/SMS Email list.

#replace MySiteServer with central site server name,
#and LAB with site code
get-wmiobject sms_driverpackage -namespace root\sms\site_LAB -computer MySiteServer -filter "Priority <> 3" | foreach {
    $_.Priority = 3
    $_.Put()
}

Use this script to set the Sending Priority to Low for all ConfigMgr driver packages. You can see in the script, we query the SMS_DriverPackage class for all Driver packages that do not have a Priority = 3, and then enumerate each one, set the Priority property to 3 (3=Low, 2=Medium, 1=High) and then used the Put() method to save the change. Here’s a brief list of the classes that you can use modify sending priority by simply replacing the class name in the script above:

SMS_PackageBaseClass - This is the base class for all package class. Use extreme care (and testing) when running scripts against SMS_BasePackagClass.
SMS_DriverPackage
SMS_ContentPackage – new to ConfigMgr 2012, this is for Applications, no SDK Doc currently available.
SMS_OperatingSystemInstallPackage
SMS_SoftwareUpdatesPackage
SMS_TaskSequencePackage
SMS_ImagePackage
SMS_BootImagePackage
SMS_Package

You can also use the get-wmiobject –filter command to find a specific package. Just change -filter “Priority <> 3″ to –Filter “PackageID=’LAB00028′”

Bonus TIP: Here’s a quick script to show the count of each Package type using the group-object cmdlet:

#replace MySiteServer with central site server name,
#and LAB with site code
get-wmiobject sms_packagebaseclass -namespace root\sms\site_LAB -computer MySiteServer | group-object __Class | select-object Name, Count

Happy Scripting,

Greg

Win32_Product Is Evil.

This is an encore presentation from my old blog.

I’m a bit of a fan of Windows Management Instrumentation (WMI), but today’s post is a bit of a ‘buyer beware’.  I’ll sum it up, and then provide some detail and give you some ideas of where this can be a very bad thing. For starters, go to a TEST system (Windows Server 2003, Windows Vista or later), launch a PowerShell command prompt (run as administrator so that you have full rights), and run the following command:

get-wmiobject win32_product

(PowerShell is used for simplicity here – this issue occurs in every way you query Win32_Product )

Win32_Product will return some great information about each windows installer-based application.  In fact, you can even view additional properties by running get-wmiobject win32_product | select * . However, even though you called a basic query of the Win32_Product class, you actually performed a consistency check of each installation. Take a look at the Application Log after running the previous command  (event viewer), and you will see something similar to this:

EventID = 1035

Source = MsiInstaller

Details = “Windows Installer reconfigured the product…. “

Each of these entries is for a Windows Installer product, and you can see in the details that each product was ‘reconfigured’ – luckily, if you have healthy Windows Installers, everything should be happy, and the consistency check just confirms that. If however you have systems that are unhealthy, or the installation has been altered in some way, this could cause a failure during the consistency check, or a failure of the application after the reconfigure.

The bottom line is that I expect when I query a WMI namespace, that ONLY a query occurs. Unfortunately, with Win32_Product, that’s not the case.

Here’s a KB article for Vista and Server 2008 that explains a scenario with using Win32_Product as a WMI Filter in group policy – the same info applies when querying Win32_Product manually or with an enterprise systems management tool.

Event log message indicates that the Windows Installer reconfigured all installed applications

http://support.microsoft.com/kb/974524

The article only applies to Vista and Server 2008, but I can confirm that the same thing happens on Server 2008 R2 and Windows 7.

Now that we’ve talked about the general issue, let’s talk about where things can go bad with using Win32_Product in ConfigMgr.

Win32_Product Use Potential Issues
System Center Update Publisher (SCUP) Using Win32_Product in an Applicability rule will cause every system in your site (regardless of collection membership) to run the query, which causes the consistency check/repair. You can’t control this on a collection level. All clients that are configured to the Software Update Point will perform the scan. This custom update automatically replicates to all children sites with Software Update Points.  Each time a scan is run, the Windows Installer consistency check/repair will run.
Desired Configuration Management Creating a Configuration item (CI) with win32_product will cause every system that is targeted with the CI to initiate the consistency check/repair each time the baseline rule is evaluated.
SMS_DEF.MOF (hardware inventory) Untested, but I believe the consistency check/repair will occur each time hardware inventory runs for all clients in the site.
ConfigMgr 2012  App-Model Deployment Types If deploying to USERS, the consistency check/repair will occur when a user attempts to install the software from the software catalog.
If deploying to DEVICES, I the consistency check/repair will occur when the client checks to verify that software is installed.

So as you can see, in the ConfigMgr world, there are many ways to use win32_product that can cause you to have a bad day. So be careful with win32_product!

The good news is that (so far) the message reported is benign, and it doesn’t seem to actually cause a repair. If you encounter a product where this does cause a repair, please send me the info asap.

Greg

ramseyg@hotmail.com

Keeping Up With Microsoft Daylight Savings Time Updates

My colleague Angie and I were searching for “The Latest” Daylight Saving Time Cumulative Update and stumbled onto the following page:

http://support.microsoft.com/gp/dst_hottopics

If you deal with time zones around the world, you may want to bookmark that page for future reference! Unfortunately, Microsoft doesn’t release time zone patches as a separate category, and since they’re not a security update, are often overlooked.

Greg

Follow

Get every new post delivered to your Inbox.

Join 1,045 other followers