In March 2014, Lenovo issued a recall for certain batteries shipped with specific models of their ThinkPad line of laptops (or purchased afterwards as accessories). You can read about the recall here:
http://support.lenovo.com/en_CA/detail.page?DocID=HF004122
They provide an enterprise tool which can be silently deployed to affected machines, but the enterprise tool only creates a .csv file for each machine which an admin needs to gather up and email to a Lenovo rep to have them check whether the battery in the machine is affected. For various reasons, that didn't sound like a good solution to me, so I thought this might be a good first project to try out the toolkit.
Here's the script:
https://gist.github.com/rgsteele/f08f817d955440bb98c4
Save LenovoBattery.exe (
download link) to the Files folder. You'll want to deploy as a Package rather than as an Application. Enable the "Allow the user to run the program independently of assignments" option so the user can run the tool again through the Software Center if they have an additional battery to test.
I posted a WQL query in
this thread on the Lenovo forums which should find all of the standard machines which may be affected. (Special bid machines may have a different model number and thus would not be found by this query.) Use this to create the device collection you deploy the Package to.
Here's how it works: first the script verifies that the client can connect to
https://lenovobattery2014.orderz.com (which is the site the tool uses to verify whether the battery is eligible for recall). If the site cannot be reached, the script terminates with errorcode 1. Otherwise, the script displays a dialog to the user explaining what they will see when the tool runs. When the user clicks OK, the script runs LenovoBattery.exe with the /silent switch, which installs the tool and runs it.
The tool itself will either display a dialog saying that the battery is not affected or launch a browser window, which will either display "The battery is not eligible for replacement" or "The battery is eligible for replacement", in which case the user needs to click "Continue" and fill in their details to arrange to be shipped a replacement battery.
As soon as the tool finishes running, the script performs a silent uninstall of the tool since it is no longer needed. A final dialog is displayed to the user.
You should customize the messages displayed before and after the tool is run by editing the $message and $message2 here-strings.
A couple issues I encountered: I tried using Show-InstallationPrompt to display the messages to the user but the text was cut off, which I why I ended up using Show-DialogBox instead. I was also going to use Test-NetworkConnection rather than specifically validating that the site was available, but I found that function falsely reported "no connection" on my test machine which did in fact have a connection available. I'll file a bug for that when I'm able to further investigate why it didn't work.
Anyway, hope this is useful to someone. It was a good project for my first PSAppDeployToolkit deployment! Feedback is welcome.