Import-Module and the "-Prefix" parameter

Lesson learned from the presentation “How to Position Yourself for the Future” with Jeffrey Snover and Jason Helmick (from the Q&A session at 1:01:17): you can add a prefix to the commands of a module when you import it!

In the Q&A session a guy from audience mentions that a PowerShell module (presumably PowerCLI from VMWware) breaks other PowerShell commands as there are Cmdlets/functions named like core or other modules Cmdlets.

So if you import the PowerCLI module it will provide you with the command Get-VM, which is a good idea if you want to manage virtual machines on vSphere, but nowadays you might also have a Hyper-V server you want to manage from that very same computer (maybe using RSAT) which also has the Cmdlet Get-VM. So now it is no longer possible to manage virtual machines on the Hyper-V servers (at least to run the Cmldet Get-VM against Hyper-V) unless you remove the PowerCLI module from that PowerShell instance (or specify explicitly that the command should be the one from the Hyper-V module).

It is not very likely that VMWare will change their commands anytime soon to not overwrite/conflict with other Cmdlets/functions. So what could you possible do manage both hypervisors within one script?

You can import the module which breaks your code with the parameter -Prefix.

Let’s see how this works. For demo purpose I will use the BitsTransfer module.

So importing the module “as usual” and getting the available commands gives you just what you expect.

But importing it with a prefix will add this very prefix to every command (after the verb-) of that module.

Very cool feature I did not yet know about.


As I was about to merge two influx databases into one, I was surprised that one could not use the CLI influx to both import and export data.

export influx measurement

To export data from a influx database I used the following command: influx -database home -format csv -execute "select * from temperature" > /tmp/temperature.csv The measurement temperature from database home is exported and saved into a CSV file.

import fails

My attempt to import the data as follows failed: influx -database private -format csv -path /tmp/temperature.csv -import 2018/02/17 12:33:03 error writing batch: {"error":"unable to parse ' ... ERROR: 11397 points were not inserted I did not RTFM but instead guessed the command/parameter combination which I thought would be reasonable. How naive I was!

formatting for the import

Turns out, the data has to be formatted like a normal insert; e.g.: temperature,sensor=livingroom temperature=21 One has to convert the data from the CSV export to be able to import it again …

alternative scripts

I found several scripts on github which all convert CSV files to influx. But those where all written in programming languagues which I neither had installed nor knew (as in “created at least 10 scripts in that language”). I was looking for a Bash script but couldn’t find any. And writing Bash scripts is not fun for me. Thus I wrote the PowerShell script ConvertTo-Influxdb.

running ConvertTo-Influx.ps1

Converting a CSV file into one which can be imported using the influx CLI goes like this: ConvertTo-Influx.ps1 -Path /tmp/temperature.csv -Database private > /tmp/temperature.influx The script takes two parameters (both mandatory): Path: the path to the CSV file Database: the database name you want the data to be imported to

import data into influx database

Once converted the data can be imported using the influx CLI: influx -path /tmp/temperature.influx -import

Firefox – disable autofill of saved logon data

Recently heise security reported that tracking scripts are (under certain conditions) able to read saved email addresses and passwords (full report and video). One could now panic or disable this automatism to instead fill in saved form data with two clicks “manually”.

To disable the automatism you enter about:config in the address bar and confirm the warning to be careful.

On top of the list you search for signon.autofillForms which has a value of true by default. To switch that value to false you double-click the value true - and that’s it.

disable MRU in Atom editor

The Atom Editor is a great hackable editor. Unfortunately it uses the default setting MRU when using CTRL+TAB to switch opened files (which is the wrong behaviour for me).

MRU (Most Resently Used) switches between the last accessed files in the very order they where used.

I don’t like that behaviour .. but as the editor is easy hackable I managed to disable/reset that setting.

Clicking on Edit > Keymap... opens a file named keymap.cson.

Appending the following few lines fixed the behaviour for me.

  'ctrl-tab ^ctrl': 'unset!'
  'ctrl-tab': 'pane:show-next-item'
  'ctrl-shift-tab ^ctrl': 'unset!'
  'ctrl-shift-tab': 'pane:show-previous-item'

Those lines are also easily removed once you want to test MRU again.

certificate error when initiating a RDP session using Remmina

Shortly after running the latest version of Remmina a new message “certificate changed” popped up.

As I connect to different VMs with the same IP address (e.g. with client A I connect to host “KA” and client B I connect to host “KB” using the same IP address this message totally makes sense as each VM has a unique certificate. But when I click on “OK” to accept the new certificate I get an error message.

Several posts on the web say that files in the folder ~/.freerdp/certs should be removed .. but this folder does not exist on my machine.

Others say they changed the RDP security from Negotiate to RDP .. but this also did not work for me.

Finally a blog post got me on the right track - there the programme xfreerdp was run via command line with the parameter /cert-ignore - this very parameter Ignore certificate can be configured right in Remmina .

using Remote Desktop Gateway with Remmina

Previously I was starting a Windows VM to do nothing else but connect to other Windows machines or VMs using Remote Desktop Gateways. Several weeks ago I was asked why I don’t use Remmina as it uses FreeRDP and this has the feature implemented. With a quick search I found an answer (from 2014) that I would have to compile FreeRDP myself. It was also mentioned that there was a feature request on the Remmina GitHub repo which one should upvote. There I found the information that it was already implemented …

So I double-checked if I was running the current version of Remmina. The Linux Mint Update Manager also did not show any updates.

Remmina was installed in version 1.1.2 - support for Remote Desktop Gateway was added in version 1.2.0 (which is currently available as PreRelease).

The wiki mentions that there is an official PPA for Remmina 1.2 which one can add and install the latest PreRelease with the following commands:

sudo apt-add-repository ppa:remmina-ppa-team/remmina-next
sudo apt-get update
sudo apt-get install remmina remmina-plugin-rdp remmina-plugin-gnome libfreerdp-plugins-standard

After updating Remmina with the latest PreRelease I can now successfully connect using RDG without firing up a VM every time.

DuckDuckGo - the search engine better than Google

Google hoarding data always worried me but the results where the best - no competitor could deliver results that good.

For many years I am using Firefox’s “keyword search”-feature. This feature (first introduced by Opera iirc) helps specifying the site/search engine within the address bar and may be just one character long.

If I type “searching the web using my default search engine” into the address bar and confirm it with return, the text will be searched with my default search machine (DuckDuckGo). But if i prepend a “g” followed by a space, the text will be searched by Google. Analogue if I configured to prepend an “a” for Amazon, “e” for Ebay and “d” for translations by

  • “g Porsche 911” searches on Google for “Porsche 911”
  • “a Porsche 911” searches on Amazon for “Porsche 911”
  • “e Porsche 911” searches on Ebay for “Porsche 911”
  • “gi Porsche 911” searches on Google Images for “Porsche 911”
  • etc.

So setting a default search engine is a comfort feature or me to not have to specify/prepend the search engine.

looking for Google-Alternatives

Every now and then I convinced myself to try “not Google” as my default search engine as colleagues where using Bing for all their searches - happily. So I once tried Yahoo, then Bing, ixquick, and MetaGer to be my default search engine. Also when switching I forced myself to use that search engine for at least one week. I’ve been doing this for the last two years searching for an alternative - everytime with the same result -> switching back to Google as my default search engine.

the difference

Until I tried DuckDuckGo. IIRC I tried DuckDuckGo some months ago and was not pleased (while writing this I think I might mistook it for ixquick). Nevertheless I switched my default browser again and was excited looking at that result when searching for “linux test wifi strength”. Not only was there a list of links pointing me to websites where the answer to my question might be found but the result from the top hit presented right under my search query.

For comparison the Googel result:

The advantage is obvious - instead of clicking on the first hit, there looking for the answer to my question you get the solution right at a glance. The “Google step” where you have to click on a result list to get the answer you are looking for is omitted. Awesome!

Not always .. but every now and then

This of course does not work with every search query but when I was searching for “php cast string” (and similar things about programming) the answer was right there.

And Google for comparison.

Nice also

Very nice also was the result for the search query “beautify html”.

DuckDuckGo itself can beautify obfuscated HTML no need to click my way to yet another web page - another click less for me.

MediaWiki update script "mediawiki-updater"

Because repetative tasks bore me (my principle is: “If you have to do something twice, automate it. Every time you have to do it again increases the likeliness of doing it again.”), I have written a two scripts to automate the task “update MediaWiki”.

As I manage installations on both Linux and Windows I created a Bash and a PowerShell script.

The files (and their requirements) can be found in the following repo:

Here are the steps the scripts do: 1. check if a new release is available 2. backup the MySQL database 3. backup (copy) the current installation 4. download new MediaWiki release 5. extract new MediaWiki release into a temporary directory 6. overwrite current installation (files) with the new release 7. delete the directory “vendor” 8. clone the external libraries into the directory “vendor” using git 9. delete old backups (but keep the last 3) 10. run the script “maintenance/update.php”

While creating these I thought of running them by cron/scheduled task. They are not yet perfect for that - but I was able to successfully update my installations from version 1.28.2 to 1.29.0 by manually running them.

Hope it helps you automate that task also.

toggle window "always on top" via shortcut

When I use Windows I still use the aged tool WinSplit which brings the shortcut “CTRL+ALT+O” with it. This keeps the current window always on top of all other.

I wanted this functionality (and the shortcut) also on my laptop which is running Linux Mint.

This works without any additional software as the functionality is built-in and available via the context menu of every programme icon.

And a programme to add shortcuts exists also.

So, starting the programme “Keyboard Shortcuts” and click the “Add”-Button.

Entering a name and the following as the command:

wmctrl -r :ACTIVE: -b toggle,above

Once the shortcut is added you click on the column “Shortcut” of if (where it says “Disabled”).

Now you can add the favoured shorcut by simply pressing it.

SikuliX - pressing key combinations

I just wanted to quickly automate a task using my favourite tool SikuliX. Therefore I had to make it press a key combination. Trial and error with the first web-results did not work.

First, because the syntax seems to have changed and second, because I ignored upper and lower case in my test scripts - which SikuliX does not.

Here are some examples of key combinations you can use in SikuliX:

type(Key.HOME, KeyModifier.CTRL)

# ALT+F4
type(Key.F4, KeyModifier.ALT)

# CTRL+v
type('v', KeyModifier.CTRL)

type(Key.ESC, KeyModifier.CTRL+KeyModifier.ALT)