PowerShell as a Backup Solution

This is a quick PowerShell (PS) way of creating backups for your documents.

I have another post that uses robocopy. I tend to like the robocopy solution more because it can be smarter about copying files only if they don’t already exist in the destination (the backup location).

On the backup location, place the code below on a text file named backup.ps1.

# the line below stops the execution of the file when a
# line errors out
$ErrorActionPreference = "Stop"

$folderName = ".\$((Get-Date).ToString('yyyy-MM-dd'))"

echo "---- Creating dated folder"
New-Item -ItemType Directory -Path $folderName

echo "---- Copying C:\home\docs into dated folder"
Copy-Item C:\home\docs $folderName -recurse -Force

Edit and add the lines that start with Copy-Item so they copy the folders you are interested in.

On the same folder that contains backup.ps1, create a text file named run-backup.bat and make it have these contents:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -File backup.ps1 > last-execution.log 2>&1

run-backup.bat makes it so

  • You don’t get an error saying “backup.ps1 cannot be loaded because running scripts is disabled on this system. See about_execution_Policies”
  • The output of backup.ps1 makes it to the last-execution.log file

Getting Git to work with a Self Signed or Corporate Issued Certificate

If you’re getting this error when using Git on the command line or in Visual Studio:

fatal: unable to access ‘https://myserver/tfs/DefaultCollection/_git/Proj/’: SSL certificate problem: unable to get local issuer certificate

This post is just for you!

The issue is that Git does not trust the certificate from “myserver”. To get git to trust it, you must set it up on Git’s certificate store.

Step 1: Getting the root certificate

  1. Open Chrome and type https://myserver (where I work it’s https://tfs )
  2. Hit F12
  3. Go to the Security Tab
  4. Click “View certificate”
  5. Go to the “Certification Path” tab
  6. Select the root certificate (at my work it’s CTAC-DR0-RCA….)
  7. Click “View Certificate”
  8. Go to the “Details” tab
  9. Click “Copy to File”
  10. On the step that asks “Select the format you want to use:”
  11. Select “Base-64 encoded X.509 (.CER)”
  12. Save the certificate on your computer, you will need it in a further step. I called it ctac-root.cer

Step 2. Add the root cert to git’s certificate store

  1. This will make the error go away from the command line. If you only want to fix it for Visual Studio, go to Step 3.
  2. Go to C:\Program Files\Git\mingw64\ssl\certs\
  3. Copy ca-bundle.crt to ca-bundle.crt.orig as a backup
  4. Open ctac-root.cer (created in step 1)
  5. Open ca-bundle.crt in a text editor
    • Since you will edit it, open it in a program as an administrator.
    • If you are not an admin of the box, follow this post to make a user specific certificate store.
  6. Append the contents of ctac-root.cer (created in Step 1) to the end of ca-bundle.crt

Step 3. Add the root cert to Visual Studio’s Git certificate store

  1. Follow the instructions in Step 2 with the ca-bundle.crt found on C:\Program Files (x86)\Microsoft Visual Studio\2017\[Enterprise|Professional]\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\ssl\certs

You’re all set!

Installing “Active Directory Users and Computers”

I often need to know what users belong to an AD group. To do this you need to install the “Active Directory Users and Computers” feature.


This feature comes as a part of the “Remote Server Administration Tools for Windows 10” installer.

After installing it you can open it by hitting the Windows key and typing “Active Directory Users and Computers”. You can then right click the AD node on the left and select “Find…”.

Google’s Project Fi will not save you from bad cell reception at your home

The only cell phone network with decent signal at my house is Verizon. Verizon is an OK company; they have good customer service. My only complain is they are expensive.

I love the Google ecosystem so I got very excited when I heard about Project Fi. I waited until the Nexus 6P’s price dropped (when The Pixel came out) to switch over to Project Fi.

One of the big features of Project Fi is that it can switch from Wi-Fi to cell towers (of 3 cell networks) seamlessly while you have a call going on. And it can also switch from any of the 3 cell networks seamlessly picking the one you have best reception with.

I made the switch over to Fi.

It was no surprise to me that the 3 cell networks Fi is currently partnered with (Sprint, T-Mobile, U.S. Cellular) had less reception than Verizon.

But this is where Google Fi began to fail for me: It is not smart enough to know that my Wi-Fi quality is better than the cell tower quality. From my home, it still tries to use the towers even though the tower call quality is unacceptable.

I called Fi support to complain and they mentioned they could update my settings so Wi-Fi took precedence over cell towers. It was annoying to have to call to get them to do what I thought the phone would have done on it’s own based on the advertising on Fi’s website. It was also disappointing that it was always going to choose Wi-Fi when it was available as opposed to finding the best call quality comparing both Wi-Fi and cell towers.

Then came the final disappointment. All Wi-Fi calls have a strange echo heard by the non-Fi person on the call. At this point all my calls at home were going through Wi-Fi; I thought this was going to work out great. But then we noticed that the person on the other side of the call would ALWAYS hear a 1 second delayed echo of themselves. Everyone thought it was annoying and some could not even talk to me because they were so distracted by listening to their voice.

This echo was experienced also on Google Hangouts calls. Others (see here and here) are experiencing the same thing. Wi-Fi calls with Skype, WhatsApp, and Boss Revolution work fine even though support tried to blame it on all Wi-Fi calls for a little while.

Sadly, I had to cancel the service. Cell phone call quality is already crappy (compared to the good old land lines) when things are working as expected; anything worse than that is unacceptable.


Figuring out what assembly is trying to load a specific (missing) DLL version in .NET

If you ‘re running into an error similar to this one:

The type initializer for 'YourNamespace.Program' threw an exception.
---> System.IO.FileLoadException: Could not load file or assembly 'log4net, Version=, Culture=neutral, PublicKeyToken=8774c74090335470' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at YourNamespace.Program..cctor()
   --- End of inner exception stack trace ---
   at YourNamespace.Program.Main()

Then post is for you!

What’s happening here is that Program is referencing a log4net dll version But another, currently unidentified, DLL that Program is referencing is looking for version .

There are two ways of fixing this.

  1. Adding an assembly redirect in the app.config or web.config
  2. Recompiling the unidentified DLL with log4net version

In this post I’ll focus on the recompiling approach. The first thing we need to do is identify the unidentified DLL we talked about above. To do this:

  1. Open the “Developer Command Prompt for VS2015” as an administrator.
    • Not sure if you really need to be an admin; doing it just in case.
  2. Type “fuslogvw” and hit enter
  3. Click the Settings button
  4. Select “Log bind failures to disk” and click OK
  5. Click the “Delete All” button
  6. Make your dll error happen again
  7. Click the Refresh button on fuslogvw
  8. You should see the dll binding failure displayed on the report
  9. Double click the failure.
  10. The report is an HTM file that you can open with your preferred web browser.
  11. This report will tell us the name of the unidentified DLL
  12. You can now recompile the now identified DLL with the same DLL version that your main Program is referencing.
    • If the identified DLL does not belong to you, meaning you can’t recompile it, you need to add an assembly redirect on your app.config or web.config.

Why I went back to Android from iPhone

I’m a long-time Android power user. I’ve been using Android for about 10 years now and always wondered why some people loved iPhones. So I decided to try one out. My plan was to stick to the phone for 6 months to make sure I gave it a good shot; but after 2 months of using it; I decided it was not worth it and went back to Android.

The phones I compared were an iPhone 7 and a Samsung Galaxy S7.

The iPhone 7 was not all bad. Here are the areas where it felt superior (note they are all hardware related):

  • Camera is slightly quicker
  • Finger print scanner is quicker

Here is where Android was superior (note they are all software related):

  • Back button
    • The placement is the same across apps.
    • You can always reach it with your thumb where the optimal grip of your phone is not jeopardized
      • the iPhone has it at the top left or top right. Both places are not optimal for how common you do this action.
  • You can customize the position of your home screen icons.
    • the iPhone only lets you customize the sort, but they are always positioned from top to bottom. And again, the top of the phone is really hard to reach; why do they force their users to use it?
  • You can install apps from the web browser
    • On the iPhone, all your app research has to be done either on the phone or on iTunes, none of which let you open multiple tabs at the same time.
  • Custom mp3 ringtones are easy to set up.
    • On the iPhone you need iTunes and the ringtone has to be converted to a spceific codec. I was not able to convert my special mp3 ringtone to that format; not sure why.
  • Does a better job at embracing the cloud
    • You can access all your photos/documents on any device (pc, phone, tablet) that has a web browser.
      • This means you can go to your buddy’s computer and just log in to a website to see all your photos. Same thing with your documents, spreadsheets, etc.
    • The iPhone also syncs things to the cloud but they are not that easily accessible from devices that are not yours.
  • Allows you to install apps that can read/send text messages.
    • This enables magnificent apps like MightyText where you can enter the text message on a web browser running on a desktop and send it through your mobile phone.
    • The iPhone allows you to send text messages from a desktop or laptop but you have to use their apps that only run on Mac OS. This means the desktop or laptop has to be a Mac.
  • This one is very worthy of a bullet: You don’t have to use iTunes.
    • Granted that you really only need iTunes to do power user things on your iPhone.


Both are good phones and operating systems.

The iPhone has superior hardware. If you don’t like to customize things and you use your phone mostly for normal things (phone, calendar, maps); you will prefer this phone.

Android has a superior UI and is way more customizeable. If you are a power user that enjoys tons of app choices; this is definitely the phone for you.

Analyzing IIS C# Memory Leaks

There comes a day in a developer’s life when you have a memory leak. This is not too common in the C# world but it happens. When it happens it is usually in production; and it spoils your day for sure.

In this post I’ll show you how to get a memory dump of the IIS process running your website (application pool) and then I’ll show you how to open it an analyze it.

Step 1: Getting the Memory Dump

Go to the server (production, staging, dev, wherever) where the memory leak is happening.

  1. Open up the Task Manager
  2. Click on the Details tab
  3. Right click on any of the existing column headers (name/PID/status)
  4. Click on “Select Columns”
  5. Check the “Command Line” column and hit OK
  6. Sort the list of processes by Name
  7. Find all the w3wp.exe processes
  8. Identify the one running your app pool by looking at the “Command line” OR “User name” column
  9. Right click on the process
  10. Click “Create dump file”

Step 2: Analyzing the Dump File

There are several tools for analyzing Dump Files. Visual Studio (VS) has that functionality as well and chances are you already have VS installed on your machine.

To see the C# type (class name) that is using tons of memory:

  1. Take the dump file generated in Step 1 and place it in the machine that has VS installed.
  2. Open Visual Studio
  3. Go to File>Open>File
  4. Open the Dump File
  5. This will open the Minidump File Summary
  6. On the Actions section of the report hit “Debug Managed Memory”
  7. This opens the Managed Memory report
  8. Sort the report by “Inclusive Size” descending
  9. The types at the top of the list are the ones using up all your memory

From here you are on your own. You need to understand what those types do and why they are using all the memory. On my particular situation, my IoC container was set up to use singletons on tons of WCF client classes. I registered those types as transcients in the container; that solved my problem.

Best Way to Store a Yakima Cargo Box in Your Garage

The Yakima Cargo Box I own is a RocketBox Pro 14. I used cables, pulleys, and a winch to hang it right on top of where I park my car. When I winch it down, it lands right on my car’s cross bars.


The box fits well on top of the opened garage door. You can see that and the winch on this pic:


On this pic you can see the pulleys and cables:


This final pic has the car right under the box:


This project was a lot of fun; it involved pulleys and a winch! I thought I’d share this in case someone’s looking for ideas.

TVP Helper for Dapper ORM

I’ve used this TVP (Table Valued Parameter) helper for Dapper for quite some time now and I thought I’d share it here in case someone also thinks it is super cool.

It’s really just a wrapper around the existing AsTableValuedParameter method that comes with Dapper. The wrapper helps you quickly build a DataTable from any type of collection.

With this small helper method:

public SqlMapper.ICustomQueryParameter ToTvp<T>(
    IEnumerable<T> enumerable,
    params Func<T, object>[] columnSelectors)
    if (columnSelectors.Length == 0)
        Func<T, object> getSelf = x => x;
        columnSelectors = new[] { getSelf };
    var result = new DataTable();
    foreach (var selector in columnSelectors)
    foreach (var item in enumerable)
        var colValues = columnSelectors.Select(selector => selector(item)).ToArray();
    return result.AsTableValuedParameter();

You can now create TVP parameters super easy and feed them to Dapper like this:

string[] names = GenerateNames(generatedNamesCount);
var namesTvp = ToTvp(names);
    new {Names = namesTvp},
    commandType: CommandType.StoredProcedure);


string[] names = GenerateNames(generatedNamesCount);
User[] users = names.Select(x => new User {Name = x, Email = x + "@1800.com"}).ToArray();
var usersTvp = ToTvp(users, x => x.Name, x => x.Email);
    new {Users = usersTvp},
    commandType: CommandType.StoredProcedure);

EMF Meter Comparison (ED88T, ED78S, Trifield 100XE)

After searching for the right EMF meter for my home, I decided to buy the Cornet ED88T. On this post you will find why.

These are four types of EMFs that you want to measure in areas where you spend a significant amount of time:

  1. Microwave Radiation
    • Sources: wireless technology like Wi-Fi routers, cell towers, cordless phones and “smart” meters
  2. Magnetic Fields
    • Sources: power lines, improper home wiring and appliances
    • Health: They decrease the immune system and are known to be carcinogenic3
  3. Electric Fields
    • Sources: unshielded electrical wiring
    • Health: They rob you of a good night’s sleep3
  4. Dirty Electricity
    • DE are the frequencies that travel on your home wiring from things like solar power inverters, florescent lighting, dimmer switches and wireless “smart” meters)
EMF type Cornet ED88T Cornet ED78S Trifield 100XE
Microwave Radiation  Yes  Yes  Yes, but not accurate2
Magnetic Fields  Yes  Yes  Yes
Electric Fields   Yes, but the scale is not ideal1  No Yes, but the scale is not ideal2
Dirty Electricity  No  No  No

Once you have the ED88T, you can watch this video to learn how to use it and you’ll probably wonder what the safe maximums are for all the readings:

EMF type Safe Max3 Safe Max in Cornet ED88T screen readings
Microwave Radiation  100 (day) 10 (sleep) microWatts/squared meters (uW/m2)  0.1000(day), 0.0100 (sleep) miliWatts/squared meters (mW/m2)
Magnetic Fields 1.0 milliGauss (mG)  00.10 microTesla (uT)
Electric Fields  Less than 10 V/m  0010. V/M
Dirty Electricity 25-50 Graham-Stetzer Units

Here are some of the readings I’ve collected.