Mar 09 2017

Move RDS profiles to another volume/drive

Published by under Windows

You’re in charge of a Remote Desktop Services (RDS) server but unfortunately, C: drive starts running out of space, RDS profiles being on that same volume.
Lucky enough, a huge amount of space remains on D: drive, but how shall I migrate?
You can run a GPO that creates new profiles in D: like this:
Computer Configuration -> Administrative Templates -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host -> Profiles -> Set path for Remote Desktop Services Roaming Profiles
It works for new profiles but older ones need to be moved as follow:
– Migrate user folder from C: to the new drive and assign proper rights.
If older profiles connect with a temporary profile, you should also:
– Remove the entry in Control Panel -> User accounts -> Configure user profiles advanced properties.
– Remove the registry entry HKLM\Software\Microsoft\Windows NT\CurrentVerison\ProfileList\S-1-5-21… with a ProfileImagePath key matching the user profile path
Advantage: All new profiles will be in this new location
Edit the path in the above registry key, move the profile folder to the new location and assign user’s rights.
New profiles will still be created on C: but you can migrate some on D: as you wish, and spread data on 2 volumes.
The best is clearly to define a GPO right from the start on a dedicated volume other than C:


No responses yet

Oct 06 2016

Processing CSV Files with Perl and Bash

Published by under Linux

Olivier, a friend of mine, had to parse a CSV file and took the opportunity to benchmark the performance of 3 programming languages.
The file contains server names and disks he needs to add up into a hash table in order to get the total disk space for each server. He assumes on his blog Perl, Python and Golang are much faster than Bash. He is definitely right but, how much faster?
The following (slightly modified) Perl script processed 600k lines in less than a second. Not bad knowing Perl is an interpreted language.

my $file = 'sample.csv';
my %data;
open(my $fh, '<', $file) or die "Can't read file '$file' [$!]\n";
while ( my ($server,$value)=split(/,/,<$fh>)) {
    $data{$server} += $value;
close ($file);

Now, here’s a similar code in bash

declare -A data
while read -r line; do
  values=($(echo $line|awk -F, '{print $1" "$2}'))
  (( data[${values[0]}] += ${values[1]} ))
done < "$file"

The file was processed in over 19 minutes, or in other words, around 1200 times slower!
Let's see if we can improve the script's performance.
The read command man page states something of interest:
"The characters in IFS are used to split the line into words".
Setting comma as the default separator allows to build the $line variable as an array, saving the hassle of parsing each line and using a temporary variable.

declare -A data
while read -a line; do
  (( data[${line[0]}] += ${line[1]} ))
done < "$file"

This new version runs in the smooth time of... 17s! This is 17 times slower than Perl, but 70 times faster than the original version.
No doubt Perl and Python are much faster than the shell family languages, but one needs to pay attention to small details when it comes to performance issues.


No responses yet

Oct 02 2016

Microsoft Exchange Multiple Mail Relays

Published by under Exchange

This works for Exchange 2003, 2007, 2010 and 2013. Haven’t tested on 2016 but it should. Please let me know if you do.
You have an Exchange server (or cluster) that communicates to the outside through a mail relay (also called smarthost), usually in the DMZ. You’d now like to double the infrastructure on a second site – siteB – in case something goes wrong on site A, meaning a relay on each site, with their own Internet connection.
Routing incoming mail is only a matter of creating DNS MX records for each mail relay and forwarding mail to Exchange servers. External mail servers will automatically fall back to the second mail relay if the first goes down.
Routing mail to the outside can be a bit more complicated.
If you add a 2nd mail relay to the Exchange send connector, it will load balance emails over the 2 relays wether they’re up or not, and will not fail over. But there is a way.
Create DNS entries for relays, each in his own subdomain:
These could be aliases indeed pointing to real hostnames.
Create 2 MX records for siteA subdomain, the local relay having the lowest number (highest priority):	3600	IN	MX	5	3600	IN	MX	10

Do the same for siteB if there’s also an Exchange server on the site.
All you need to do is to create a send connector pointing to Before resolving the DNS hostname, Exchange will first attempt to do an MX lookup, even though this is not clearly stated in Exchange EAC.

With this flexible solution, you have loads of possible setups. You could:
– Send traffic to the local relay and fail over to the remote site
– Load balance the traffic on the 2 sites and fail over if one goes down (same MX priority)
– Load balance the traffic on 2 local mail relays and failover to a single remote (two equal high priority MX and a lower for the remote relay)
And so on
All is fully automated if a relay becomes unreachable and new relay hosts are managed through DNS. Simple, really


No responses yet

« Prev - Next »