Network issues with a Raspberry Pi

I know, I know, it’s a little off topic but I’d struggled with this for quite a while before solving it so hope to save the pain of others with the same issue.

I recently installed a Windows Media Centre at home, and it’s fantastic. Shortly afterwards I bought a Raspberry Pi, connected it to a television in another room of the house and install RaspBMC on it. I then connected it via my home network to the shares on my always-on Media Centre (initially mapping to hostnames but later on switching to mapping via IP); this gave me access to all the media on the Windows device, except for the live television.

Everything worked great for a whole 24 hours until I started seeing the error “10060 Connection Timed Out” on the Raspberry Pi when trying to access the Windows shares, although my other Windows devices could access the same shares. Assuming it to be a fault with Samba on the Pi device I tried restarting the Pi, and re-establishing the mount points/mappings – but none of this made any difference; bizarrely, the only solution was to restart the Media Centre in order for the Pi to get network connectivity back – this does not really something that seemed that logical because the fault surely lies within the Pi.

In the end, after 2 weeks of frustration and Media Centre rebooting, I wondered if the fault could lie in the Pi not registering itself correctly with the SMB browser service on my network; because the Media Centre was always switched on it was fairly safe to assume that it was the Master Browser. By disabling the “Computer Browser” service on my Media Centre I was preventing it from becoming the Master Browser, and this simple change solved all my networking issues between the Media Centre and the Raspberry Pi!

So if you are experiencing similar issues, try disabling this service and then rebooting by the Windows computer and the Raspberry Pi, hopefully this will solve it for you.

Microsoft Technologies Infographic

There’s a great infographic that Microsoft recruitment often use to illustrate the breadth of Microsoft technologies and how they are connected to each other. I used it several times in the past in presentations with clients during my time working at Microsoft and it never failed to impress; I came across it again recently and thought it was worth sharing.

Here it is in it’s full glory:

A high resolution version is available here

I noticed that it’s missing a couple of rather important products such as SQL Server and the entire range of Windows Server so it looks like this infographic is focussed more at the consumer than enterprise. Still, it’s interesting stuff!

Windows 8 and Windows Server 2012 KMS Keys

I’ve had to go look for this information twice this month, both times struggling to remember how I found the information, so it seems only right to blog the link for both myself and anyone who is searching for it.

The below table lists all the KMS installation keys for Windows 8 and Windows Server 2012.  You can use these keys to complete an installation of Windows and also to activate an already installed instance.

Operating system edition KMS Client Setup Key

Windows 8 Professional

NG4HW-VH26C-733KW-K6F98-J8CK4

Windows 8 Professional N

XCVCF-2NXM9-723PB-MHCB7-2RYQQ

Windows 8 Enterprise

32JNW-9KQ84-P47T8-D8GGY-CWCK7

Windows 8 Enterprise N

JMNMF-RHW7P-DMY6X-RF3DR-X2BQT

Windows Server 2012 Core

BN3D2-R7TKB-3YPBD-8DRP2-27GG4

Windows Server 2012 Core N

8N2M2-HWPGY-7PGT9-HGDD8-GVGGY

Windows Server 2012 Core Single Language

2WN2H-YGCQR-KFX6K-CD6TF-84YXQ

Windows Server 2012 Core Country Specific

4K36P-JN4VD-GDC6V-KDT89-DYFKP

Windows Server 2012 Server Standard

XC9B7-NBPP2-83J2H-RHMBY-92BT4

Windows Server 2012 Standard Core

XC9B7-NBPP2-83J2H-RHMBY-92BT4

Windows Server 2012 MultiPoint Standard

HM7DN-YVMH3-46JC3-XYTG7-CYQJJ

Windows Server 2012 MultiPoint Premium

XNH6W-2V9GX-RGJ4K-Y8X6F-QGJ2G

Windows Server 2012 Datacenter

48HP8-DN98B-MYWDG-T2DCC-8W83P

Windows Server 2012 Datacenter Core

48HP8-DN98B-MYWDG-T2DCC-8W83P

In the source link below you can find the KMS keys for Windows Vista, Windows Server 2008, Windows 7 and Windows Server 2008 R2

Source: http://technet.microsoft.com/en-us/library/jj612867.aspx

Introduction + Scripting Snippet #01

I know, I know, the blog’s been neglected lately. It’s not my fault that work, holidays, Christmas, New Year’s Eve, and everything else at came at once! I need to make yet another New Year’s resolution: blog more.

As a die-hard VBScript-er I never really saw the need for me to learn Microsoft PowerShell; I got along just fine with VBS and could do pretty much anything I needed to, admittedly it had a few quirks and limitations meaning that you had to sometimes write less than ideal code just to get around some of the hurdles. Well, my opinion on all this has now changed: PowerShell is just way better than VBS, and much easier to write – and why write 20 lines of VBS when you can achieve the same with a single line of PowerShell? :-)

At my current project PowerShell is the preferred scripting language meaning that I was pretty much obliged to learn some PowerShell and check my VBS at the door! I’ve been surprised at how quickly I was able to pick up the basics, and it’s been a fairly straightforward task of learning how to use it; I’m still a long way of from being an expert though. Starting now, I am going to share some PowerShell code snippets and functions that I think will be useful to others – feel free to comment on these posts with help/suggestions/changes/ridicule etc. – but remember: this is a learning process! So here we go…

Ever need to check if your script is running with administrative privileges? The below function will do just this, returning $true if it is and $false if it isn’t. Add the function to your script and use it as shown below – don’t forget that functions go at the top of a PowerShell script (the opposite of how I always wrote VBS!).


$boolAdminRights = funcCheckAdminRights
Write-Host $boolAdminRights

 

Function funcCheckAdminRights
{
     $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
     $windowsPrincipal = new-object 'System.Security.Principal.WindowsPrincipal' $windowsIdentity
     $AdminRights = $windowsPrincipal.IsInRole("Administrators")

     If ($AdminRights)
     {
          # Admin rights OK
          Return $True
     }
     Else
     {
          # Not got admin rights
          Return $False
     }
 }

Scripting the Creation of Windows 7 Libraries

Ever since Windows 7 was first released in Beta, one of the common grips amongst the techies doing deployment projects was how to automate through scripting, and therefore MDT, the creation/modification of the Windows 7 Libraries.  I’ve seen a few different solutions but they were all rather ugly as they involved hacking the registry using a process discovered (no idea by who) through trial-and-error.

I never liked these hacks so would always steer customers well away from them (as well as towing the Microsoft line of “this is an unsupported method” etc.).

Well, fret no more, because it seems that Microsoft finally got round to creating such a tool – and even published the source code for it!  You can find the MSDN documentation for SHLIB.exe here: http://msdn.microsoft.com/library/dd940379

As a heads-up, here are the usage instructions for it:

Usage: shlib.exe SUBCOMMAND

Displays and modifies the attributes of Shell Libraries.

Supported commands:

create           Creates a library at the specified path.
info               Prints info about the given library.
enum            Enumerates the folders in the library.
setattrib       Modifies the attributes of the library.
add                Adds the specified folder to the specified library.
remove         Removes the specified folder from the library.
setsaveloc    Sets the default save location of the library.
resolve         Resolves the specified folder in the library.
resolveall     Resolves all locations in the library in bulk.
manage        Displays the Manage Library Dialog for the library.

 

I’ve not had the chance to use it yet so please share your experiences of using it here.  When I get a moment to try it out I’ll feed back any tips/recommendations about it.  By the way, Raymond Chen also recently blogged about it here: http://blogs.msdn.com/b/oldnewthing/archive/2012/08/28/10343980.aspx

Ch-ch-ch-ch-Changes (Turn and face the strain)

Wow!  It’s been a crazy month in the deployment world.  When will this madness ever stop?!

First of all Michael Niehaus (Mr. MDT) is doing the off, although knowing the other members on the MDT team the MDT wheels won’t stop turning whatsoever.  Secondly, Windows 8 went RTM, so there will be lots of deployment related blog posts being written by everyone.  Then, a preview version Office 2013 was released :-0 !!  Next up, Hotmail was given the boot in favour of Outlook.

All this was preceeded by news that Metallica are working on a new album - OK, so not deployment related news… nor news really at all as they are all old enough to collect a pension now (or should seriously consider doing).  And finally, I almost broke my wrist on my mountain bike trying to ride a course that I could have easily managed 20 years ago – hence the delay in posting anything here; typing with one hand is rather tricky, and scripting is pretty much out whilst my wrist is strapped up :-(

Now the only thing that could really top all this madness is if something truly whacky happened such as if someone burnt their house down by trying to dry their pants and socks in the microwave!  Oh wait, hold on

 

In the meantime (whilst my wrist heals and then I take 2 weeks of holiday in the sun!) I wanted to post one-handed about a new Microsoft whitepaper that’s been published.  Titled “Mitigating Risk:  Why Sticking with Windows XP is a Bad Idea” you can probably gather which topic it is addressing.  It’s amazing how many companies are still on Windows XP with no roadmap for moving off of it.  I doubt this whitepaper will sway many people but it does give some food for thought.

You can get the whitepaper here: http://www.microsoft.com/en-us/download/details.aspx?id=29883

Scripts and Logging

Scripting.  It’s a necessary skill in any deployment project.  Given the prolificity of scripting examples on the Internet nowadays, you don’t necessarily need to even know how to write a single line of code to be able to use it!

But what about when your script does something unexpected?  Well, that’s what log files are for, and the better the quality of the log files your scripts generate, the greater their value when things go wrong.  So when adding the logging code to your scripts, do yourself a favour and ensure that they adhere to a predefined format – that way you’ll be able to take advantage of the colour coding feature of many log parsing tools, such as the “Configuration Manager Trace Log Tool” which is (in my opinion) the best one of them all.  And that’s where this blog post comes to your aid!  With little effort at all you can ensure that your scripts will generate these correctly formatted log files.

The below VBS code starts by creating a log file with the same name and location as the script itself, but with the “.log” extension (the location of this log file is easy to modify).  It then proceeds to append text entries to the end of the log file through the use of a call to a Sub procedure, “LogEntry”.  By calling LogEntry() and passing it the required information, the log file will be immediately updated.

Option Explicit

‘DECLARATIONS——————————————————–
Const FOR_APPENDING = 8
Dim strFilename, objFS, objTS, sTime, sDate, sTempMsg, Component, iType

‘Setting up log file for append - if it doesn’t exist, create it.
strFilename = Replace(Replace(WScript.ScriptFullName, “.vbs”, “.log”), “.wsf”, “.log”)
Set objFS = CreateObject(“Scripting.FileSystemObject”)
If objFS.FileExists(strFilename) = False Then objFS.CreateTextFile(strFilename)
Set objTS = objFS.OpenTextFile(strFileName, FOR_APPENDING)

‘SCRIPT BODY———————————————————
Call LogEntry(“NORMAL: This is my test log example - 1″, “1″)
Call LogEntry(“WARNING: This is my test log example - 2″, “2″)
Call LogEntry(“ERROR: This is my test log example - 3″, “3″)
‘END OF SCRIPT BODY————————————————–

‘Script complete, closing log file
objTS.Close

‘PROCEDURES———————————————————-
Sub LogEntry(StringToLog, strType)

sTime = Right(“0″ & Hour(Now), 2) & “:” & Right(“0″ & Minute(Now), 2) & “:” & Right(“0″ & Second(Now), 2) & “.000+000″
sDate = Right(“0″& Month(Now), 2) & “-” & Right(“0″ & Day(Now), 2) & “-” & Year(Now)
sTempMsg = “<![LOG[" & StringToLog & "]LOG]!><time=”"” & sTime & “”" date=“”" & sDate & “”" component=“”" & strType & “”" context=“”"” type=“”" & strType & “”" thread=“”"” file=“”" & “” & “”">”

objTS.WriteLine(sTempMsg)

End Sub

The first parameter that LogEntry() expects is the text to be written as the error message.  The second parameter is the key to the coloured highlighting and is a number between 1 and 3; the number defines what colour (Normal, Warning or Error) that the log parsing tool will use to display the line.

The below example shows how the log file generated in the above code looks in the log parser tool:

 

To get started just copy and paste the above code into a text file and replace the code between the indicated lines with your own code.  Then call LogEntry with your own values whenever you want to write an event to your log file.  When your script runs your log file will be automatically generated!

Of course, if your script is running as part of an MDT Task Sequence, then all of the above can be achieved through a single solitary line of code!  I’ll explain this though in a future blog post.