Skip to content

Archive

Tag: Scripting

Shrinking disks on your Hyper-V guests

A few of my guests run on SSD drives. Occasionally I reclaim diskspace by defragmenting and compacting the VHD;s. I have managed to free up to 20GB diskspace on a single guest, which is pretty much SSD wise. However, first of all, you should consider before putting R/W intense operations, such as VMs, on your SSD;s.

 

Since this is a process that will take quite some time I wanted to make it as automated as possible.

 

1. Defrag with Raxco perfect disk. This script is run remotely on the target machines. Errorhandling is omitted for readability.

 

2. Compact VHD:s. Run in powershell on the Host. Make sure the actual VM is turned off.

 

There is no easy way to Pin items to the Start Menu or on the Taskbar, it is by design to prevent programs filling up these locations ( http://technet.microsoft.com/en-us/magazine/2006.01.windowsconfidential.aspx ). However it is possible to script the pinned items.

 

When you rightclick on an object (shortcut / file) in explorer, you are presented with a context menu. These actions are known as “Shortcut Menu items” or “Verbs” in shell terms. These verbs can be enumerated and executed programmatically.

rclickmenu

 

Example to get all verbs on the Internet Explorer link:

 

Result from the example above:
verbresult

 

When scripting, you basically point out the object , and apply an action(verb):