NEBytes July event: SharePoint, IIS Media Services 4

This month NEBytes has teamed up with the SharePoint User Group UK – Simon Tyler is presenting on SharePoint Best Practices, and NEBytes’ own Andrew Westgarth will be covering IIS Media Services 4.


The event will be held in Claremont Tower, Newcastle University on Wednesday 20th July at 18:30, and is sponsored by ffA.


For further details, and to register, head over to Eventbrite.

Using PowerShell to calculate vSphere 5 licenses

Users of VMware will likely be aware of the change to the licensing model for vSphere 5 (if not, they’re running some webinars), and I’m sure that a lot of organisations are busily calculating how that is going to affect them going forward. Hugo Peeters has produced a script using PowerShell and PowerCLI to calculate your vSphere 5 license requirements. Very handy.


I’d suggest running Hugo’s script against your existing infrastructure, and if the results aren’t to your liking you might want to grab a 60 day eval of vCenter CapacityIQ to see whether you can get away with less than what you’re currently running!

Pre-staging Computers in Active Directory for WDS with PowerShell and Quest AD cmdlets

One of the most common issues when buidling computers with Windows Deployment Services (WDS, and RIS before that) are typos in the GUIDs used to net-boot the PCs. When you’re entering them by hand as you pre-stage the computer objects in Active Directory it’s very easy to make mistakes, especially when you’re entering a lot of them. It’s also extremely time consuming if you have to boot each machine to the point of PXE displaying the MAC and GUID – that’s why the smart move is to request that information from the supplier, preferably before they deliver the machines.


Anyone who has pre-staged a computer object before will be aware of the jiggery-pokery that goes on with switching round the first half of the GUID, so that when you view it later in ADUC, you see something significantly different to what you typed in. It appear that this conversion is done by the GUI when you create the object, so when you’re adding them programatically, you need to change the format yourself.


Microsoft published a VBScript function to reformat the GUIDs so they could be added to AD by a script, but I haven’t seen similar in PowerShell, so here it is:


function flip-guid ([string]$g) {
    $g = $g.replace(“-“,””).replace(” “,””)
    -join $g.substring(0,16).tochararray()[6,7,4,5,2,3,0,1,10,11,8,9,14,15,12,13] + $g.substring(16,16)
}


The function takes the GUID as a string and first removes any dashes or spaces (since I’ve received them from suppliers with both at different times). Next it converts the first half into an array of characters, selects them back in the new order and uses the join operator to make them back into a string, to which it concatenates the second half, unchanged from the original. As with most things in PowerShell it could be reduced down to a single line, or expanded further to enhance readability.


So, given the ability now to change the format, I use Quest’s AD cmdlets (if you haven’t come across these before, take a look now!) to create the computer objects. Assuming that you have a CSV file containing the new PC’s name and GUID, just do this…


Import-Csv newpcs.csv | foreach {
   New-QADComputer $_.name -ParentContainer “SomeOU” -ObjectAttributes @{netbootguid = ([guid](flip-guid $_.guid)).ToByteArray()}


That’ll leave you with a load of new computer objects ready for WDS. :-)


NB. It’s likely that the code snippets above have been wrapped to fit the page layout. In the function there are only two lines – everything from “-join” to the end is the same line. In the foreach scriptblock that’s just a single line.

Free PowerShell books

Way back in December 2009 I wrote a post entitled Where to start with PowerShell which listed free resources, including a couple of ebooks. Well the PowerShell community has been busy since then, bringing the number of free ebooks on the subject up to 9. Jason Hofferle has helpfully compiled them into a single blog post: List of Free PowerShell eBooks


These books are authored by some of the brightest and best names in PowerShell, so I can’t recommend them highly enough.