Category Archives: Tools

Powershell: How to manage Hyper-V VMs in Windows 10

I am using Windows 10 since it’s first release. So far I am happy with it and had no issues. With it comes Hyper-V to deploy VMs. I normally do not install 3rd party tools until its absolutely necessary. Therefore I started using Hyper-V to run my DB server as well as Linux servers.

To manage VMs under Hyper-V, we have two options. One is to use “Hyper-V Manager” and second one is to use “Power Shell”. First one is pretty common and easy to use, but that second method is very interesting. The following post is about what i have learned so far the commandlets to work with Hyper-V. I know the following is not full information but I keep updating this post with latest information. So lets jump in;

Show all VMs under Hyper-V:

To list all the VMs available under Hyper-V, use the following command;

 get-vm

This command list all the VMs available under Hyper-V. Here is the output;

image

In my case  I have Windows 2003 as my DB server and Ubuntu 15.10. Here, VM is short form of Get-VM.

Start a VM:

To start a VM, fire the following command;

start-vm win2k3

The above command starts the VM with the name “win2k3”. Powershell shows a progress bar on top of the screen. The following is the current status of my VMs. Look at the status of VM WIN2K3;

image

Save a VM:

In order to save the current VM state, simply issue the below command;

 save-vm win2k3

This command saves the current status of the VM and again Powrshell shows a progress bar to indicate the progress. Now look at my current state of VMs

image

Stop a VM:

Now you pretty much guessed the next command;

stop-vm win2k3

The above command, stops the running VM. If the current sate of the VM is “Saved” and if you issued this command to stop the VM then Powershell prompts you with the following;

Confirm

Hyper-V can’t shut down virtual machine “WIN2K3” because the Shutdown integration service is

unavailable. You can turn off the virtual machine by selecting [Y]es, but this is similar to

pulling the power on a physical machine. To avoid potential data loss, select [N]o, then pause

or save the virtual machine. Do you want to turn off the virtual machine?

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is “Y”):

Therefore make sure the VM is in running state before you issue this command. Now check my current VM state;

image

Take a Snapshot

To take the snapshot fo the VM, issue the following command;

 checkpoint-vm -VMName win2k3

For more awesome Hyper-V commands visit here.

 

 

Advertisements

ConEMU, A better way for console management in Windows

For server administrators and deep dive developers console is a vital helper. Some times it is very hard to maintain more than two consoles on the screens. Since they consume a good amount of real-estate on the desktop, it is very hard when you want to run background scripts or self-host WCF applications. The good news is there are few alternatives to default console on the Windows desktop or server. I am regularly using one of them and following lines are some brief account on it.

ConEMU

ConEMU is a short form from Console Emulator. This is really a versatile emulator where you can run multiple console application in tabs.

image

You can add your own console applications as tasks in this emulator. Once you added, they are available right on the screen to kick off. Also you can run any of the console application as Administrator.

image

I normally run, default console, admin console, FAR Manager and SQL Plus for my oracle database concurrently for my regular operations.

image

Another useful feature is, you can copy and command output on this console by just selecting the lines. Once you release the mouse, the selected lines will be placed into clipboard and ready to past anywhere you want.

You can download ConEMU from here.

I will update this post with details about different tasks that we can do this this console emulator.