Jumlins TechBlog

The coding hell and the daily IT of Niklas Jumlin

September 12th, 2018 by Niklas Jumlin

I found a need to convert ImmutableID (An Azure AD/Office 365 attribute) back and forth to a Hexadecimal-, GUID- and DN value, this in order to match the value to an on-premise Active Directory user.

So I wrote a little script that does all the conversions back and forth to all kinds of formats that I could think of.

Read the rest of this entry »

May 13th, 2015 by Niklas Jumlin

I recently wrote this script to schedule Memory and vCPU up/downgrades on virtual machines from a VMware PowerCLI enabled vCenter server running Windows.
The script is built upon many useful parts from a script that I found here:

I mainly had to make changes in order for the script to be able to run from Task Scheduler. First of, the script needed to be executed as a different account, one that has permissions in your VMware Cluster to reboot and change configuration of virtual machines. So I created the user svc_sched_script in VMware vCenter and gave it enough permission.

I then needed to save the password (not in clear text) and pass it to the script somehow.

Read the rest of this entry »

January 9th, 2013 by Niklas Jumlin

I found this really cool open source software that I’m currently implementing for a customer remotely.

It’s called HVBackup and is of the time of writing in Beta v1.

Description from their website:

The main goal of this project is to provide a very easy and powerful free tool to backup and restore Hyper-V virtual machines, in standalone and clustered (CSV) environments, overcoming all the limitations that a generic tool like Diskshadow provides.

This tool targets Windows 2008, Windows 2008 R2 and Windows 8 / Windows Server 2012. All the corresponding core and free Hyper-V editions are also supported!

HVBackup supports app consistent and crash consistent backups through the Hyper V VSS writer component integrated in the operating system.

There are quite a few expensive commercial solutions on the market supporting this scenario, but this is the first open source one, based on the research we did before publishing the project.

We integrated this tool in our datacenter’s production environment management infrastructure, which means that it undergoes continuous testing in a real world environment :-)

HVBackup can be invoked from the command line, scripted with Powershell or integrated in any .Net program through it’s class library.

The backup process generates a separate zip file for each virtual machine in the specified output directory, containing all the files owned by the VM and identified for backup by the VSS Hyper-V provider.

My script for the tool is essentially the same as theirs, only that I’m slightly changing the way files are archived. Check it out below.

Read the rest of this entry »

May 24th, 2012 by Niklas Jumlin

At work I was tasked with writing a script that would clean up and archive logs from an application that didn’t have any decent log rotation built-in. The application would however rotate the logs when the application’s service was restarted and then rename the old log with an incremental number suffix. So we added a scheduled task that would restart the service every night in order to get the logs rotated and free from being locked.

So what this script will do is to take any log which contains a number at the end and archive it to another location, it will then replace the archives last modified date to the original last modified date of the actual log file. After that it will simply delete archives older than X-days based on its last modified date and time.

You can of course configure the script to look for logs named in a different way. This is quite simple:

## Define files to match
$LogFileMatch = "*scplog?"
## * = Any or none characters
## ? = Any character (Must be one)

The script will log events to screen and also to a log file.
It will also log every event to Windows built-in EventLog if executed with administrator privileges.
The script will also handle all exit codes from 7-zip command-line which is the program it’s utilizing in order to archive files.

Configuration settings that can and should be edited in the script are commented at the top of the script.

Read the rest of this entry »

May 11th, 2012 by Niklas Jumlin

I wrote a script that utilizes RoboCopy to mirror directories. It can easily be changed to do file level backups by changing some configurable parameters within the script. Read RoboCopys documentation to understand the use of switches.

Whats interesting about this script is that it writes events/logs to EventLog if executed with administrative privileges, otherwise it will just fallback to logging to file and screen.

Read the rest of this entry »

February 24th, 2011 by Niklas Jumlin

I couldn’t find any unpacker that would extract and delete archives for a torrent after a certain period of time or after a certain seed ratio had been reached. I’ve noticed quite alot of people complain about this on, for example, uTorrent’s official forums.

So I wrote this script that will wait for a set amount of hours when a torrent finishes before extracting, deleting archives, moving files into its right location, scraping with EMM or EMM-R (command-line) AND notify XBMC of your new download and update its library.

This script will NOT stop your torrents.
Read the rest of this entry »

December 23rd, 2010 by Niklas Jumlin

Well I had started to write a guide for this already, but just when I was to create this entry I came across a guide that’s already really good.

So I’m just going to link to Pete Long’s blog where I found it:


October 26th, 2010 by Niklas Jumlin

A colleague asked me if I could write a script that would move files within a folder or its subfolders that were older than one year into a new location but still keep the directory structure.
I figured it would be quite a challenge so I decided to do it for him; kind as I am =)

As I haven’t been providing this blog with something new in a long time I figured I could make it useful to more people if I added a few things, like different date formats and other various settings.

So here it goes:
Read the rest of this entry »

July 28th, 2010 by Dennis

Having to synchronize some data among a Debian linux cluster, i settled on using csync2 for the job.
Here’s a short guide to set it up.
Read the rest of this entry »

July 17th, 2010 by Niklas Jumlin

I was given the task to rewrite the login script for a company, they had 4 sites and about 20 login scripts for various purposes.
So I wrote a general one which took care of all the general stuff.

You may look at my earlier post about an inventory script, because this script will use that one.

Read the rest of this entry »