Wednesday, 1 April 2015

Use PowerShell to detect if a disk is an SSD

Update 2016-03-18: If you are on Windows 8 / Server 2012 or later, use the 'MediaType' attribute of the 'Get-PhysicalDisk' output. See the comments for more detail.

I was talking with some colleagues recently who were having trouble detecting if a disk was a Solid State Disk (SSD) or not in a lab environment. They wanted to run PowerShell scripts against the machines but found if the disk on the machine was a spindle disk it would cause an issue without a built-in delay. They wanted to detect if the disk was an SSD to remove the delay on machines that could handle it.

Easy I though. Just issue a Get-PhysicalDisk cmdlet and checkout the properties, no problem. Well that's what a PowerShell expert would think anyway. It turns out not to be the case.

After a lot of mucking about and searching I found there is no information reported from an ATA device to tell the operating system that it is an SSD. This makes sense I suppose seeing the concept of an SSD would have been unimaginable back when the interfaces were designed.

It turns out the best way to detect if an attached disk is an SSD or not is by reading two properties of the disk being, spindle speed (or rotation rate) and seek penalty. Neither of these properties are exposed by PowerShell or .NET.

Thanks to the Add-Type cmdlet and a guy from this blog (sorry, I can't find your name on the site), I created this PowerShell script to report if a disk is an SSD or not.

Simply copy the code to a script file and run it passing in a physical disk id number. It will return $true if the disk is an SSD, or $false if not. It will also return $false if exceptions occur in the Win32 DLL calls.

Wednesday, 2 July 2014

Intense PC 2 Unboxing and Review

I run a server at home. This is not surprising seeing as I am in the Information Technology industry. What I don't like is paying the electricity to run a server 24/7. Because of this I have been keen to get my hands on an Intense PC 2 ever since they were first announced.

The Intense PC 2 or IPC2 is a low powered computer the size of a box of savory biscuits.
If you compare its specifications to any other modern PC you would not be overly impressed. It is a standard Intel box with all the bells and whistles. What makes this beauty different is its power related to its size. Also, the IPC2 doesn't have any fans. As if those two features weren't enough, it only drinks 15 watts of power.

I'm not going to show too many details here because the manufacturer, CompuLab, can do that.

Waiting, Waiting, Waiting...

I contacted CompuLab when the IPC2 was first available for order and they replied stating that there would be a twelve week waiting period for a pre-order. OK, I don't like to wait but for this piece of engineering genius I suppose I will have to.

Zoom ahead twelve weeks and one day and last night I got my first IPC2 in the mail.   I had ordered an Intense PC 2 i7 Barebone which is the top of the line with no memory or hard disk supplied.

Once I got the device out of the box I installed the maximum 16GB of Kingston DDR3L low power RAM and a Samsung 512GB SSD PRO 840 Series hard disk drive.


After removing the delivery packaging I was surprised at the lack of marketing on the box itself. It is probably a good choice for a box that gets thrown in the bin once opened.

The only information on the box.

Inside the outer box was the instruction manual available from the website.

The included items below are the power brick and cable, HDMI to DVI adapter, COM mini port to 9 PIN adapter, Audio Cable, two WiFi Antennas, and a pack of screws and feet.

The inner box containing the IPC2.

And there she is. Quite heavy which is not surprising because of the amount of goodness jammed into it.

Front panel.

Back panel.

After taking out one screw the bottom cover slides out.

Two SODIMMs can be inserted on the right and just under my thumb is the SATA hard disk socket. The HDD gets screwed onto the cover plate above. An mSATA  drive could be used on the left as you can see.

Once I had the RAM and the hard disk installed the system booted up in seconds. I have installed Windows Server 2012 R2 to run Hyper-V for hosting all of my home virtual machines. I am currently hosting 11 virtual machines on this little power house. I went with Windows rather than Linux because this machine is also being used as an information station for the kids with a large touch screen monitor. I have tried Gnome with this monitor and was not happy with the touch support. Who would have thought the metro interface could come in handy?

Here is the final stand-up workstation with Audio Engine A5+ speakers, Logitech Wireless Combo MK270 mouse and keyboard, Dell 23 Touch Screen P2314T monitor on a Dell MSA14 Single Monitor Arm Stand. Also in the picture is my Bose SoundLink Mini bluetooth speaker. You can see the IPC2 on top of the right hand speaker. I will be getting a VESA mount for the IPC2 so I can screw it to the back of the sideboard.


I am very impressed with the build quality of the Intense PC 2.  I haven't run any benchmarks against the machine but my impressions are that the performance is extremely good considering it is only using 15 watts of power. Here are the benchmarks from CompuLabs site.   I have a mail server running as a virtual machine and the response on this machine is streets ahead of the old first generation i7 server I had.

I was also very pleasantly surprised to feel the temperature of this device. With around 30% CPU utilization for an hour (Windows Update had a bug causing this) it felt like the warmth you would get from your significant others hand on a steamy date.

If this little device has some longevity, which is yet to be seen, I will no longer buy machines that have fans on them. CompuLab may have just won themselves a long term evangelistic customer. If any of my future web projects take off, I will scale out using these little puppies.

Be aware if you are wanting to order an IPC2 you may still have to wait for supply as of July 2014. I don't know how long you will be waiting. A friend of mine at work is ordering one today because of my favorable impressions.

The waiting is over. If you order now you will most likely get a package in a week.

Sunday, 29 June 2014

Debian Screen Resolution when Hyper-V Guest

So I had a need to create a virtual machine on my laptop running Debian Jessie (Testing).   After the installation the screen resolution was limited to 1152x846.   This is a limit within Hyper-V.

I don't know why it took me a number of hours to find the fix for this but I found how to set the resolution on a blog called Random.GetNewEntry().

What is interesting about the fix is that it doesn't involve configuring X Windows. It is a simple change to the GRUB launch command.

I am keeping a copy of the changes needed here for my own reference, but 100 internets go to the owner of the blog.

  1. Edit the grub configuration file, for example:
    sudo vi /etc/default/grub
  2. Find the line starting with GRUB_CMDLINE_LINUX_DEFAULT, and add "video=hyperv_fb:1680x1050" (or your custom resolution) in between the quotes. For example: 
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1680x1050"
  3. Save and exit 
  4. Run 
    sudo update-grub
  5. Restart your computer

Monday, 13 January 2014

Delete Windows Driver Packages

Today I had a need to remove a driver from Windows 7 x64 on a Syspreped Operating System.
As it turned it is it very easy to do thanks to a built-in tool called pnputil.exe.

Simply run pnputil.exe -e to get a list of third party drivers.   I piped the output of the command into a text file with pnputil.exe -e > pnputil.txt

Then search the new text file for the driver you need to delete.

Lastly, delete the driver package with this command pnputil.exe -d oem1234.inf
You will have to supply the correct file name for the above command to work.

This is all documented on TechNet here;

Thursday, 28 November 2013

GIP the best PowerShell alias

I recently discovered the PowerShell alias GIP which runs the Get-NetIPConfiguration cmdlet.
This is the new ipconfig for PowerShell.
Here is the example for the straight gip command.

Here is gip with the -detailed option shortened to -det.

Isn't that great!
It might not be THE BEST PowerShell alias, but it is up there.   I think GCM would take that crown.

[Update] I just did a search and found a TechNet blog article about GIP and also TNC. TNC is an alias for Test-NetConnection and looks like a great alias also.   Read the article New Networking Diagnostics.

Thursday, 14 November 2013

Remove SkyDrive and Homegroup from Windows 8.1 File Explorer

Today I got sick of scrolling past SkyDrive and Homegroup nodes in the left pane of File Explorer in Windows 8.1.   I did a search and found a good post on Lifehacker and another post from a forum on how to remove them from the Explorer window.

Removing SkyDrive

I am adding the details here for my own reference but here is the link to the article from Lifehacker titled How to Get Rid of SkyDrive in Windows 8.1 Explorer.

The root of the change is to set a registry key called Attributes to a value of 0.   There is one problem though. The parent key called ShellFolder does not give read/write permissions to user accounts.   You will need to take ownership of the ShellFolder key and give your user account read/write permissions to change the Attributes value.

The key of interest is

Removing Homegroup

This one is a little easier.   Make sure you are not a member of any Homegroups and then disable two Homegroup related services in the services.msc utility.

The services are;

  • Homegroup Listener
  • Homegroup Provider

After you have made the above changes simply reboot the machine and the explorer windows will look like this;

Ah, that's better. No SkyDrive or Homegroup tree nodes.

Friday, 25 October 2013

Installing Harp on Debian Jessie

I recently came across the new open source web server called Harp.
Here is the description from the Harp website;

What is Harp?

Harp is a zero-configuration web server that is used to serve static assets. It has a built in asset pipeline for serving .jade, .markdown, .ejs, .coffee, .less, .styl as .html, .css, and .js. Harp supports a template agnostic layout/partial system and metadata for dynamically building files.

I thought I would take Harp for a drive around the block and decided to install it on a Debian Jessie virtual machine.
The installation process is rather easy except for one issue due to the Node.js package.

Here is the process to install Harp.

Firstly there are some prerequisites to get Harp installed being Node.js and npm, the package manager for Node.   I decided to install Node and npm using the Debian package repositories with these commands.

apt-get update
apt-get install nodejs npm

Once Node is installed, you can install Harp using the Node package manager.

npm install harp -g

The -g switch in the above command tells the package manager to make the Harp install global rather than a local directory install.

Harp is now installed and everything should be ready to go!   There is a problem though.   If you run the following command.

harp --version

You will get an error which is very misleading.

/usr/bin/env: node: No such file or directory

You can be forgiven for thinking that the harp binary was not found.   This is not the case.   The problem here is Harp is trying to call Node.js by using the command 'node' while on a Debian system the Node command is 'nodejs'.

This is easy to fix with the following symbolic link.   Simply run this command.

ln -s /usr/bin/nodejs /usr/bin/node

Now if you run Harp everything works as expected.

harp --version

All that is left is to follow the instructions on getting started to use the Harp web server.