Month: March 2011
Script to Check Devices Without Drivers
This is a quick script that I wrote to identify if a remote computer has a device without a driver installed.
'========================================================================== ' NAME: DevicesWithoutDrivers ' AUTHOR: Nick Moseley, https://t3chn1ck.wordpress.com ' DATE : 3/30/2011 ' COMMENT: Connects to WMI on a remote computer to check for devices without ' a driver installed. '========================================================================== Option Explicit Dim oWMI, sComputerName, colItems, oItem sComputerName = ucase(InputBox ("Enter Computer Name", "Name", ".")) Set oWMI = GetObject ("winmgmts:\\" & sComputerName & "\root\cimv2") Set colItems = oWMI.ExecQuery ("Select * from Win32_PnPEntity where status = 'error'") For Each oItem In colItems WScript.Echo "Name: " & oItem.Name & "; status = " & oItem.status Next
Task sequence – Condition to execute only if NOT installed
<< Edit: Prior to following instructions in this posting, please review http://support.microsoft.com/kb/974524 regarding Vista and Server 2008 >>
I frequently use task sequences to quickly and easily chain multiple, unrelated, software distributions together for deployment during our business scheduled maintenance window. One of the powerful things about using a task sequence is that a particular software install task can be limited to only run if certain criteria is met, such as only run the install of hotfix XYZ if Outlook 2010 is currently installed (otherwise skip). This can be done by using a WQL query that says “Select * from Win32_Product where Name = ‘Microsoft Office Professional Plus 2010’“.
In working on a new distribution of updates, I was met with a new situation for limiting software execution to only run if a particular software was NOT installed. Still using the same WQL query as an example above, it simply doesn’t suffice to replace the equals with “not equals” or “<>” because there will always be at least one installed software that is not Office 2010. Thus the logic fails and the task would execute…but we want it to NOT execute.
Instead, I used an If condition – that If none of the WQL query is true (e.g. installed) then DO execute. I tested this on a computer that already had the software (it skipped) and one that did not (it ran). So all is good! It was just a new thing I had not done in a task sequence before that I thought I’d share with everyone…..
Missing SQL 2005 Model Database
We went to install an SRS database on our SCCM 2007 server for FEP 2010, but when attempting to create a new report server db, we were getting error 1807 “System.Data.SqlClient.SqlException: Could not obtain exclusive lock on database ‘model’. Retry the operation later.” It was discovered that the install failed because the Model database had become corrupted and detached. And more unfortunately someone removed backups of the database (lesson learned: do monitor the backups of your system databases!)
Our initial attempts to restore Model was to ‘import’ the model db from another server with the exact same SQL version. While the import was successful and the database was automagically moved into System Databases, the error continued. Knowing that a service pack in effect reinstalls SQL, we upgraded to SQL 2005 SP4. There was still no joy. A proposed solution was to do a cut-over of SCCM to a new server with a clean install of SQL and SCCM. However, in my experience, that would have caused more issues resulting a longer drawn out resolution path. So I wanted to avoid that. Based upon a forum thread somewhere, we had indications that the error was now being caused by Model not having the proper system database ID value. To confirm this, we used a Microsoft support case.
The issue was caused by the `model` db having the incorrect database_id. It was registered as 7, but all system databases must have the specific db_id, with model being ID 3. Which means that model was actually a user database, despite being listed in the System Databases category. To fix the issue, all user databases, model, and msdb were detached. Then attaching them in order model, msdb, user dbs resulted in creating model with ID 3 and msdb with ID 4. The ability to create databases was then fully functional again…
MMS 2011 Here I Come!
I’m looking forward to another great year of learning and community at the Microsoft Management Summit. It is alway a wonderful opportunity to engage with other professionals. I hope to meet you there next week!