Relocating fruit trees in spring.

Due to a property line clarification, I had to move our non-fruiting cherry tree from one side of the yard to the other. It saddens me to move it this time of year, because the likelihood of survival isn’t great.

The xylem structure in the root nodes gets damaged, and then the roots can’t transfer enough nutrients and moisture to maintain a healthy tree. Stresses induced into the homeowner from such activities? Well, that’s another post for another day.

Automating Service Desk Plus with Powershell

Assuming you’re using PowerShell 3.0 (you better be!) you can use the new method tool for REST APIs called “Invoke-RestMethod”.

It’s quite nice to have a REST parser instead of trying to write some sort of custom thing specific to each REST application I’ve needed to interact.

This little piece of demonstration code below demonstrates a way to create a new helpdesk request with an XML package, submitted through the ServiceDesk Plus URI.

In a future post, I may get around to writing additional examples that demonstrate updating existing requests. This should be pretty straightforward, as the object returned from Invoke-RestMethod returns the calls from the REST server. In this SDP implementation, you get the ID of the request returned, which you can utilize later to modify and update all aspects of an existing request.

function new-helprequest
{
	param(
			[string]$requester="Lastname, Firstname",
			[string]$subject="null",
			[string][Parameter(Mandatory=$true)]$description,
			[string]$category="Unknown",
			[string]$subcategory="Unknown",
			[string]$impact="Impacts User",
			[string]$urgency="Low",
			[string]$site="Sitename")

	#this is an xml template to generate new SDP requests
	$requestXML=[xml]("<Operation>
		<Details>
			<requester></requester>
			<subject></subject>
			<description></description>
			<category></category>
			<subcategory></subcategory>
			<impact></impact>
			<urgency></urgency>
			<site></site>
		</Details>
	</Operation>")

	$url = "https://help.domain.com" #url to your helpdesk server
	$api = "/sdpapi/request/?" #api path, which is pretty much the same for SDP 8+
	$operation = "ADD_REQUEST" #the operation
	$apiKey = "541240AE9-197D-4F91-BDBC-7C614CA980D7" #the api key you generated from one of your technician accounts.

	#Configure the parameters for the xml with the content from the command parameters
	$requestXML.operation.details.requester = $requester
	$requestXML.operation.details.subject = $subject
	$requestXML.operation.details.description = $description
	$requestXML.operation.details.category = $category
	$requestXML.operation.details.subcategory = $subcategory
	$requestXML.operation.details.impact = $impact
	$requestXML.operation.details.urgency = $urgency
	$requestXML.operation.details.site = $site

	$uri = $url + $api + "OPERATION_NAME=" + $operation + "&TECHNICIAN_KEY=" + $apiKey + "&INPUT_DATA=" + $requestXML.InnerXml #assemble a URI. SDP expects a paramatized URI method to generate requests.
	Invoke-RestMethod -Method post -Uri $uri
}

Arduino TFT Shield

I’ve been working (playing) with an Arduino Mega2650, TFT shield and prototype board and I have to say it’s a lot of fun. One of the issues I ran into is the TFT library available doesn’t reference the right arduino core library in it’s various headers and references, and won’t compile out of the box. If you’re playing with the red TFT screen and mega shield like you see in the picture, try using this library to get going. I modified the include defs so it should work with newer development libraries. The link to a zip file with the modified library after the code example.

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

ITDB02_Graph16

Perforce <-> Active Directory through PowerShell

I’m working on releasing a group of Powershell functions that work as an overlay for managing Perforce users and groups that are tied to AD. Hopefully soon.
Oh yeah, since it’s just powershell you don’t need to register any classes or dlls or whatever. Just make sure p4.exe is installed somewhere. I know about p4.net, but I was really looking for something that can be extended and understood by someone without c# experience, like me! Yes, that was a self-deprecating joke.

X server SSH forwarding pro tip

I’ve been looking for this magic incantation for a while. Remoting to a linux box from a windows machine has been sort of special. For a long time I used XDMCP, but that protocol seems to be sort of depricated in recent releases of linux.

Then, you’ve got all these guys claiming that VNC is the way to go. Ugh. The last thing I want is a dumb bitmap copier from remote to local. What I’d really like is a remote client with some intelligence. Microsoft RDP would be good, except XRDP is sort of like VNC tunneled through a bastardized MSTSC protocol.

Another problem with XDMCP is that it’s UDP only, and thus sort of hard to tunnel over SSH. I’ve read that you should be able to do SSH X remoting, but I could never figure it out or maybe I was just too lazy.

Behold, the magic incantation to make X remoting over ssh behave properly.

After launching startx with nohup, inside your local x server window start your window manager.

nohup startx &
ssh -Y user@server.com
gnome-session&

Basically, we’re starting an x window session and ignoring hangup commands, then SSH inside that x session to set our display and launch a window manager. Yay, remoted SSH X.

I’ve been trying to figure that out for a while and now that I’ve got it, I’ll finally remember how to do it. Almost forgot, on a Windows machine you need Cygwin/X and the basic X server installed, including ssh client.