Sunday, October 30, 2016

Changing Keyboard Shortcut Behavior in PowerShell Studio

I'm a big fan of SAPIEN's PowerShell Studio. The editor is fast and PrimalSense (their equivalent of intellisense) is rock solid, unlike intellisense in the PowerShell ISE, which mostly works...sometimes...if you're lucky.

One thing that I don't like is how the behavior of the F5 shortcut key differs from the ISE - F5 runs the script in their special sandbox session rather than within the shell itself. At the time of this writing, there is no way to change this behavior within the program itself.

Enter AutoHotkey. AutoHotkey is open-source macro-creation and automation software. In this instance, I'm using its macro abilities to send Ctrl+F8 (run script in shell) whenever F5 is pressed, but only when the PowerShell Studio window is active.

I also set up Scroll Lock to send Ctrl+Shift+A (expand aliases to Cmdlets) and Ctrl+Shift+J (format script). If you're wondering about whether or not pressing Scroll Lock for this macro causes it to turn on the light on your keyboard, it doesn't.

First, download and install AutoHotkey. After that, navigate to the directory where you want to store your script and create a new AutoHotkey Script via the right-click menu.

Next, open your newly-created ahk file in your favorite text editor, paste the following code into it and save.

#IfWinActive SAPIEN PowerShell Studio 20
SetTitleMatchMode, 1 ; Title must start with the specified text to be a match

f5:: ; Run script in console
 send, ^{f8}}

Scrolllock:: ; Expand aliases to Cmdlets and format script
 send, ^+a
 send, ^+j

Double-click the file and it will run. If you want to reload the script after making changes, or exit AutoHotkey completely, this can be done by right-clicking the green tray icon.

Once you're satisfied that everything is working as desired, place a shortcut to your ahk file in the startup directory and you're done.

Monday, September 5, 2016

Notepad++ Find in Files

Several months ago, I wrote a post about some of the cool things that Notepad++ can do. Today, I'm going to share another feature that saved me a lot of headache - Find in Files.

After installing an update to an important application, I discovered that the installation path had changed. This was a problem because I had a folder full of scripts that reference this path. Thanks to Notepad++, I was able to fix this in about 3 minutes.

Using Find in Files

This should go without saying, but before you make any modifications to your files, make sure that you have good backups of everything.

When you're confident that you're ready to modify your files, go to Search > Find in Files, or press Ctrl + Shift + F

Text files prior to text replacement

When the Dialog box appears, simply specify the text that you want to replace, and the folder that you want to search in, and click Replace in Files.

After the replace runs, all the files within that folder should have the applicable text replaced.

Text files after text replacement

Monday, August 1, 2016

Sending Windows Key Shortcuts Over RDP

If you use Windows keyboard shortcuts, such as Alt-Tab, Win-R, Win-E, etc. you may have noticed that when you use use them in an RDP session that isn't full-screen, the action occurs on your local machine rather than the remote machine. Annoying, right?

To change this behavior, open the RDP client and click Show Options.

Next, go to the Local Resources tab and set change the Apply Windows key combinations: setting to On the remote computer.

Finally, go back to the General tab and click Save so that the RDP client will default to this setting in the future.

Sunday, July 24, 2016

Fixing VMware Client Mouse Issues on Scaled Displays

If you have a high-resolution display and are running DPI scaling in Windows, you may have experienced how frustrating the VMware vSphere desktop client can be. Accessing the console of a VM is a maddening experience where the mouse refuses to cooperate and makes it nearly impossible to accomplish even the simplest tasks.

A workaround for this is to disable DPI scaling for the client. Browse to the installation directory, C:\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Launcher by default, and open the properties for VpxClient.exe. Under the Compatibility tab, check the box for "Disable display scaling on high DPI settings" and click OK.

The downside to this solution is that the client may appear tiny on your display because it's not being scaled like the rest of the desktop. It looks microscopic on my laptop's 15-inch 4k display, but at least it's usable. Fortunately, my laptop is docked most of the time, so I can just use the client on one of my larger external monitors.

Thursday, June 30, 2016

PowerCLI Error Updating Shortcut

I was trying to make the text bigger in the VMware PowerCLI shell. When I tried to apply the changes, an "Error Updating Shortcut" message. After clicking OK, the changes would apply, but wouldn't persist after closing re-opening.

This was happening because the program didn't have access to the shortcut, so it couldn't to modify it. To get around this error, simply run the console elevated (aka "as administrator"). The error should go away and the changes should persist.

Monday, June 20, 2016

Bringing NES Game Cartridges Back to Life

Not long ago, I discovered my old NES in a shed at my parents' house. I quickly ordered a new 72 pin connector (iFixit has a good write-up on installing this if you're interested), and a "simulated stereo" AV cable. With the new connector installed, I had an NES that, for all intents and purposes, worked as well as it did when it was new.

The console was squared away, but the games were a different story. Some games worked perfectly, others were hit or miss. There was even one game that wouldn't work at all.

In this post, I'm going to go over the method that I used to clean the cartridges in order to get them working reliably. Some cartridges will be completely worn out and no amount of cleaning can save them - some of them are over 30 years old, after all. However, all the cartridges that I've personally cleaned this way have worked afterwards.

While I use an NES cartridge in this example, the same method can be used on game cartridges for pretty much any system. Most other systems use a 4.5mm security bit rather than a 3.8mm.

What you'll need:
  • 3.8mm security bit driver - These are usually sold in sets that include both 3.8mm and 4.5mm drivers
  • Pencil eraser - The large pink erasers are best, but the eraser on the end of a pencil will work if you're only doing one or two games.
  • Cotton swabs
  • Rubbing alcohol

Disassemble the Cartridge

Remove the screws from the cartridge shell and separate the two halves, exposing the circuit board.

Clean the Contacts

Rub the pencil eraser over the contacts until they are clean and shiny. If the eraser gets gummed up, rub it on a sheet of paper to clean it. Once the contacts are clean, use a cotton swab and rubbing alcohol to clean off any eraser residue.

Re-Assemble the Cartridge

Re-assemble the cartridge by placing the circuit board into the front half of the cartridge shell. It will only go in one way (the side with the chips goes towards the label).  Be careful not to over-tighten the screws since they are just threaded into plastic. In most cases, the game will play perfectly.

Wednesday, May 25, 2016

Disabling Status LEDs on a Cisco Autonomous Access Point

To disable the status LEDs on a Cisco autonomous AP, run this command in global config mode (type "conf t" to enter global config mode).

led display off

To re-enable the LEDs, simply "no out" the command.

no led display off

If you're not in front of the AP and want to see whether or not the LEDs are disabled, use the "show run" command with some filtering.

sh run | include led display

If output is returned like this, the LEDs are disabled.

If no output is returned, the LEDs are enabled.

Monday, May 2, 2016

Rebooting a Windows Machine over RDP

If you regularly RDP into Windows machines, you've probably noticed that the options to shut down or restart are often missing. I've seen a lot of people work around this by opening a command prompt and running something like this.

shutdown /r /t 0

This works great, but there is an easier way. Hit Ctrl-Alt-End. This is the equivalent of hitting Ctrl-Alt-Delete when physically on a machine. You'll be greeted by the screen below, complete with a power button in the lower-right corner.

Sunday, April 3, 2016

Notepad++ Tips and Tricks

Notepad++ is one of my all-time favorite pieces of software. Whether I'm editing a text file, reviewing log files, or simply using it as a scratch pad to hold an IP address or some other piece of information that I need short-term, I use it virtually every day.

These are some of the useful functions that I've learned over the years. Some of these require additional plugins. To install plugins, go to Plugins > Plugin Manager > Show Plugin Manager.

Don't re-open previous session on startup

By default, Notepad++ will re-open the files from your previous session. While I'm sure that many users like this feature, I personally find it rather annoying.

To disable this, go to Settings > Preferences. Go to the Backup section and uncheck the "Remember current session for next launch" box.

Sorting Text

This requires the TextFX Characters plugin.

Highlight the lines that you want to sort, and go to TextFX > TextFX Tools, and choose whether you want to sort case sensitive or insensitive.

Executing Console Commands

This requires the NppExec plugin.

Thanks to the NppExec plugin, you can have a console embedded within Notepad++. Once you have NppExec installed, hit Ctrl-~ or go to Plugins > NppExec > Show Console Dialog to bring up the console.

The primary use case for this is using Notepad++ for development along with a command-line compiler, but you can perform pretty much any task that you can perform in the native Windows Command Prompt.

It's also more copy/paste friendly than the native Command Prompt. The only gotcha is that you'll have to use Ctrl-C/Ctrl-V because there is no context menu or Edit menu integration.

Comparing the Contents of Two Files

This requires the Compare plugin.

Open two files that you would like to compare, right-click on the tab for one of the files and choose Move to Other view.

This will show your files side-by-side.

Next, hit Alt-D or go to Plugins > Compare > Compare.

When you're done, you can clear the results by pressing Ctrl-Alt-D, or by going to Plugins > Compare > Clear Results.

Find/Replace New Lines

The first thing to do is determine the format of the text file that you're working with. Look at the lower status bar in the area shown below to see the format of the file that you're currently working with.

Open the standard replace dialog box by going to Edit > Replace or pressing Ctrl-H, and set the search mode to Extended.

Enter the appropriate newline character for the format of your file in the "Find what:" box, and whatever you want to replace it with in the "Replace with" box. The newline characters are:

Dos/Windows: \r\n
Unix: \n
Macintosh: \r

If you're curious about what the difference is between \r and \n, this thread on Stack Overflow has a good explanation.

Replacing new lines with commas

Tuesday, March 1, 2016

WSUS - Fatal Error: Illegal characters in path.

I was working on a WSUS server that was ready to complete its post-installation tasks. When I clicked Run...

...the post-installation tasks failed with Fatal Error: Illegal characters in path.

Looking at the log file referenced in the error was not helpful. The issue ended up being the trailing backslash in the path. After removing the backslash and clicking Run again, the post-installation tasks completed successfully.

It seems silly to me that Microsoft hasn't fixed this, but at least it's easy to work around once you figure out what the problem is.

Friday, February 19, 2016

USB Ports not Working on a Macbook Pro

A non-techie buddy of mine had the USB ports on his Macbook Pro randomly stop working. Luckily, fixing it was a simple matter of resetting the SMC (System Management Controller).

I followed these steps to reset the SMC:
  1. Connect the power supply
  2. Completely shut down the computer
  3. Hold down Control-Option-Shift as well as the Power button
  4. Release everything simultaneously
The light on the power supply connector will briefly blink/change color. After that, power on the computer normally.

The above process should work for any Apple laptop that has a non-removable battery. Instructions for resetting the SMC on other Apple computers are available here.

Friday, February 5, 2016

Installing IIS Manager on Windows 10

In this post, I'm going to cover how to install IIS manager in Windows 10 so that you can manage remote IIS servers from your workstation. This process should also work on Windows 7 and 8.1. I'm only installing IIS Manager, not any of the other IIS features.

First you'll need to "turn on" the IIS Management features. You can get to the screen through Change/Remove Programs, or just type optionalfeatures in the start menu search box and hit enter. Check the boxes for IIS Management Console and IIS Management Scripts and Tools, then click OK to install them.

At this point you can open IIS Manager, but it's pretty much useless. The option to connect to a remote server isn't there, and there aren't any local sites to manage since the other IIS role features aren't installed.

There is one final piece of the puzzle that you need in order to connect to remote servers. This doesn't appear to be very well documented. I learned about it thanks to a conversation with a co-worker.

You'll need to install the IIS Manager for Remote Administration extension. Download and install the extension, then open IIS Manager. There will now be a Start Page section at the top that you can right-click and Connect to a Server...

Enter the server name and credentials to connect. If you get an error that you can't connect, you may need to enable IIS remote management on the server. See this TechNet article for instructions.

The first time you connect to a server, you may get a notification that new features are available. Click OK and install these.

After that, you're all set.

Friday, January 8, 2016

Using iPerf 3 to Test Network Throughput

iPerf 3 is a lightweight, cross-platform, command-line tool for measuring network throughput between 2 hosts.



Simply download the appropriate (x86 or x64) version from the iPerf site, extract the archive to a location of your choice, and browse to that folder in a command prompt.

iPerf 3 on Windows


iPerf 3 is available from the default repositories in many distros. For example, you would run the following command to install iPerf3 on Ubuntu.

sudo apt-get install iperf3

If your distro doesn't have it in the repositories, you can download various binaries here.

iPerf 3 on Ubuntu


The easiest way to install iPerf 3 in OSX is to use Homebrew

Open a terminal and run this command to install Homebrew:

ruby -e "$(curl -fsSL"

Next, run this command to install iPerf3:

brew install iperf3

iPerf 3 on OSX


On the machine that you want to use as the server, run the following command.

iperf3 -s

This will start iPerf 3 in server mode, and it will listen for incoming connections.

iPerf 3 in server mode listening for incoming connections

Next, run the following command on the client machine:

iperf3 -c <hostname or IP of server>

For example:

iperf3 -c

iperf3 -c

A session will establish and a test will be run. The progress and results will be displayed on both the client and the server.

Test results as seen on the server

Test results as seen on the client

Advanced Options

iPerf 3 supports a number of command-line options that I didn't cover. To see a complete list of options, go to the iPerf user docs section of the iPerf site.