Incremental Machine Naming In MDT

Posted by beakersoft | Posted in MDT | Posted on 11-03-2010

7


I have recently done some work with the Microsoft Deployment Toolkit, the successor to RIS and kind of extension to WDS. I used RIS quite extensively in the past, and while i did have it working quite well, it was a nightmare to actually setup (half the time it was easer to build 70 machines than to get RIS working!).  WDS and the MDT change all that.

It is now easy to build, and customise all parts of your OS deployment using these technology’s, but as I started using it there was one thing missing from it that old style RIS used to have.  Incremental naming of machines as you build them.

In RIS is was a simple matter of putting a variable into it’s settings, and it worked no problem, now however even though there are hundreds of new options naming in this manor is not one of them. I did a search around and come up with this article at Michael Niehause’s blog.

I have re-written the code from this posting in vb.net, i also had to make a couple of changes to my rules file to get it to work. The only differences between my code and Michael’s is mine is in vb.net and his is c# and mine does not add the machine account with a description to the active directory, I just let the install process do this for me.

The Code

Fire up a new web service project, and add this function to it:

WebMethod(Description:="Returns a new Computer Name to use." & _
" Inputs dns domain, a prefix and OU")> _
Public Function GetNewName(ByVal DnsDomain As String, _
ByVal NamePrefix As String) As String

'build the search, based on the passed domain, then the name prefix
Dim adRoot As New DirectoryEntry("LDAP://" & DnsDomain)
Dim dirSearch As New DirectorySearcher(adRoot, "(name=" & NamePrefix & "*)")
Dim existingNames As New Dictionary(Of String, Guid)()

'loop through the results
For Each result As SearchResult In dirSearch.FindAll()

'get the name, and create a guid holder
Dim strCurrName As String = result.Properties("name")(0).ToString.ToUpper
Dim netbootGuid As New Guid

'if we have a guid use that with this name
If result.Properties("netbootGuid").Count > 0 Then
netbootGuid = New Guid(DirectCast(result.Properties("netbootGuid")(0), Byte()))
End If

'add details to the dictonary, if they are not already there
If Not existingNames.ContainsKey(strCurrName) Then
existingNames.Add(strCurrName, netbootGuid)
End If

Next

'now try and get the next name in sequence
Dim strNextName As String = Nothing

'loop through all the avalabe machine numbers up to max of 999
For i As Int32 = 1 To 999

Dim strNameTest As String = NamePrefix & i.ToString("000")

'is this name in the list, if not we have our name
If Not existingNames.ContainsKey(strNameTest) Then
strNextName = strNameTest
Exit For
End If
Next

'return our new name
Return strNextName

End Function

What its doing

All the code is doing is querying your active directory for machines named like you specify, that end with a unique 3 char number (from 001 to 999). Once it finds one it returns the new name back to you. The good thing about this code is it will re-use any machine you have retired, so no numbers go to waste.

You pass the function the dns name of your active directory and the first part of the computer name (e.g. CA-HR-), and that’s it.

Calling the naming function from MDT

Once you have done your web service and it is callable from your web server, you need to alter your MDT rules file to call it and get a new name. This is all the sections you will have to fill in to get it to work, you will probaly have a lot more in your production system:

[Settings]
Priority=Default,GetNewName
Properties=DnsDomain, NamePrefix

[Default]
SkipComputerName=Yes
DnsDomain=mysite.comp.co.uk
NamePrefix=CA-HR-

[GetNewName]
WebService=http://your-web-server/WDSExtras/WDSNameExtras.asmx/GetNewName
Parameters=DnsDomain, NamePrefix
OSDComputerName=string

All that is happening here is you are telling MDT to run an extra section called GetNewName, and that section is going to call your web service with 2 parameters (created in the default section) and then set OSDComputerName (the key that holds the machine name) to the returning string.

Troubleshooting

Odds are you wont get this right first time, but MDT writes does quite a good job of logging what it has done. On a machine your have deployed if you look in C:\MININT\SMSOSD\OSDLOGS you should be able to find the section that is trying to call the web service, and see what it did, and any errors if they occurred

Folder2Page Plugin

Posted by beakersoft | Posted in Programming | Posted on 11-02-2010

1


Just a quick post to point you in the direction of my latest (ok second ever!) plugin for wordpress. Its called folder2page, you can check out more info at beakersoft.co.uk/folder2page

Its a simple plugin that will allow you to use a directory of images you have on your web space as a simple gallery on page in your blog. There seemed to be a lot of plugins out there for getting images from flickr and other image hosting services, but not much if you wanted to get at the images your self.

Any comments, suggestions etc please let me know!

Spiceworks 4.5 Review

Posted by beakersoft | Posted in spiceworks | Posted on 08-01-2010

1


My post I did some time ago on Spiceworks has recently got quite a bit of attention, so i have decided to check out the latest version (4.5).

I haven’t used Spiceworks since version 2, I was quite impressed with it back then and I know the product has developed quite a lot in that time, so I was hoping it has improved even more. As in the previous post i have done a few timings, and noted what the scanning of the network has managed to find.

This test was completed in a completely different environment than the previous tests, so its not really fair to compare this version with say version 2. Spiceworks was installed to a Dell 1850 server, running windows 2003 with 2gig ram. I scanned 6 subnets in all, containing lots of different devices (pc’s, phones, routers etc). Clients are mainly Dell optiplex’s running Win XP, printers mainly HP.

Test Results

Spiceworks 4.5
Total Network Scan Time 4 hours 15 mins
Total devices discovered 446
Workstations discovered 251
Servers discovered 77
Printers discovered 26
Unknown devices discovered 32
Other devices discovered 60
Total Software recognized 2155
Applications recognized 1123
Services recognized 457
Hotfixes recognized 575

Test Conclusions

Speed
The first thing to hit me was the scanning speed, I had given spiceworks a lot more work do to then in the previous tests, but i was still a little disapointed at the time it took to initially scan the network. There was a lot of kit to find and identify, but it took a little longer than I would have thought

That said, the initial scan is a one of event, and subsequent ones once the majority of devices have been found are nice and fast. I’m not sure if the speed is really that big an issue, I would prefer to sacrifice a bit of scan time to get more accurate results.

Hardware Results
So, did Spiceworks actually manage to identify all the hardware on the network, and work out what it was. For the most part, yes it did. Unless there was a connectivity problem with the machine, it did manage to work out what it was. I correctly identified all the workstations and servers, and managed to extract out the information on the hardware.

It does tend to class most of the network kit as ‘Other Devices’, i’m assuming this is because it cant authorise its self on the device, but i’m not sure, it just seems to see them as http devices. I was going to try and scan a test device, but there is no scanning option to pass a telnet password to a box, even if you could I’m not convinced it would be able to tell what it was

It did however, manage to recognise all the printer correctly, and in most cases it was reporting back information on the status of the device correctly

Software Result
This is one area where I found it difficult to tell if Spiceworks was working right or not, as I dont have an up-to-date list of the software on the machines. To try and test it I picked a couple of machines at random and looked at the software on them, it managed in both cases to get pretty close to what was on the actual box. I like the feature of the software list that tells you the oldest and newest versions of things, this would be very handy if you are rolling out some software and want to make sure everything has got the correct version

Interface and Features
As I have not used Spiceworks since version 2, i’m not sure what is new this version and what has been in for a while. I do like the time line function, it would be nice if it could update in real time but then you would be scanning your network all the time.

The reporting system seems a lot more customizable, as you can now not only decided what you want to see, but organise the columns on the reports as well, and filter down what you want to see. The export options are pritty standard, but I would have expected to see an xml option along with the others. It is missing some advanced reporting features (grouping, custom fields etc.) and has no support for generating graphs, but those are probably not that important.

The network map is a nice idea, but i’m not really sure what use it would be, normally you would probably only be interested in this information for your network kit, and Cisco already have some specific tools to do this.

Summing Up
While the product is not perfect by any means, for a free bit of software you cant really get much better for a small or medium size organisation. The hardware/software inventory is accurate, if a little slow and does seem to struggle with network kit.

The interface is very easy to use, and its easy to customise the dashboard so you can see the information that interests you. The adverts do get in the way a bit sometimes, but you can always pay to get them removed.

All in all this is another very good version, and if your in the market for some network auditing/reporting tools, for the (lack of) price this is one of the best.

My First Book Review

Posted by beakersoft | Posted in Book Review | Posted on 22-12-2009

1


The good people over at packt publishing recently sent me a copy of Learning SQL Server Reporting Server 2008 Reporting Services by Jayaram Krishnaswamy. So here is my first ever book review. Hope you find it interesting –

SQL reporting services has been part of the SQL Server suite for a few years now, and this book covers the latest version 2008. As stated by the back cover of the book, it is aimed at beginners, but also has plenty of useful information for old hands, with all of the topics covered in the book backed up by code examples and screen shots.

As with most books I have read on any reporting engines, a basic knowledge of SQL server, and the SQL language will always help a great deal when reading the book. Also a couple of the topics hit on using the reporting service from your own applications, so you will need some programing know how to get anything from these chapters.

The book is written in a very easy to read way, and unlike some technical books manages to seems light enough to enjoy reading, but everything is still explained in an accurate and concise manner.

There are 2 sections given over to using the new report Builder (something i have never used before), explaining how it is set out like excising Microsoft office application, and information and examples of all the other new features in this version. The section on using Crystal reports is interesting, and although i found it a little short, it is something i have never seen before in a SQL reporting services book, they never seem to touch on the subject at all.

The chapters at the end of of the book are about programing into/around the reporting engine, I found the one about Progammatically Creating a report particularly interesting, it takes you through all the necessary steps to create your own .rdl, using the XMLTextWritter class. Might not be very interesting if you just want to author reports in the builder, but if you wanted to take it to this level the information is very helpful, with full source code in the book.

As well as all the new features for 2008, all the existing one are covered (images, sub-reports, parametrised reports, datasets, formatting, graphs etc) in good detail, with examples and screen shots available for each topic.

All in all not only enjoyed reading this book, i took quite a bit of useful information out it as well, some of witch i think i would struggle to find in other publications. A good read all round.

Buy this book from Packt.com now!