GAThrawn

A little corner of the Empire on the web.

16 April, 2019

Retrieving Package Source Path/Application Content Locations from SCCM

We've been running with an old file server and a new file server for our SCCM package sources for a while now, with all the new software being put on the new server, and obsolete software being deleted from the old server as it goes out of use. Over time the old server should be used less and less as a package source, until it falls out of use and is decommissioned, but we really need to get a shift on with getting everything off the old hardware, and onto the new one. To make things easier for future moves the new one's referenced in all our systems with a fairly generic DNS name (rather than an old and obscure machine naming scheme), which should also make future server changes easier to manage.

So the first thing that I need to do is trundle through SCCM and work out what software is still using the old server as its source. There are a few main categories of bulk content that could be referencing files on that old server:

  1. Programs (using the Package Model)
  2. Driver Packages
  3. Applications (using the Application model)

Any of those could have their content files stored on either server. Packages are fairly easy as you can add a column to the console called "Package Source Path" and then sort by that. Applications are not so easy; each Deployment Type within an app has its own individual source path, and you have to drill right into the Deployment Type's properties to see it, there's no quick and easy way to see a list. (Obviously things like OS Images, Boot Images, etc could also be on the old server but we've only got single digit numbers of each of those, so they're just as quick to check one by one).

Packages (and Programs)

First the easy options, Packages and Driver Packages. Packages have one Package Source Path for the whole Package, which is used by each Program in the Package. All we need to do is use a cmdlet to retrieve all of the packages, then just pull out the properties from each that we're interested in, and finally dump that to a file that we can open in Excel and work our way through:

(All of the below PowerShell commands to be executed from a Config Manager PowerShell window, or a normal PowerShell command prompt with the ConfigurationManager module loaded and the current location changed to the Config Manager PSDrive for your site).


PS ABC:\> $Packages = Get-CMPackage
PS ABC:\> $Packages | Select-Object -Property PackageID, Name, PkgSourcePath | Export-Csv -Path C:\temp\PkgSrc.csv -NoTypeInformation

Driver Packages

These are very, very similar to normal packages. So similar that you may not even notice there's six extra letters in the initial cmdlet.


PS ABC:\> $DriverPackages = Get-CMDriverPackage
PS ABC:\> $DriverPackages | Select-Object -Property PackageId, Name, PkgSourcePath | Export-Csv -Path c:\Temp\DriverPkgSrc.csv -NoTypeInformation

Both of the above (Get-CMPackage and Get-CMDriverPackage) are relatively quick, they took less than a minute even running them from a remote machine against a site with a large number of [driver] packages .

Application model applications

Ok, here we go, here's the big one. Each Application can have multiple Deployment Types, each of those deployment types (which can each use a different deployment style) has its own, individual Content Location. To add to this, these queries are slower than their equivalents in the Package model (we're talking multiple minutes rather than seconds), long enough that there's some progress text output during this one, just to let you know that it's actually doing something. Then finally details of the app's Deployment Type(s) are all listed in a big XML property of the Application object, rather than each being their own object properties.

Here we are. Firstly we get the full list of apps from the site (which is the part that I've seen take 10 to 15 minutes on a site with around 800 app model apps), then iterate over them, pulling the relevant properties out of the XML (including iterating over each Deployment Type in that app), then finally output all of that as an object which we write to a CSV file:


$CSVOutPath = 'c:\temp\AppSrc.csv'
#Change to your site's ConfigMgr PSDrive before running this script

#Get each Application, then get the source path from each Applications's Deployment Types
Write-Host "Fetching application details - this takes a few minutes, please wait...`n"

$Applications = Get-CMApplication
$AppCount = $Applications.Count
Write-Host "$AppCount applications found.`n"

#Iterate over the apps list pulling out the details for each app. Takes a couple of minutes.
$i = 1
$AppSourceList = ForEach($App in $Applications)
{
    Write-Progress -Activity 'Checking apps and deployment types' -Id 1 -PercentComplete $(($i / $AppCount) * 100) -CurrentOperation "app $i / $AppCount"
    $PackageXml = [xml]$App.SDMPackageXML
    #An app can have multiple Deployment Types, each with their own source location. DT details are stored in the XML properties
    ForEach($DT in $PackageXml.AppMgmtDigest.DeploymentType) {
        $DtTitle = $DT.Title.'#text'    #need to quote property names with hashes in them, normal backtick escaping doesn't work
        $DtTech = $DT.Technology
        $DtLocation = $DT.Installer.Contents.Content.Location
        New-Object -TypeName psobject -Property (@{AppDisplayName = $App.LocalizedDisplayName; PackageID = $App.PackageID;
        CiId = $app.CI_ID; Enabled = $app.IsEnabled; Superseded = $app.IsSuperseded; HasContent = $app.HasContent;
        DepTitle = $DtTitle; DepTypeTech = $DtTech; DepTypeSrcLocation = $DtLocation})
    }
    $i++
}

#$AppSourceList | Out-GridView
$AppSourceList | Export-Csv -Path $CSVOutPath -NoTypeInformation

Download the Get-ApplicationSources.ps1 here: GitHub Get-ApplicationSources.ps1

(No download for the Package and Driver Package sources, as they're basically just one-liners).

09 April, 2019

SCCM Detection Rules for Dell BIOS Updates

I've been doing a bit of work lately on deploying Dell BIOS updates using SCCM. This is using SCCM's Application Model to deploy the updates out to live machines, and also using those to update BIOS firmware during OSD Task Sequences. I've been a through a few versions of SCCM app detection rules for these jobs. The problem is that WMI's SMBIOSBIOSVersion is a text field, so it's returned as and then treated as a string type. There's also nothing that standardises how manufacturers fill in that text field, so they can use whatever versioning scheme they want, with whatever text they want around it. So different manufacturers do it different ways and they often change it between models.

Dell (at least for their Optiplex and Latitude business products) seem to use two different BIOS version number schemes at the moment, they seem to use one on older models, and the other for newer models, and they each have their own challenges. The first scheme uses an "A" followed by a two digit integer, counting up from zero, eg "A00" followed by "A01" then "A02" with "A09", "A10", "A11" being later in the series. The second scheme is a three part version number separated by dots (full stops, periods whatever your region calls them), eg "1.0.0", then "1.1.0" and later releases may be "1.6.2", "1.9.3", "1.11.2".

Taking them one by one, the problem with the "A00" scheme is that it's a mix of letters and numbers, so you can't do a purely numeric comparison to get the larger number, but at least a string greaterThanEqualTo (-ge) comparison of them does work, and you can always remove the leading "A" and then just do a numerical comparison.

Unfortunately the "1.0.0" type scheme works perfectly with a string greaterThanEqualTo (-ge) comparison right up to point where any of the numbers in it become double digits, so '1.2.0' -ge '1.0.5' returns True, whereas '1.12.0' -ge '1.3.5' unexpectedly returns False. This is because it's comparing each digit in the number one by one, so the first digit "1" is the same in both, then the dot is the same in both, then "1" is less than "3", so the greater than test fails, even though 12 is bigger than 3 it only looks at the digits individually.

The end result of this is that I'm now using the following PowerShell script in a script detection rule for Dell's BIOS updates. You just put the version number of the BIOS version that you're deploying in the variable in the first line then it parses it all correctly from that.

$NewBiosVer = '1.13.0'
$CurrentBIOSVer = (Get-WmiObject -Class Win32_BIOS).SMBIOSBIOSVersion
#Check if this is old-style Dell BIOS versioning "Ann" or new-style "n.n.n"
If ($NewBIOSVer.StartsWith('A') -and $CurrentBIOSVer.StartsWith('A')) {
    If ($CurrentBIOSVer -ge $NewBIOSVer) {
        #To indicate software is found, return something in STDOUT
        Write-Host "BIOS Version $CurrentBIOSVer found"
    } else {
        #To indicate software not found, don't return anything to STDOUT or STDERR
    }
} ElseIf (($NewBiosVer -match "^[\d\.]+$") -and ($CurrentBIOSVer -match "^[\d\.]+$")) {
    #Check if we've got a problem with two digit decimals (where 1.9 is less than 1.10 in version numbers, but not numerically)
    $NewBiosVerArray = $NewBiosVer.Split('.')
    $CurrentBIOSVerArray = $CurrentBIOSVer.Split('.')
    If ([int]$CurrentBIOSVerArray[0] -ge [int]$NewBiosVerArray[0]) {
        If ([int]$CurrentBIOSVerArray[1] -ge [int]$NewBiosVerArray[1]) {
            #To indicate software is found, return something in STDOUT
            Write-Host "BIOS Version $CurrentBIOSVer found"
        }
        Else {
            #To indicate software not found, don't return anything to STDOUT or STDERR
        }
    } else {
        #To indicate software not found, don't return anything to STDOUT or STDERR
    }
} Else {
    #Doesn't fit either BIOS version format???
    #To indicate software not found, don't return anything to STDOUT or STDERR
}

For the task sequence step's run conditions I'm doing two WQL queries, one for the device's model, and the second a simple check that the BIOS version is not the one that the update's looking for (so that machines on our nominated version skip the step) and then the Application's detection rules check fully whether the currently installed version is older or newer than the one we're installing (using the above script).

04 July, 2017

Retrieve LAPS (Microsoft's Local Admin Password Solution) details using VBScript

History

We've been Microsoft's LAPS (Local Admin Password Solution) as a solution to manage the local administrator passwords on the majority of our servers (excepting domain controllers, for obvious reasons) for a while now. The fact that we'd been living with all of our servers having one or two incredibly simplistic passwords that hadn't changed for the best part of a decade, was giving us so many potential problems, from the ex-employee knowing the all the keys to the kingdom problem, to the straightforward pass-the-hash attack, and LAPS has worked well to mitigate those problems. For our server admins the options of reading the raw password from ADU&C, or using the PowerShell module, or even using the barebones LAPS GUI were fairly straightforward.


The Present

Now we're expanding our LAPS usage to manage the local admin passwords on all of our desktops and laptops. I know that most companies roll LAPS out to their laptops first and their servers last, but the fact that we'd been regularly changing the admin passwords on our laptops and desktops roughly twice a year for years meant that it wasn't needed so badly there.


For our desktop admins, and our helpdesk staff, we can't just point them at the installer for the PoSh module and leave them to it, so we're giving them the LAPS GUI client, but also integrating LAPS password lookup into some of the existing tools that we provide them. This means that I needed to retrieve the LAPS info using VBScript, rather than PoSh, to integrate into one of these tools. All of the examples in the LAPS documentation, and in everyone else's web write-ups of LAPS, use PoSh, so I had to pull this together from a few other scripts and tools that I'd used.




Download


Download the script here: GitHub: LAPS-Password.vbs



11 July, 2016

Find objects within folders in the SCCM Console hierarchy using PowerShell

Frustration


Ever since Microsoft's SCCM got the new-style System Centre console with SCCM 2012, I've been massively frustrated about how difficult it is to find items in the console once you've organised it with folders. Probably not too much of a problem if you're a lone SCCM admin, but as someone who works as part of a larger team who all use SCCM for slightly different reasons it can be a nightmare finding things like collections buried deep in the folder hierarchy.


Yes, I know that the console has a search function, and I know that there's a subtle "All Subfolders" button that magically appears on the Search ribbon bar sometimes. However that "All Subfolders" button has a few major flaws: 1) it doesn't always appear when it ought to, leaving you in a dance of clicking in the search text box, clicking away, clicking back in there, clicking away to another part of the console, clicking back, all the while crossing your fingers that the button will show up; 2) annoyingly clicking the "All Subfolders" button clears out any text that you may have foolishly typed into the search bar already before you remembered that you wanted to search the whole tree; 3) most importantly, the search results don't give you any information about the folder path that it found each item on, so it doesn't help you find that item (or similar items that may be in the same folder) quickly next time.


SCCM console rant over.


Journey


So over time I started casually looking around for ways to access this folder hierarchy info. These days there's a regularly updated set of SCCM PowerShell Cmdlets provided by the ConfgMgr team, this seemed an obvious place to start. Unfortunately, none of them even acknowledge that console folders exist. Next I set off on a hunt through WMI on the site server (using one of my favourite tools WMI Explorer (WMI Explorer downloads), but I couldn't any folder related properties on the collections/packages/etc themselves and couldn't find any obvious looking WMI classes. Real desperation now, open up SQL Management Studio and hunt through the Views in the site database. Nothing obvious. Brick wall hit. I went away and worked on other stuff for a while.


Enlightenment

Then early last week I came across this blog post by Peter van der Woude, that my previous searches had somehow missed: More than just ConfigMgr: Get the folder location of an object in ConfigMgr 2012 via PowerShell. Finally, answers - not only did that post contain this magic phrase: A good thing to know is that all folder information is stored in two classes in WMI, SMS_ObjectContainerNode and SMS_ObjectContainerItem. These two classes are the same for every object type., but it also had a working script linked, find his script in the TechNet gallery here: TechNet Gallery: Get the location of an object in the console via PowerShell


Moving Beyond


As great and useful as Peter's script was, it does have a minor flaw, and doesn't handle some edge cases. So I set off to use his information to write my own. The minor flaw was that his script requires hard coding your SMS Site Code and Site Server names into it. I can see the reason for that, especially as it means that his script has no external dependencies (other than the ConfigMgr infrastructure, obviously) but it still bugged me. More problematically, I hit an edge case that it didn't handle within my first few uses of it. Some objects (of different types) in SCCM can share the same SCCM IDs. So a Collection, a Query and a Package could have the same 8 character ([site code][5 hex digits]) ID, as all of those objects have their own numbering starting from XXX00001 and counting upwards. So using Peter's script, you don't always find the object that you're actually looking for, and, as his doesn't echo the name or type of the object that it's showing the hierarchy for, it can get quite confusing if it's not showing the info for the item that you're expecting.


Nirvana (or Farvana)


So, I've written my own PowerShell function to do this: Get-SCCMObjectLocation, find the code on GitHub, here GitHub: Get-SCCMObjectLocation.ps1. There's a bit more code here than Peter's versions, but this now outputs the object's name and type (so that you know you haven't made any typos, and you really have found the droids object you were looking for), and if there are multiple objects with the same ID, it lists them one by one. It also gets the site code and site server name from the ConfigurationManager PowerShell provider, though this does mean that you need the SCCM console installed on your machine, and you need to change to ConfigurationManager's PSDrive before running it.


Usage:
PS C:\>Get-SCCMObjectLocation -SMSId "ABC001BB"
root\Racked Server Drivers\Dell\PE1950-Microsoft Windows 2008 R2 SP1-OM7.3  [SMS_DriverPackage]
PS C:\>"ABC000CC" | Get-SCCMObjectLocation
WARNING: Multiple objects with ID: ABC000CC
root\x64\Test\Win 7 Ent x64 with Office 2010  [SMS_ImagePackage]
root\Servers\Server roles\All Domain Controllers  [SMS_Collection_Device]
PS C:\>Get-SCCMObjectLocation -SMSId "ABC00166" -SiteCode ABC -SiteServerName sms01.example.com
root\Application Deployment\MS Access App-V  [SMS_Collection_User]

Download

Download the script here: GitHub: Get-SCCMObjectLocation.ps1



Music to get through this with: Faithless - Faithless 2.0

15 July, 2013

Kindle Weather Display pt4 Putting it all together

By this point, if you've followed the previous posts in this series, you should have a server that's downloading weather info from a weather service, and converting that into a Kindle friendly PNG image, and you should have a Kindle that's been jailbroken, has working USB Networking (and SSH access) and has the Kite application launcher installed on it. Congrats, now let's put it all together and finish this crazy thing off.

Setting up the Weather Display on the Kindle


Find the "kindle" folder in the master.zip file you downloaded previously, or get the files from the "kindle" folder on GitHub.

Copy the "init-weather.sh" file into the "kite" folder on the Kindle. Then create a new folder called "weather" and copy both "display-weather.sh" and "weather-image-error.png" into it.

Open up the "weather\display-weather.sh" in a text editor (the same one that understands Unix line endings from above) and change the line that contains "http://server/path/to/weather-script-output.png" to the web server and file location that you set your weather script up on. When you save the file, make sure that you select Unix style line endings (this will probably be an option on the Save As dialog). Safely Remove and unplug your Kindle.

Now you're ready to test everything, you should see a new "PDF book" on your Kindle's screen called "init-weather.sh" if you don't, then switch your Kindle off and back on again. Select that and your screen should flash a few times and then either show your current weather, or show a warning sign and "Weather Image Unavailable".

Either of those mean that everything's working on your Kindle and you've succesfully run a custom script on it, if you get the image unavailable message then check the web address you've put in for the picture is correct.

One other possibility here is that when you click the init-weather.sh your Kindle puts a loading circle in the top-left corner for a moment, and then flashes back to the Home screen, this probably means that either init-weather or display-weather have been saved with Windows line endings (some decompression/un-zipper apps "helpfully" translate the line-endings for you when you extract text files, yours may have done this) just open the files up in a text editor and make sure that they're saved with the Unix line endings option select and try again.

One thing you'll notice when you've successfully got the weather scipt running is that there's only one way to exit it, and that's to hold down the power button on your Kindle for 20 seconds or so and wait for it to reboot. While that's fine when everything's up and running it can get a bit annoying while you're just testing things (like getting connected to your web server, or playing around with the look of the weather page), one alternative is to drop a test-weather.sh file into the "kite" folder containing:

#!/bin/sh
/mnt/us/weather/display-weather.sh

This should show the weather display on the screen for a moment, and then dump you back to the Kindle's home screen.

Set up Cron On the Kindle

This is it, we're nearly there now, just need to set the Kindle up to regularly check back with the server for an updated weather picture. Cron is how we do that.

Firstly, if you've never used Cron before, read up on Cron at wikipedia and follow links to further info if needed. I can also recommend searching for something like "crontab calculator" or "crontab generator" and using one of those to help build up your cron line, or running a search for "cron" on SuperUser.com.

Now you need to SSH into the Kindle again, you know the drill by now, switch on USB networking on the Kindle, plug it in and reconnect to it with Putty.

Once you're SSH'd into your Kindle, mount the file system for editing:
mntroot rw
Edit the CRON file in vi (a command line, text mode, text editor) (unbelievably *nix people like this thing and even fight religious wars over how much better it is than other text mode editors, like it's still 1980)(http://en.wikipedia.org/wiki/Vi)
vi /etc/crontab/root
A list of the jobs in the root cron file should appear:
*/15 * * * * /usr/sbin/checkpmond
*/15 * * * * /usr/sbin/tinyrot
*/60 * * * * /usr/sbin/loginfo tmpfs
*/60 * * * * /usr/sbin/loginfo localVars
*/60 * * * * /usr/sbin/loginfo memusedump
*/15 * * * * /usr/sbin/loginfo powerdcheck
All we need to do now is add the display-weather.sh script onto the end, mine's set to run every 6 hours, starting at just after midnight.
Try 10 */6 * * * /mnt/us/weather/display-weather.sh



Move the cursor to the end of the final line (using the arrow keys), press "i" to switch into "insert" mode, press Enter for a new line, and then type in your cron line, press Escape to leave Insert mode, and then press ":w" to save the file, and then ":q!" to exit vi. There, wasn't that straightforward and obvious! For more help with vi commands and a tutorial, consult your favourite search engine.

Your crontab file should now look something like:
*/15 * * * * /usr/sbin/checkpmond
*/15 * * * * /usr/sbin/tinyrot
*/60 * * * * /usr/sbin/loginfo tmpfs
*/60 * * * * /usr/sbin/loginfo localVars
*/60 * * * * /usr/sbin/loginfo memusedump
*/15 * * * * /usr/sbin/loginfo powerdcheck
10 */6 * * * /mnt/us/weather/display-weather.sh

And then you restart Cron, to read the new job details, by entering:

/etc/init.d/cron restart

Which should give an output like:
[root@kindle root]# /etc/init.d/cron restart
system: I cron:def:stopping crond
system: I cron:def:starting crond
[root@kindle root]#

Note: while you can set the Cron repeat interval to very small amounts of time when testing, I really wouldn't advise setting it to repeat any more often than every 5 minutes, as to get in there and change Cron's settings you need to wait for the Kindle to come on, turn on debug mode, turn on USB networking mode, SSH in and adjust the timings, all before the weather job kicks in again. That's not a quick process, you'll want to give yourself a few minutes.

Unplug, switch USB Networking off again, run init-weather.sh and enjoy your weather display.

And we're there!

The finished job, a Kindle showing today's weather
Some atypical English weather, showing on my Kindle.

Useful references and acknowledgements:

Thanks to Matthew Petroff for the inspiration and for putting in all the hard work to get all of the original scripts together and get this working on a Kindle in the first place.

Todo

Thoughts for future changes to this:
  • Wind - being a sailor, the wind conditions can be a useful thing to know, a couple of the weather feeds include this, either by default or as an option, so it should be possible to include it with some tweaks to the vbscripts, a tweak of the SVG template, and some new icons.
  • New icons - while the icons included in Matthew Petroff's original collection are clean and clear, I'm quite fond of the old BBC weather icons - they're what I grew up with - a member of the design team for the BBC's new visual style has made a set of icons in the style of the old classics, available here, it shouldn't be much work to swap these in.
  • Two other personal projects that I'm planning to do at some point are learn PowerShell and rebuild my 2003R2 based home server into Server 2012 whilst recreating most of WHS's functionality, as part of this I may rewrite the server-side VBscripts as PowerShell scripts.

Update 07/2016: download links updated now that project files have been moved to GitHub

  1. Introduction
  2. Setting up the server
    • Weather Services
    • Getting the Image Tools
    • Scheduled Tasks
    • Download the Scripts
  3. Setting up the Kindle
    • Jailbreak your Kindle
    • Setting up USB Networking (1)
    • Setting up USB Networking (2)
    • Installing Kite on the Kindle
  4. Putting it all together
    • Setting up the Weather Display on the Kindle
    • Setting up Cron on the Kindle
    • Useful References and acknowledgments
    • Todo

12 June, 2013

Kindle Weather pt3 Setting up the Kindle

Back to the first post in this series.

Setting the Kindle Up


I'm doing this with a black Kindle 4 (non-touch) running Kindle v4.1.0, some of the following steps could change if you have a slightly different model (grey Kindle 4's may have older older firmware which give you more jailbreak options, they may also have the built-in SSH server enabled), I believe that most of this should work on a Kindle 3 (aka Kindle Keyboard) but I haven't tried that, so do it at your own risk.

Jailbreak your Kindle

I used the Universal method from here: MobileRead.com Kindle4NT Hacking.

Get SSH access to your Kindle (USB Networking) - attempt number 1


Plug in the Kindle and create a blank file named ENABLE_DIAGS in the Kindle's USB drive's root, "Safely Remove" the USB cable and restart the Kindle (Menu -> Settings -> Menu -> Restart).

It should reboot into diagnostics mode.

While you're in the diagnostics mode, plug the USB cable back in again and go to USB networking: Misc individual diagnostics -> Utilities -> Enable USBnet -> Exit. This will enable network access to your Kindle via USB.




Windows may fail to autodetect everything, if so you'll probably need to install a specific driver to access the Kindle over USB networking. This .inf file should do the job (I'm running Windows 7, Windows XP users need to do slightly more than this, good luck).

Once you have your driver set up, you'll need to configure the settings on your new network interface, set them to: IP 192.168.15.201 Subnet 255.255.255.0




Open your favourite SSH client (assuming that you have such a thing), I'm using Putty.

Try running Putty root@192.168.15.244 if that connects you're gravy, and your Kindle has a SSH server, if not and you get a "Connection Refused" then you're like me, so carry on.



Get SSH access to your Kindle (attempt 2, USBNet hack)


Download kindle-usbnetwork-xxx.zip from http://www.mobileread.com/forums/showthread.php?t=88004 extract it and copy update_usbnetwork_XXX_k4_install.bin onto your Kindle's USB drive. Safely Remove, unplug, then go into Settings, Menu, Update your Kindle. USB Networking should now be installed.

Restart your Kindle (not strictly necessary, but the Readme's recommend it).

Plug your Kindle in, and double-check the settings in D:\usbnet\etc (you'll need to use a text-editor that understands Unix line endings, Notepad won't work here, Notepad++, TextPad and others will work). In particular make note of the IP addresses, by default mine were set to:
HOST_IP=192.168.2.1
KINDLE_IP=192.168.2.2

On a Kindle 4, it's recommended to check that USE_VOLUMD is set to "true"

Following the README_FIRST.TXT from the usbnetwork zip:

  • Safely remove and unplug your Kindle,

  • You'll need to be in debug mode to run private commands, so, on the Home screen, bring up the
    search bar (by hitting [DEL] on devices with a keyboard, or the keyboard key on a K4, for example), and enter:

    ;debugOn

  • And now we can enable usbnet:

    ~usbNetwork

  • If you don't need to enter any more private commands, switch debug off.

    ;debugOff

  • Now, to actually connect to the device, we'll need to bring the shiny new USB network interface that the kernel prepared for us.

  • Plug the Kindle back in, wait for Windows to detect it, your Kindle should now be detected as something like a "RNDIS/Ethernet Gadget" or "CDC Ethernet Device network adapter" by Windows.

  • Then go into network settings, find the new network connection, and set the IPv4 settings to IP address 192.168.2.1 (assuming that's the HOST_IP that was set in your Config file above) and a subnet mask of 255.255.255.0.

  • To test it, open a command window and Ping 192.168.2.2 which should come back with a reply.

  • Now try Putty again:
    putty root@192.168.2.2

  • Hopefully this time you should get a connection and a warning message about the server's "host key". If so, say "Yes" to add the key to your cache, and then you should find yourself at a password prompt. A blank password works here, so you can just press Enter.
Congratulations, you now have SSH working. Careful, you can do a lot of damage here!

Install Kite (Kindle Application Launcher)

Now you need to install Kite, this lets you easily run custom programs on your Kindle. I tried installing Kite using the update package, with no luck, so here's installing it using the script method. First, download the kite.gz file from http://www.mobileread.com/forums/showthread.php?t=168270 and copy the kite.gz file onto the USB drive of your Kindle. If your Kindle is currently in USB Network mode, then you'll need to switch back to USB storage mode to copy the Kite installer onto it, as the usbnetwork command is a toggle, you can issue:
;debugOn

~usbNetwork

;debugOff
Once you've copied the files on, switch back to USB Network mode by issuing the commands again.
;debugOn

~usbNetwork

;debugOff
Plug your Kindle back into your PC again and test connectivity with a PING (depending what you've been doing in between, Windows may detect your Kindle as a new device again. If so, re-set the IP settings back onto the network adaptor as above, I went been to France for the weekend in between setting up USB Networking, so it happened to me). Connect to your Kindle's shell with Putty
putty root@192.168.2.2
Issue the commands to uncompress, and then run the Kite install script:
  • Mount the Kindle file system, type:
    mntroot rw

  • Move into /mnt/us:
    cd /mnt/us

  • Unzip the kite.gz file, and run the install:
    gzip -d kite.gz
    sh kite

Kite should now be installed, unplug your Kindle and then reboot it (Menu, Settings, Menu, Restart). As the reboot happens you may see a kite appear in the picture of the boy reading under a tree, or the land behind the tree may just flatten out, either are good signs. Once it's rebooted plug it back into your PC and check if there's a "kite" folder on the Kindle, if not create one (you may need to move/delete a file called "kite" first).

Next: Setting up the Weather Display on the Kindle


  1. Introduction
  2. Setting up the server
    • Weather Services
    • Getting the Image Tools
    • Scheduled Tasks
    • Download the Scripts
  3. Setting up the Kindle
    • Jailbreak your Kindle
    • Setting up USB Networking (1)
    • Setting up USB Networking (2)
    • Installing Kite on the Kindle
  4. Putting it all together
    • Setting up the Weather Display on the Kindle
    • Setting up Cron on the Kindle
    • Useful References and acknowledgments
    • Todo

Kindle Weather pt2 Setting up the server

Back to the first post in this series

Setting up the server


Matthew Petroff's original scripts assume that you're using a Linux server, they're made up of a BASH shell script (that won't do anything on a Windows box) and a Python script (that needs an extra install of 3rd party software to get it working on Windows), as well as relying on a couple of small tools that either aren't available to us, or don't work as well on Windows.

So to get things compatible with pretty much any Windows box, I've rewritten the shell script as a batch file and the Python script as VBScript, both of those should just work on anything from Windows 2000 upwards, and I've found some replacements for the small tools.

What you'll need for this section:

Create a new folder somewhere on your server (preferably outside of your web server's root) and download and extract the zip file into it. This should give you three folders, one of which is called "Server-VBScript", and in there are three folders called "ServerNOAA", "ServerWU" and "ServerMet" inside each of these you'll find an SVG, CMD and a VBS file. Now you need to decide which weather service you'll be getting your forecasts from, they all make their data freely available for non-commercial usage but have different coverage, may differ slightly in their forecasts of different areas and provide slightly different info, whichever one you want copy that service's folder into the new folder on your server:

  • NOAA - the US Government's NOAA's National Weather Service. The major downside (for me) is that they only provide forecasts for the USA.
  • WU - Weather Underground, run from a US University, they provide worldwide coverage, and in multiple languages
  • Met - Her Majesty's Government's Meteorological Office (The Met Office) forecasts. They only cover the UK (this is what I'm using on my Kindle)

Pick whichever weather service you want, and feel free to delete the other folders if you don't want them.

Weather Services


Depending which weather forecast service you pick, you'll need to find your location code, and possibly sign up for a (free) API key to use it, I'll go though these:

NOAA
All you need is to find the latitude and longitude of your location, and change these in the long URL inside the ServerNOAA\weather-script.vbs file using a text editor, also note that the final parameter in that URL "&Unit=e" sets it to the temperature in Fahrenheit, changing it to "&Unit=m" will output the temperatures in Centigrade.

WUnderground
You will need to sign up for a developer account at Weather Underground, and then you can create a (free for the usage level that we'll be putting it to) API key to access the weather reports. Once you have that you just need to work out your city's code, acceptable formats are:
CA/San_Francisco | US state/city
60290             | US zipcode
Australia/Sydney  | country/city
37.8,-122.4       | latitude,longitude

Then open up ServerWU\weather-script.vbs file using a text editor, find the line with the long URL in it and replace "APIKEY", "COUNTRY" and "CITY" with your API key and location.

Met Office
As with WUnderground, you'll need to sign up for a free API Key to use the Met Office's forecasts, once you have that you can visit the following URL to get a list of the location codes that you can use:
http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/xml/sitelist?key=API_KEY
Take the 6-digit location code from there, and your API key, and plug them into the long URL in the ServerMet\weather-script.vbs file using a text editor.

If you've got everything set up right, then when you double-click the VBS file it should create an SVG file in the same folder, showing your graphical weather forecast. You can view this SVG file with most web browsers.

Getting the Image Tools

(Side-story, looking for a suitable replacement for the RSVGconvert *nix tool to do command-line SVG to PNG conversions I went straight to my old, faithful ImageMagick, but every version of that and every option I tried seemed to choke on the embedded icons, eventually I came across Inkscape and discovered it had a decent command line interface, so here we are)

Next download Inkscape SVG editor and extract it into an Inkscape folder in your server's weather folder.

Then download PNGCrush and save the file in your server's weather folder.

Your folder structure should now look a bit like this (the "public" folder won't have been created yet):


Then go into the folder for the weather provider you're using, open the CMD file and edit it to reflect the paths of all these tools, and change the references to the "public" folder to point to the location of the folder within your web server's root that will be serving up the PNG image.

Now try running the CMD file in your chosen folder by double-clicking it, and with luck after a few seconds your 'public' folder should now contain a PNG image that looks a bit like this:

typical English weather

Scheduled Tasks


Finally you'll need to decide how often you want your weather image to update and set up a Scheduled Task in Windows to run the relevant CMD file as often as you want it. Personally I'm going to have my Kindle updating its weather display 4 times a day, so I'm setting my scheduled task to run every 6 hours.


Download the Scripts

  • GitHub project: all files for the project browsable online, and individually downloadable
  • Entire project master.zip (72KB zip compressed file): if you don't know what a GitHub project is, use this link to download everything needed in one go.


Update 07/2016: files and download moved to GitHub, all previous updates merged in.



Next: Setting up the Kindle.


  1. Introduction
  2. Setting up the server
    • Weather Services
    • Getting the Image Tools
    • Scheduled Tasks
    • Download the Scripts
  3. Setting up the Kindle
    • Jailbreak your Kindle
    • Setting up USB Networking (1)
    • Setting up USB Networking (2)
    • Installing Kite on the Kindle
  4. Putting it all together
    • Setting up the Weather Display on the Kindle
    • Setting up Cron on the Kindle
    • Useful References and acknowledgments
    • Todo

09 June, 2013

Kindle Weather Display (from Windows)

I admit it, I'm interested in the weather. What can I say? I'm an Englishman and a sailor, I need something to talk about, and some way to know whether it's shorts weather, or if I need to take a brolly to work. Add in the fact that I love tinkering with gadgets, and have a mini server box sitting in the corner of my living room that spends large parts of the day doing very little, then I was very interested when I ran across Matthew Petroff's Kindle Weather Display blog post.


The only problem was that although he has all of the files available for download from that page, and a barebones hint on how to use them, it assumes a certain familiarity with Linux and its tools, and assumes that you're using a *nix server for the web server, and a *nix machine to do the install from, much of the Kindle hacking needed as a pre-req makes similar assumptions. I've barely touched Linux in the last 10 years (why deliberately make life hard for yourself when there's better choices out there?), was planning to set this up on my Windows Home Server box, and to do it all from my Win7 laptop. Clearly I was going to need to rewrite a few things, and work a few things out.

This is my tale of how that was done, so that you may read it, and do the same yourself.

To accomplish this you're going to need a few things that most people apparently don't have lying around their homes for some reason:

  1. A Kindle to dedicate as the display - while you could use the same Kindle that you use to read in bed at night, or on the train in the morning, that really won't be very convenient. Beware also that we're going to be hacking the Kindle and doing some (potentially harmful to the Kindle) things that will not be covered under your warranty. That said, if you hunt around you can find Kindle 4's for a fraction of their retail price on eBay, the one I'm using is an ex-shop demo unit that I got for a hair under £20.
  2. A Windows server (or at least a Windows box, doesn't necessarily have to be server hardware or a server OS sku) that will be switched on all the time, with an "always on" internet connection (the server itself doesn't need to be accessible from the internet). I have an old Tranquil PC SQA-5H that I use to run my home services, so that'll do me.
  3. A web server installed and running on your Windows server - all we need is a way to serve static PNG images over HTTP, so you won't need anything fancy. Personally, I'm using a Windows Server SKU, so I'm using the built-in IIS web server but pretty much any web server will do, Apache is probably the next most common, and I've used that for projects in the past.
  4. A basic plain text editor that understands the difference between Windows and Unix line endings.
    MS Word absolutely won't do, that's a Word processor not a text editor, Windows Notepad is no good either as it can't handle Unix style line endings. Something like Notepad++ or TextPad (which I'm using) would be perfect for this, many programmer's IDEs (such as Komodo, Eclipse or Visual Studio) also include this if you already have one installed, but don't go installing an IDE just for this as it really would be overkill.
  5. A basic familiarity with Windows and basic, common Windows tools - I'm happy to walk you through the Unix/Linux tools and commands but I'll expect you to know what you're doing on the Windows side

Warning: this is going to be a long one, so I'm dividing it up into a few parts over a few days, click any of the links to skip to parts you're interested in, or read the whole series to do it all. You can do some of the following steps in different orders, but I found it easiest to start with setting up the server while I was still searching eBay for a cheap Kindle.

Next: Setting up the server.


  1. Introduction
  2. Setting up the server
    • Weather Services
    • Getting the Image Tools
    • Scheduled Tasks
    • Download the Scripts
  3. Setting up the Kindle
    • Jailbreak your Kindle
    • Setting up USB Networking (1)
    • Setting up USB Networking (2)
    • Installing Kite on the Kindle
  4. Putting it all together
    • Setting up the Weather Display on the Kindle
    • Setting up Cron on the Kindle
    • Useful References and acknowledgments
    • Todo

06 March, 2012

Mass Effect 3 questions

As someone who played (and loved) the first two Mass Effect games on the PC (after being badgered to just try them by a good friend), I'm on tenter-hooks waiting for the third installment's release on Friday (after the USians got theirs today).

As I'm moving between platforms these days and having a whale of a time in multi-player on XBox, including in the excellent multi-player section of the ME3 demo, I've had a few concerns about the PC/XBox divide, here are the answers I've found:

Tons of useful info there to keep me interested and informed until the final release!

11 May, 2011

Deploying Adobe LiveCycle Launchpad ES2 (9.5) for use by end users

As in many companies these days, our users don’t have administrative permissions to their PCs or to the various servers and services we give them access to. This means that the standard one-click web page deployment of LiveCycle Launchpad won’t work for our users, and also we have to configure the permissions within LiveCycle to give them the permissions needed. Here’s how we got it working:

Throughout this please replace any references to "LiveCycleServer" or port numbers in URLs with the appropriate ones for your environment.

Software Deployment

  • Log into your LiveCycle server's admin console (as a user with at least some admin privileges):
    http://LiveCycleServer:8080/adminui/
  • Then go to http://LiveCycleServer:8080/launchpad
    You should be able to download the .AIR executable from your server from this page, its address will be http://LiveCycleServer:8080/launchpad/installer/LaunchPad.air ).
  • (If you haven’t already) Sign up to Adobe’s AIR Runtime distribution agreement, this should get you a link to the direct download for the corporate deployable, bare-bones, all-in-one, AIR runtime installer.
  • Once you’ve been sent the link to the "Download Adobe AIR Runtime" page, you want to download the installer files under the "Adobe AIR Runtime Installer files: For use with a native installer or through CD/DVD redistribution using the Adobe AIR side-car configuration" heading.
  • Put your LaunchPad.air and AdobeAIRInstaller.exe files into a folder together, and you can now push out the two together, with a command line like:
    AdobeAIRInstaller.exe -silent -eulaAccepted -programMenu LaunchPad.air
  • Screenshot of the Server.xml file's contentsFinally the first time that you run the LiveCycle Launchpad app, you’ll notice that the servername, protocol and port are all set to defaults, and not to your server’s settings. Have a look in c:\Program Files\Adobe\LiveCycle ES2\Adobe LiveCycle Launchpad ES2 on a PC that has Launchpad installed and you should see a Server.xml file, copy that to your distribution location, open it up in a text editor and change the server details to match your environment. You can now push this file out along with the Launchpad app to give your users the correct default settings (I just use an Xcopy to put this in the folder after install).
Folder listing showing LaunchPad.air Server.xml and AdobeAIRInstaller.exe files ready for deployment

Now you’ll find that any users (who don’t have admin permissions within LiveCycle) who try to log into the Launchpad app will get an error like: "Server configuration specified here is invalid. Do you want to reconfigure the server settings?"

Error message after login - Server configuration specified here is invalid. Do you want to reconfigure the server settings?

Permissions

So, once users have the app, you need to ensure that normal users can use it without needing admin access all through the LiveCycle server.

  • Log into the LiveCycle admin console (as a user with at least some admin privileges):
    http://LiveCycleServer:8080/adminui/
  • Go to Settings -> User Management -> Role Management
  • Create a New Role, I called mine LaunchPad User, and obviously fill out the description field

  • Assign them enough permissions to use the Launchpad app, according to these articles they need these permissions at a minimum they’ll need "Repository Read", "Repository Traverse", "Repository Write", "Document Upload" and they’ll also need the PDFG User role assigned as well. Depending on your LiveCycle config, and which modules you have, you may have to give them additional permissions to other modules to give them all of the available modules. See these articles for more info on permissions needed: Adobe Knowledgebase: Unable to use LiveCycle Launchpad services without administrative role - LiveCycle Launchpad ES2 (9.x) and Adobe Forums: Launchpad ES2 - Logging In Issue.

  • Now assign these roles to end users (or preferably to a group to keep things tidy).

Done! You should now be able to deploy and give your users access to LiveCycle Launchpad. Next up (hopefully) deploying the LiveCycle ES2 PDFG Windows printer to your non-administrative users.