Powershell detect and delete a registry entry

Thursday 30 June 2022 at 5:25 pm

I'm sure this will be better documented elsewhere on the web, but I like to add snippets here which may help a person with the same query as me.

I wanted to use PS to see if a particular entry in HKLM\Microsoft\Windows\CurrentVersion\Run is there, and if it is, delete it so the program doesn't autorun.  So here's my code:

$path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\run"
$test = (Get-ItemProperty -Path $path -Name "softwarename") #you can use wildcard * to find
if ($test -ne $null)
Write-Host "deleting reg entry"
Remove-ItemProperty $path -Name "softwarename"
Write-Host "it's not there, bye"

It's probably clunky and badly-written, but works for me!

Teams in a domain environment

Thursday 23 September 2021 at 12:02 pm

OK, Teams is a pretty good product, and when it's working, it's great.  However in a domain envrionment, particularly with roaming profiles, it's horrible..

As anyone in IT Support will know, it is installed in the user's profile, rather than the usual Program Files area. I think this is known as a Squirrel install or something. The concept is that, since it updates regularly (every couple of weeks or so), it's easy to keep updated because the user doesn't need admin rights all the time.

When you have roaming profiles, Teams wants to store all its junk in there, anything up to about 2Gb in size. When logging on and off, this puts a huge bandwidth and time burden on the system. Because of this, we took the decision not to roam these folders, but the knock-on effect is that everyone has to reinstall Teams when they log on. Back to bandwidth use again, plus user annoyance factor.

There is a machine-wide MSI installer, but it's no good for keeping updated. You can't just download a new one every so often and deploy it. Doesn't work. So here's my workaround, maybe it's not the best way of doing it, but it seems to work for us (for now).


This is the concept

- a PowerShell script runs on a server on a scheduled task to download the latest version of the Teams installer exe, and saves it in a shared location.

- a small batch file runs the installer, and;

- Group Policy places a shortcut on the All Users desktop.

It's not automated, but as long as users know where the shortcut is, they can be told to use this when they need Teams.

This is the PowerShell script, which will work as long as Microsoft don't change the location. We're all 64-bit here so it's the x64 version. Change your hyperlink for locale and version.

$source = 'https://go.microsoft.com/fwlink/p/?LinkID=869426&clcid=0x809&culture=en-gb&country=GB&lm=deeplink&lmsrc=groupChatMarketingPageWeb&cmpid=directDownloadWin64'
$destination = '\\pathto\folder\Teamsx64.exe'
Invoke-WebRequest -Uri $source -OutFile $destination

Stick this on a server and make a Scheduled Task to run it every Sunday night (or whatever).

Then Group Policy makes the shortcut:


This is in User Configuration -> Preferences -> Windows Settings -> Shortcuts

I made a nice little custom icon too so it stands out on the desktop. 

The install batch file isn't strictly necessary, but if the user just runs the .exe direct, it pauses for a while and doesn't look like it's doing anything. This simple batch shows a window (in custom Teams purple & white!) just to prove to them that something is happening.

TITLE Teams Installer
ECHO Installing Microsoft Teams, please wait...

Garrett Metal Detector Ace250 Coil Pinout

Thursday 15 April 2021 at 2:52 pm

Had to resolder a friend's Garrett coil connector as the wire had broken.  Couldn't find a reliable pinout online so from my dismantling, here's what I found.  Diagram is from the rear of the plug (solder side).

Click for full size


SCCM deployment of Epson Scan driver

Tuesday 14 July 2020 at 08:48 am

College PCs in our art department all have Epson V700 scanners, and up til now we've been manually installing drivers from the Epson download.

But this year I've sorted out a deployment, I stumbled on the silent install switch on an ancient forum (source https://www.itninja.com/question/epson-scanner-software) so recording here for posterity.

- Download epson driver from website
- Extract files using 7-zip or similar
- Find the folder Common/Escan which contains the drivers and setup.exe
- In SCCM deployment run "setup.exe" /SI -sms /Nodisp
- For detection I used the presence of C:\Program Files (x86)\epson\escndv\escndv.exe

Install .net Framework 3.5 on Windows 10 using SCCM

Thursday 16 January 2020 at 4:24 pm

There are hundreds of Google results with this subject, but after a day of trying various solutions and tearing my hair out I finally managed to get this working, so here's my take on it.

This was to retrospectively roll out .net framework 3.5 to an estate of W10 1903 PCs.

You will need (from the Windows installation ISO - make sure it's the same version of Windows because an 1809 install won't work on 1903, for example), a copy of the folder sources\sxs.  I copied the whole sxs folder to my deployment share, because earlier attempts just using the single .cab (the biggest one) failed miserably.

In SCCM make a new Application package. Make a Script Deployment, pointing to your deployment shared folder, with the Installation Program as follows:

Dism /online /enable-feature /featurename:NetFX3 /All /Source:"sxs" /LimitAccess

The 'Source:"sxs"' refers to the folder I'd copied previously.

For the Detection Method I just used the existence of registry key HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5, which wasn't there before the install.  Good enough for me.

Now I can use it as a dependency for any legacy software which wants this framework to run on.  Online exam software seems to be a major user of this.

Next time I create a new W10 image for deployment, I'll probably build it in, but this gets me out of a load of manual work for now.

Tripod support ring for Lumix 100-300mm lens

Wednesday 30 January 2019 at 04:34 am

Home-made solution for a tripod support ring for my Panasonic Lumix 100-300mm lens HFS100300.  My camera body is the tiny GM-5 so it already looks ridiculous with a big lens, and there was never any chance of it working properly on a tripod.

There doesn't seem to be a genuine Panasonic unit, and the only other one I found was a bespoke German-made one which is really expensive, as well as being quite difficult to source. Yeah, it looks lovely and doesn't need a screwdriver to fit, but the look of the thing isn't really an issue, and I'm a cheapskate, so I thought I'd try to make my own.  I toyed with the idea of buying a ring for another camera and modifying that, but this is way cheaper!

Based on a 67mm Munsen ring (I learned a new thing - a Munsen ring is a pipe clip/support commonly used in construction, and this one's threaded mount is usually connected to Unistrut in a building by a threaded bar).  It comes with a rubber cushion which is a bit bulky so I binned that.  Cost me a couple of quid off eBay, but you may even find cheaper at your local plumbing store.


First I Dremeled a hole for the lens' image stabilisation switch. 


Then bolted on an aluminium plate.  Originally I was going to drill and tap the tripod mount hole, but I found a brass insert from an old action-cam mount and press-fitted it in (carefully drill the right-sized hole then squeeze in a vice to force the insert through). 



To protect the lens I used heatshrink on the top (again, cutting a hole through for the switch).  I found I'd run out of the right-sized heatshrink for the bottom so I glued in a strip of scrap leather


Fitting to the camera - had to be careful not to squeeze it too hard as it makes the zoom ring stiff to turn, so I experimented with different washer thicknesses to give the perfect grip without affecting operation.  Finally a bit of work on the grinding wheel to round off the corners of the bar.



More by luck than judgement the balance is now pretty much perfect, so now I've no excuse not to go out for some fancy wildlife pics.

Walking round Norwich's City Walls

Sunday 08 July 2018 at 11:54 am

Map of a walk I made around the route of Norwich's mediaeval city wall, of which there is quite a lot remaining.  I took in Pull's Ferry and Cow Tower (a separate artillery tower not directly related to the orignal wall) as they were on the way.  Feel free to use the map if it's helpful.

Old City Wall, Barn Road Norwich Old City Wall, Carrow Bridge Norwich Old City Wall, Carrow Hill Norwich Old City Wall, Carrow Hill Norwich Old City Wall, Chapelfield Road Norwich Old City Wall, Grapes Hill Norwich Old City Wall, Magdalen St Norwich Old City Wall, Silver Road Norwich

Querying printer status via SNMP and PHP

Wednesday 18 October 2017 at 10:02 am

Background - my work (a college) migrated to a centralised printing system using about 15 multi-function Samsung printers.  As a support tech I wanted a single view which reported consumables and error statuses so we could see at a glance where supplies are low (only us technicians are allowed to replenish toner & paper).  Samsung do their own client software but I could never get it to work how I wanted.  This is what my page looks like (I've obliterated the name/location info for privacy):


Here's how I did it...

First I used a program called Frameflow SNMP browser to connect to a printer to find the SNMP OIDs I needed.  This was the tricky bit.  There are hundreds of OIDs, and by trial and error I found the right ones to build my script.  I worked out that paper levels are reported as a figure ouf of 520 (presumably the tray capacity in pages).  When calculated as a percentage they report at 100, 70, 30 and 10%.  Toners are reported out of 30000 and our black high-capacity cartridges are out of 45000.  The PHP in the script calculates these as percentages for reporting.

I had to Google the OIDs because Frameflow reported the names differently to what's needed by PHP SNMPGET, so for example ".iso.org.dod.internet.mgmt.mib-" translates to "".  You can see there's a pattern.

In summary, the PHP gets a list of IPs, then queries each one for name/location/serial/toner and paper figures and prints this out on a web page.  Some fancy JQuery stuff (I don't pretend to know anything about this, I roped in our web developer for that) makes the nice progress bars.  The web page auto-refreshes every 60 seconds, and there's a 'last updated' timestamp and a countdown to the next update.  The background colour of each machine changes from green to amber to red depending on the printer's reported status.   I run it on a dedicated old laptop, running it in IE's kiosk mode and starting/stopping it on a scheduled task.  It fires up at 8am, then goes to sleep at 5pm.

I can't seem to display code very effectively on this website, so I've printed the code pages to pdfs if you want to download:

PHP main page
CSS stylesheet
JS countdown script

 webpage  frameflow  ink  paper 

EDIT Jan 2019 - Our Samsung contract has ended and the printers are being replaced with HP PageWide machines.  I can confirm that this information works with minor tweaking for the new HPs.