Chris Nackers Blog

ConfigMgr and MDT Deployment Solutions

Useful Blogs

User Groups

April 2009 - Posts

Script to Name PC’s using the Serial Number stored in WMI

Ping to Ron’s blog

http://myitforum.com/cs2/blogs/rcrumbaker/archive/2009/02/23/scripted-naming-pc-using-the-serial-number-stored-in-wmi-during-configmgr-osd-task-sequence.aspx

Very cool!

Dealing with Laptop Standby Power Mode – Part 2

This is a continuation of Part 1 where i discussed a script to configure the network adapters to allow for WOL while in stand-by mode or hibernation mode.

Is this post we’ll address Issue #2

Issue #2

Once you have resolved the issue of being able to bring the devices out of stand-by mode, then you ideally want to keep those machines up indefinitely or at least until the application installs complete.  So then you need to either have a group policy or “something” that configures the laptop to stay on after being imaged.   I’ll cover this issue in Part 2.

 

Well here we are in Part 2, so lets address keeping the machines on.  It’s great that we have a way to at least wake up the machines from stand-by mode, but it would be even better if we could keep them from going into stand-by to begin with. 

I was able to address this issue in our environment by creating a SMS package that configured the laptop power scheme to be “Always On”.  Now once a user logs in and changes the power scheme, they could override my setting, but that is fine, my primary concern is dealing with the laptops after they are deployed or refreshed.  So once i’m done with what i need to do, the users can adjust the power settings as needed.

I simply created a new package called “Power Config” that has a program called “Always On” that is configured to run unattended.  My command line for my program is:

C:\WINDOWS\system32\powercfg.exe /SETACTIVE "Always On"

So, by running it this way, i don’t need to have files on the distribution point for the package to work, right? Well yes and no :)  If you are simply deploying this program through the normal software distribution process, then yes, correct you do not need to have files on the distribution point since it’s simply calling a command line that calls a local file. 

However, there seems to be a small bug if you are deploying this package through MDT/SMS and are calling the package as part of the OSD process, in my case through customsettings.ini again.  So i now have a Packages002=ABC0001:Always On.

However, without any package files actually on the DP, the customsettings.ini process gets a little cranky and you will see the following result in osdswdprogramexec.log

image

Basically stating that it can’t find the distribution point for the package.  Now i’ve seen this before if you don’t have your OSDMP and OSDSiteCode properties configured in customsettings.ini however, i know that i do and that they are correct. 

So i simply added a small batch file so the DP has something, and then set the source directory for the package to a folder with that batch file and then updated the DP’s.  Once that had been completed, i ran the process again and my install went through just fine.  So installing as a package through SMS, worked great without any source files.  However, when i tried to call the package through customsettings.ini then i needed to have some files in the DP in order for the package to complete successfully. For whatever reason.

Now that i’ve got this package working through customsettings.ini, it’s again part of the tail end of my imaging process and now not only can i power on my machines if they do go into stand-by mode, but i have been able to configure them to not go into stand-by mode by default after being imaged so hopefully i won’t have to wake them up to begin with.

And that’s it! Hope this helps.

Creating a Collection Query based upon Hardware Inventory

Credit to Dave Fuller for which this information is based upon.

I posted previously on how to use a SQL statement for updating collection membership.  I thought I would show an example this time around.

 

So, we want to create a collection that is based up on hardware inventory having run in the past 5 days.  So if the client hasn’t run hardware inventory in the past 5 days, i don’t want to see him in my collection.

So lets create the collection.

image

Now lets create a query statement for that collection.

image

Verify that the rule has no criteria to it.

image

Now we need to identify the “CollectionID/Store Name”

image

Which we can see is “SZ000389”

So now lets run a query in the query analyzer to find the CollectionID as it’s listed in SQL.

image

Now we have been able to tie the CollectionID that we see in the admin console with the ID that is listed in SQL, which is the ID we will need to update the SQL command.

Here is the query we want to update the collection with:

select sys.ItemKey, sys.DiscArchKey, sys.Name0, sys.SMS_Unique_Identifier0, sys.Resource_Domain_OR_Workgr0, sys.Client0
from System_DISC AS sys
JOIN WorkstationStatus_DATA AS wks on sys.ItemKey = wks.MachineID
where DATEDIFF(dd,wks.LastHWScan,GetDate()) < 5

This query will only show clients that have run a hardware inventory within the past 5 days.

So lets run this in the query analyzer and make sure we can return some valid results. I blocked out some of my data on this screenshot.

image

Ok so we validated that my query actually works and returns valid results. So lets update our collection with this query so we can use it.

So we need to run an update command and replace the current SQL query for the collection with the one i want to use.

I know that my CollectionID is ‘917’ in this instance. So my update query is as follows:

Update Collection_Rules_SQL
set SQL = 'select sys.ItemKey, sys.DiscArchKey, sys.Name0, sys.SMS_Unique_Identifier0, sys.Resource_Domain_OR_Workgr0, sys.Client0
from System_DISC AS sys
JOIN WorkstationStatus_DATA AS wks on sys.ItemKey = wks.MachineID
where DATEDIFF(dd,wks.LastHWScan,GetDate()) < 5'
where CollectionID = 917

So once i run that command i should see the following result.

image

Now i can go back to my admin console and update the collection membership.

image

And now when i look at my collection, I should see the same results that i saw in the SQL query analyzer.

Now you could also flip that query around and show clients that haven’t reported in a certain amount of days or whatever you are trying to achieve.

Dealing with Laptop Standby Power Mode – Part 1

Often as you automate things, other nifty glitches you didn’t see coming creep up. As I’ve been improving and streamlining our imaging process, I removed a portion of the OSD process that would automatically log into the machine after imaging for a timed period.  This caused some issues and it had timed reboots and could potentially effect an on-going installation, however it worked great for any applications that required a user to be logged in to install.  I removed that part of the process awhile back, and on the last large refresh we did, we encountered a new issue as a result.  Our laptops were going into standby mode, since that is the default power configuration for a Laptop in Windows XP whenever a user has NOT logged into the machine, ever.  If you log into the machine, then the game changes.  However, for our scenario, we were imaging machine(s) and no one would logged into that machine be it a physical person or a scripted login after imaging.  So that presents 2 issues.

Issue #1

A normal WOL request will not wake a device from stand-by or hibernate mode without first configuring that network device to allow that device to bring the computer out of stand-by or hibernate mode.  Oops.  Now i can’t wake up my machines once they do go to sleep.

Issue #2

Once you have resolved the issue of being able to bring the devices out of stand-by mode, then you ideally want to keep those machines up indefinitely or at least until the application installs complete.  So then you need to either have a group policy or “something” that configures the laptop to stay on after being imaged.   I’ll cover this issue in Part 2.

Ok, so what do we do about stand-by mode?

I was given a script from a friend, so I credit the original author of this script for the script, however I don’t know who that actual author is.  So if you are him/her, thank you! :)   This script is a vbscript that identifies the network adapters on the machine and configures them to allow them to bring the device out of stand-by mode.  As in the screenshot below.

nic

This script needs to be created as a SMS package and the configured to run unattended. 

Now since I use MDT to run our OSD process, rather than waiting for the package to come down through normal software distribution processes, and because i want to ensure that this package runs as soon as the imaging process is done, I deploy the application through customsettings.ini.  This allows for the use of the SMS distribution points and for the execution history to be a valid SMS application, well because it is coming from SMS, but also allows for an instantaneous install after the imaging process has completed.  Essentially it becomes part of the imaging process. 

In my case at this point i only want to target laptops with this script, so i’m going to take advantage of the chassis type query that is available within customsettings.ini 

So the necessary settings for this to work in customsettings.ini are as follows, now i have stripped this down to the absolute basics needed to do this type of query to show you.  I utilize this and many other queries to assign packages through customsettings.ini.

=================================

[Settings]

Priority=ByLaptopType

[ByLaptopType]

Subsection=Laptop-%IsLaptop%

[Laptop-True]

Packages001=ABC0001:WOL Standby Config Script

=================================

Your “Packages001=ABC0001:WOL Standby Config Script” is basically Packages001, Packages002, how ever many you have, followed by the packageID:Program

So basically:

Packages001=PackageID:Program

Pacakges002=PackageID:Program

This method allows me to install the script as part of the imaging process on the tail-end ensuring that my network adapters are configured to allow WOL just in case they do go into stand-by on me, or if the user puts the computer into stand-by.

Below is the attached script for configuring the network adapters.

I will covering keeping the machines awake in Part 2.

Creating a Collection Query From SQL

Credit to Dave Fuller for which this information is based upon.

Creating a collection query that is based upon SQL can be done.  It’s a little complicated, but not all that bad once you’ve done it a few times.  There are many times where you have a fantastic SQL query you would love to use, but cannot figure how to get that same query in WQL.  When you create a collection query in the administrative console, it’s created in WQL and translated to SQL.  It is possible to create a SQL query and simple update a collection with that new SQL statement to process the collection membership.

Things to understand:

What you see as the “CollectionID” in the admin console is actually the “SiteID” in the SQL database. 

The CollectionID in the SQL Database, is actually the number of the collection as it was created, so if the last collection you created was your 965th collection, it’s CollectionID in SQL would actually be 965, even though the CollectionID you see in the admin console is “ABC00012”

If you have it setup so that you can see the node information, you will see the “Store Name” ID for that collection that you can use as well.

This process involves a few steps:

1) Create a target collection with a blank query, aka don’t define anything in the query statement

2) Get the collection SiteID (as it’s referred to in SQL) otherwise known as the Collection ID in reports, or the Store Name in the node information tab in the admin console

3) Run the following query in SQL query analyzer to find the CollectionID as it’s listed in SQL

Select CollectionID, SiteID from Collections where SiteID= ‘CollectionID/StoreName as seen in the console’

This will return the CollectionID you need to update the SQL statement with

4) Run the following update command to insert your SQL statement in the SQL statement query portion of the Collection.

Update Collection_Rules_SQL
set SQL = ‘YOUR SQL STATEMENT’
where CollectionID = ‘X’

5) You can run the following query to identify that your SQL statement is in fact in the correct place now

select SQL, WQL
from Collection_Rules_SQL
where CollectionID = ‘X’

This will also show you the WQL statement for any collection you want to see.

6) Update your collection to see if you have gotten the intended results

7) I would highly recommend you make sure you SQL statement works before inserting it into the collection SQL statement

 

IMPORTANT NOTE: If you modify the query in the admin console, you will overwrite the SQL statement you created.  You will have to re-update the SQL statement through query analyzer if you accidentally modify the query through the console.

Mark Cochrane’s RegKeytoMof

I’ll just ping Sherry’s post on this:

http://myitforum.com/cs2/blogs/skissinger/archive/2009/04/13/mark-cochrane-s-regkeytomof.aspx

 

Very cool tool for grabbing registry info for MOF edits you want to do.  Read her post for more information.

Debugging SMS 2003 OSD Processes

One of the tricks i’ve learned over the years is a way to debug your rules and settings for your ZTI OSD process.  If you make a small change, sometimes you just want to see if that change or rule is processed correctly.  Which means you don’t want to have actually do a full ZTI every time you want to test a change.  If you just want to test a change to your customsettings.ini you can create a quick script and copy a few files to a location and test.  The end result will be the logs files you can review to verify the changes.

 

If you create a folder called “ZTI_Debug”, and then copy your customsettings.ini, ZTIGather.wsf, ZTIGather.xml, and ZTIUtility.vbs into that folder.  Then you just need to create a batch file to run the process.  The batch file should contain the following lines:

:Start:

if exist c:\minint\nul rd c:\minint /s /q
cscript.exe ZTIGather.wsf /debug:true

:End:

 

Now, whenever you run that batch file on the target machine or VM, it will process your ZTI rules/queries and output the result to the logs files.  On the client under OSDLOGS, you will see the BDD.log, variables.dat, and ZTIGather.log.  You can review those logs to verify that your cs.ini is processing successfully, or that your SQL queries are running properly.  I often use this process to verify that my packages are being correctly identified, that desktops are getting desktop packages, and laptops are getting the laptop specific packages, etc or test any other changes to my cs.ini that doesn’t require a full refresh to test.

Just a great way to quickly run the rules and process your cs.ini rules without actually doing a refresh.

 

Hope this helps…

PXE Boot: File not found/TFPT Error – File not Found

Recently configured RIS on one of my secondary sites.  I was getting a File not Found error when i attempted to PXE boot a VM.  This the error i was receiving.

PXE-T01: File not found

PXE-E3b: TFTP error – file not found

 

untitled 

Turns out that RIS/WDS was looking for pxeboot.com which didn’t exist in the remoteinstall\boot\x86 folder on my secondary site.  That’s fine, i don’t need to use that anyways since i’m running in legacy mode.  So i simply reconfigured WDS to look for startrom.com and then i was able to PXE boot my VM and image my machine using the SMS installation CD.

image image

Microsoft Deployment Workbench Error – “no tasksequences.xml”

I was recently working on a few things when all the sudden i couldn’t load the LiteTouch_X86.iso without getting an error saying there were no task sequences available.  Now i know all my task sequences were available and up and running and i had verified that tasksequences.xml was in fact in the lab share.  I searched all over the internet and couldn’t find any information on the error message. 

mdt_error

mdt_error2

However i did figure out how to resolve the issue.  It turned out that one of my task sequences was corrupted. I started going through all my task sequences and making sure they opened correctly in the workbench and looked to be configured properly.  I ran into one of my TS’s that would crash the MMC every time i tried to view it.  I deleted that task sequence from the workbench and low and behold the LiteTouch CD starting working again.  I recreated the TS from some backups i had and everything appears to be working correctly again and i can see my TS’s from the LiteTouch CD now.  Weird.

Interesting little bug.

Identifying packages missing from a distribution point

You can use this quick query to find any packages that are missing from one of your DP’s.  This is  quick way to find out if you simply forgot to distribute a package to a DP, or if there is something else keeping it from distributing.  If you resend it to the DP and it still doesn’t show up, then you might need to do some further investigation into the logs and inboxes.

 

image

 

Here is some more in-depth information from Matt Broadstock’s blog.

http://blogcastrepository.com/blogs/mattbro/pages/687.aspx

Posted: Apr 08 2009, 01:53 PM by cnackers | with no comments
Filed under:
Client Center V2 Released

Guess this was released back in Jan. But I didn’t catch it until now.  Very cool utility that i use every day.

 

http://sourceforge.net/project/showfiles.php?group_id=157573&package_id=307270&release_id=655722

 

Update:  Alt + F4 will kill the pop-up count down box that you receive every time you launch the application.