Category Archives: Windows User Series

Contains blog posts related to my experience as a Microsoft Windows (both desktop and server) user.

Free download: Blog Yearbook 2016

I have made a compilation of all my blog posts of the past year, and it was more work than you would think.
Especially because it also contains a non-published new article.

After filling in the form you can download the e-book for free.

I promise you the following:

  • I will not give or sell your email address to any third party.
  • I will not spam you.
  • If I start with a newsletter, you can easily unsubscribe or change the frequency.

(c) 2016 hansmichiels.com – Do not steal the contents – spread the link instead – thank you.

A naming convention for virtual machines and home networks (Windows User Series)

Introduction

If you are a professional working in the Information Technology Domain you might have set up virtual machines to test different software versions, do Proofs of Concept or just use them for the ease of backup and restore.
But what name do you give those virtual machines?
As long as it are only a few, it doesn’t really matter.

Challenge

It becomes a bit of a challenge when you are have different virtual machines all with a specific setup, e.g. different versions of the same software.
Recognizable?

Solution

I want to share my naming convention that I use for virtual machines and my home network.
It is pulled together from different sources in the internet, as well as my own insight, so don’t be surprised if you see parts of other standards.

My device names consist of the following parts:
1. Device type
2. Operating System Line
3. Operating System Version
4. Separator
5. Purpose of the device
6. Sequence number

A naming convention for virtual machines and home networks

1. Device type

Minimum and maximum length

Device type is a single character.

Domain values

Namepart Description
V Virtual Machine
S Physical Server
L Physical Laptop
D Physical Desktop
C Cloud Computer
P Printer
T Tablet Computer
M Mobile Phone

2. Operating System Line

Minimum and maximum length

Operating System Line consists of exactly two characters.

Domain values

Namepart Description
WS Windows Server
WC Windows Desktop/Client
LS Linux Server
LC Linux Client
OX OS X

3. Operating System Version

Minimum and maximum length

Operating System Line consists of 1 to 4 characters.

Domain values

For Windows devices use the internal version number:

Namepart Description
51 Windows Server 2003
52 Windows Server 2003 R2
60 Windows Server 2008
61 Windows Server 2008 R2
62 Windows Server 2012
63 Windows Server 2012 R2
100 Windows Server 2016
A “C” can be added to server versions, if the “Core” version is installed. E.g. 63C
51 Windows XP
52 Windows XP Professional x64
60 Windows Vista
61 Windows 7
62 Windows 8
63 Windows 8.1
100 Windows 10

Get other/older versions from wikipedia.

4. Separator

Minimum and maximum length

The separator is a single character: a hyphen (-).

Domain values

Must be a hyphen (-).

5. Purpose of the device

Minimum and maximum length

Purpose of the device consists of 1 to 4 characters.

Domain values

For Servers:

Namepart Description
DC Domain Controller
FS File Server
PS Print Server
WEB Web Server
ORA Oracle database
SQL SQL Server database
DB other database(s)
EXH Microsoft Exchange
SHP Microsoft Sharepoint
CTX Citrix Server
ESX VMware ESX Server
HV Windows Hyper-V Host

This part is optional for desktop devices.
If implemented, you could use:

Namepart Description
STD or S Standard
DEV or D Used for software development
GRD or G Used for graphical design

6. Sequence number

Minimum and maximum length

The sequence number consists of 1 to 6 characters.

WIN-S01E03-image3
Picture credits: © Yan Zommer | Dreamstime Stock Photos
Numbering your Windows instances.

Domain values

A sequence number making the name unique.
You can decide to make it unique based on purpose only, so you could have:
DWC61-STD001 and LWC61-STD002 (so you do not use 001 for the latter).
If you have a limited number of devices, you could put some intelligence in the number so you know which version of the ‘purpose delivering’ software is running.

Example names

Example name Explanation
DWS63C-HV01 Physical desktop running Windows Server 2012R2 Core, being a Hyper V Host with sequence number 01.
VWS63-SQL141 Hyper V Virtual machine running Windows Server 2012R2 with SQL Server, sequence number 141 (intelligent number, indicates that it is my first virtual machine with SQL Server 2014 installed, I would use 08x for SQL 2008, 09x for SQL 2008R2, 12x for SQL 2012, you get the idea). You could use this if the number of virtual machines per SQL version is less than 10.
VWC100-DEV151 Hyper V Virtual machine running Windows 10, used for development, with sequence number 151 (intelligent number, 15 indicates it’s my Visual Studio 2015 virtual machine, as I have only one of those, 151 is an excellent number).
LWC61-STD0554 Physical Laptop with Windows 7, with software for a ‘standard workspace’, sequence number 0554.

WIN-S01E03-image1
A real life example.

Warning/disclaimer

Do NOT use this naming convention for enterprise networks! Problems that could arise if you use it include:

  • A physical location is not part of this naming convention. In enterprise networks servers often have a physical location reference in their name.
  • The operating system is in the name. This if fine for your own lab virtual machines and home computers, but can be very inconvenient in company networks where the device name is in an inventory system. Enterprises typically do not want devices to be renamed when the Operating System is upgraded.

So.. use this naming convention only for the intended purpose, and take advantage of it.

Conclusion / Wrap up

I posted my own naming convention for virtual and physical computer devices I use “AS IS”.
I do not say it is perfect or useful in all cases.
Use the parts you think are convenient and adjust further to meet your requirements.
I would be thankful if you would like to share your adjustments with me, so I can update this post.
I discourage to use this standard in enterprise networks. For more details see the warning/disclaimer above.

(c) 2016 hansmichiels.com – Do not steal the contents – spread the link instead – thank you.

Connect to a removable drive in a Hyper V Virtual Machine (Windows User Series)

Introduction

This post is based on using Windows 10 on the host and Windows Server 2012 R2 on the guest (Virtual Machine), but on Windows 7, 8 and 8.1 things work similarly.

People coming from a VMWare environment might wonder what this is all about. What is the point, right?

I must admit, sharing or mapping a drive in a Hyper V virtual machine (a.k.a. “guest”) is not such a nobrainer as in VMWare. But no worries, with a little bit of effort it can be done easily.

So, what is the problem?

Well, I mount a VeraCrypt container on my host machine, and want to see the drive in my guest machine.  Or plug in a USB pen drive or removable harddisk, and use it on the guest machine.

Common ways to connect to a (removable) drive

I did it my way

I was looking for a more convenient way, that is, one I have to set up only once, and does not depend on the RDP protocol.

In my opinion a networkshare was the way to go.

But there were a few challenges:

  1. Windows tends to “forget” a shared drive or folder once this drive has been gone (usb media removed or VeraCrypt container unmounted). This is a problem, because then you have to configure the removable drive for sharing every time it is mounted.
  2. I did not want to do a round trip to my router, I want it to be a host/guest only party.

But I managed to get it working, and in the next paragraph I will tell you how.

myway3

Steps to do it “my way”

Again (see my previous post), the magic word to get this working is .. a junction!

Alright, having said that, where do we start?

We need set up a few things;

  1. An internal network connection between guest and host OS.
  2. A junction pointing to a removable drive letter on the host.
  3. Share that junction to one or more Windows users on the host.
  4. Create a mapped network drive on the guest.

Important note : if you want to map more than one drive on the host, you have to edit the hosts file on the virtual machine. After Step 4 below, I will explain how to do this.

Are you ready? Let’s roll up our sleeves and get going!

Step 1 – Set up an internal network connection between guest and host OS

1a – Create a Virtual Network Switch

Start Hyper V Manager, and select Virtual Switch Manager from the Actions pane.

WinS01E02_Step1a1

Create a new virtual network switch of type Internal.

WinS01E02_Step1a2

Give the Virtual Switch a name (I couldn’t think of a better name than “Internal”), leave other options as they are by default and press OK.

WinS01E02_Step1a3

1b – Add a network adapter to the virtual machine and configure it to use the Internal Switch

Now, open the Settings for the virtual machine.

WinS01E02_Step1b1

Choose Add HardwareNetwork AdapterWinS01E02_Step1b2

Configure the network adapter to use the Virtual switch Internal (or any other name you gave it). Press OK.

WinS01E02_Step1b3

1c – Find the Internal IP Address of the host

Still on the host, start a command prompt and type ipconfig. 

Then search for an Ethernet Adapter vEthernet (Internal) and write down the Autoconfiguration IPv4 Address. You will need it in a few minutes.

WinS01E02_Step1c1

 

Step 2 – Create a junction pointing to a removable drive letter on the host

Insert your USB storage media or mount a VeraCrypt File container.

For the example I use drive P on the host. Please replace P everywhere with the driveletter of your removable media.

Now find a folder on a fixed drive, e.g. where you store your Hyper V Virtual Machines. In the example I will use E:\HYPER_V\SHARES

Start a command prompt and type

mklink /j “E:\HYPER_V\SHARES\P” “P:\”

 

Replace the foldername and the drive letter with your values.
The output of the command window should confirm that the junction was made:
WinS01E02_Step2a

People who have read my previous post in my Windows User Series might remember that I preached that it is not recommended to make junctions pointing to removable drives. Well, this post proves that there is at least one exception to this rule of thumb!

Step 3 – Share that junction to one or more Windows users on the host.

Open the Properties of the junction E:\HYPER_V\SHARES\P and select tab Sharing. Press Advanced Sharing.

WinS01E02_Step3a

 

 

Select Share this folder and press Permissions.

WinS01E02_Step3b

Remove Everyone from Share Permissions and add at least one user from the host. Give this user the appropriate permissions.

Tip: if possible, use a (special) account from the host of which the password never changes, for reasons I will tell below.

WinS01E02_Step3c

 

Step 4 – Create a mapped network drive on the guest

Now, in Hyper V Manager, start the Virtual machine.

Once the Virtual machine is started, log in, start a Windows Explorer and choose Map Network Drive from the menu.

Choose a Drive (can be the same letter as on the host, but this is not necessary).

For Folder, type \\<Host Internal IP Address>\<Share Name>

(or \\<Host name from hosts file>\<Share Name> if you have modified the hosts file)

Check Reconnect at sign-in (if you think this is convenient).

If you do not want a permanently mapped drive, you could create a cmd file with a net use command, and execute it when you need to map the drive. 

Check Connect using different credentials.

WinS01E02_Step4a

In the Windows Security screen, enter a username of the host that has permissions on the share you created earlier.

Note: to indicate that you use a username of the host machine, type the host computer name and a backslash in front of the user name .

If you check Remember my credentials, the credentials are stored in the Windows Credential Manager of the guest (Virtual Machine), so you don’t have to provide them every time you access the mapped drive. But don’t forget, that when you change the password from the account on the host, you have to change the saved password also in the Credential Manager of the guest (accessible through Control Panel). When you are using names from the hosts file instead of the IP address, the same credentials will even occur multiple times, e.g. for “host1”, “host2”, etc! Therefore, it is best to use a (special) account from the host of which the password never changes.

WinS01E02_Step4b

That’s it!

WinS01E02_Step4c

Remember, as soon as you plug in the removable drive on the host, it will be available immediately in the Virtual Machine.

If you get this message, you know that the removable drive is not available on the host (yet). You have to plug it in first.

WinS01E02_Step4d

Appendix – Only needed if you want to map more than one drive: edit the hosts file.

Following steps 1 to 4 you can map only one drive, because if you try to connect a second drive, your will get a “Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed… ” error as shown below.

WinS01E02_Limitations

To map multiple drives, you have to do a little trick so that your guest thinks you are connecting to different computers ..

Start Windows explorer on the guest

Go to your virtual machine, start Windows Explorer, and go to the folder C:\Windows\System32\drivers\etc.

 Copy and adjust the hosts file

Copy the file “hosts” (it does not have a file name extension) to a different temporary folder, e.g. your desktop folder.

Open the file with a text editor, e.g. Notepad and add the Internal IPv4 adress of the host, followed by a space and then a name. The trick really is to add multiple lines with the same IP adress but a different name. I just keep it simple by numbering the names but you can do whatever you want, as long as the names are different.

169.254.151.11 host1
169.254.151.11 host2

Finally your hosts file should look similar to the one below (I have added a few more so my hosts file is “future proof”):

WinS01E02_Step5b

Save and close the file and copy it back to the original folder C:\Windows\System32\drivers\etc. Confirm to replace the existing file.

Now walk trough Steps 2 to 4 for each network drive you want to map. Instead of using the IP address, use a name from the hosts file, for each mapped drive a different name, and you will not get the “Multiple connections” error.

Here you will see an example of the endresult: I mapped drives H, P and Z using names host1, host2 and host3.

WinS01E02_Step53

Conclusion / wrap up

In this blog post, I have explained how to map a removable drive on the host operating system as a network drive in a Hyper V Virtual Machine.

By using a junction on a fixed drive on the host, a Windows problem forgetting that a removable drive was shared, can be circumvented.

By using an Internal network connection, there is no router round trip, nor a dependency to use a remote desktop connection to start up the guest. Also multiple virtual machines could have access to the same drive at the same time.

Finally by changing the hosts file, you can connect to multiple (removable) drives on the host computer.

(c) 2016 hansmichiels.com – Do not steal the contents – spread the link instead – thank you.

Windows drive full? Use junctions! (Windows User Series)

Introduction

Microsoft Windows is not so bad, is it? But in my experience it can be greedy as it comes to disk usage. Not that this is necessarily always Windows to blame, but also third party software or other reasons.

Whatever the reason is, if it happens you have a problem. But don’t panic, luckily there is something you can do about it!

Disk consumption in Windows is like a glass of water being filled until it would overflow ..
Disk consumption in Windows can be like a glass of water being filled until it would overflow ..

 

Use cases

But what situations are we talking about? I can give you some examples:

  • Windows updates eating disk space (does the folder “SoftwareDistribution” ring a bell?)
  • Visual Studio 2015 with full mobile development installation taking 40GB for that part only!
  • Software for navigation equipment that does need temporary space for downloading an update but has no way to choose the folder to download it to (my experience was with Garmin).
  • Just lots of huge files in “My music” or “My videos”, where basicly of course, there is no one to blame but you.
  • On a computer with a large amount of memory, having “hybernate” enabled. If you put a computer in “hybernate” all the memory contents is saved to disk, so when you have 16GB of RAM, you will need this amount of free disk space.
  • You have partitioned your disk to a “Windows” and a “Data” partition (aka a C- and a D-drive), but your underestimated the disk space required for the C-drive.
  • Your disk is not full but you want to store user data (documents, pictures, music and so on) on a different drive, e.g. so you can easily restore an image of Windows without copying your user data back after the restore.

 

Ways to free up disk space on drive C

The are more ways to free up disk space. However I want to focus on one solution, here is a (non-complete) list of things you could do:

  • Compress folders that you do not use frequently. This will save disk space but will cost cpu power when accessing the files in that folder(s).
  • If you have partitioned your disk, increase the size of the C-drive (and therewith decrease the size of the D-drive).
  • Using Windows utilities to free up disk space (can help but is not always you can regain enough diskspace with this)
  • Uninstall programs you do no longer need.
  • Use junctions. This is the solution I will dive into in this blog post.

 

Using junctions – prerequisites

There is one important requirement when it comes to junctions: you need to have more than one (fixed) disk or partition in your computer. If it is a second physical disk or a second partition on one disk does not matter. And of course you need to have free disk space on that second disk or partition.

So when you have a notebook with only a small sized SSD, and it is full, junctions can not do much for you.

WARNING! Don’t make junctions pointing to folders on removable drives, like USB pen drives, SD cards and so on for system-critical folders, otherwise applications might stop working or Windows would not even start!

Using junctions – how it works

Definition

First of all, what the heck is a junction?

I got to know junctions (also called a soft link) as a shortcut for a folder. This shortcut behaves like a folder but redirects all applications that access that folder to a different folder. Cool, hey?

If you want to know more: read more on MSDN

A junction in the Netherlands (Rotterdam)
A traffic junction in the Netherlands (Rotterdam)

Examples of use

An application taking up too much space

Okay, suppose you have Garmin software installed, you have only a few gigabytes free disk space and want to install a Garmin update on your device. Before starting to download and install the update, this is what you can do:

  1. Create a cmd script and store it on your computer (call it e.g. create_junctions_garmin.cmd)
  2. Paste this into the empty cmd file. Adjust the bold folder names if needed.

@echo off
echo — STEP 1 – CREATE TARGET FOLDER(S) —
pause
mkdir D:\Junctions
mkdir D:\Junctions\ProgramData
mkdir D:\Junctions\ProgramData\Garmin
echo Please check that the previous step was completed succesfully . . .
echo If errors occurred close the command window WITHOUT PRESSING ENTER ! ! !
pause
echo — STEP 2 – COPY FOLDER AND ALL SUBFOLDERS AND FILES —
pause
xcopyC:\ProgramData\Garmin” “D:\Junctions\ProgramData\Garmin” /E /K /X
echo Please check that the previous step was completed succesfully . . .
echo If errors occurred close the command window WITHOUT PRESSING ENTER ! ! !
pause
echo — STEP 3 – REMOVE SOURCE FOLDER —
pause
rmdir /s /q “C:\ProgramData\Garmin
echo Please check that the previous step was completed succesfully . . .
echo If errors occurred close the command window WITHOUT PRESSING ENTER ! ! !
pause
echo — STEP 4 – CREATE JUNCTION FOR SOURCE FOLDER —
pause
mklink /j “C:\ProgramData\Garmin” “D:\Junctions\ProgramData\Garmin
pause

3. Run the cmd file as Administrator and check that it runs without errors. Alternatively you could also move the folder including subfolders and files manually and create a cmd script that only contains STEP 4 – CREATE JUNCTION FOR SOURCE FOLDER

If files are locked, maybe you have to reboot and start Windows in Safe mode, then run the cmd script again.

Moving userdata to a different drive

However Windows offers to some extend the possibility to move these folders, in my experience still downloaded files, pictures or documents sometimes are stored on the C-drive. By creating junctions this is not the case.

I recommend to move this user folders manually and create only the junctions with a cmd script.

Warning / disclaimer: However this works fine for me on Windows 7 and 10 and I do not expect any problems if you follow the procedure, please try this at your own risk.

Note: this works also on non-English versions of Windows as the displayed localized folder names (e.g. in Dutch: “Documenten” for “Documents”) are not the actual folder names. So for the junctions you need to use the English names.

This is what you can do (adjust the bold folder names: replace Hans with your Windows username and replace D:\USERDATA with some other folder if you like)

  • Create a folder D:\USERDATA\Hans
  • Create a cmd script and store it on your computer (call it e.g. create_junctions_userdata.cmd)
  • Paste this into the empty cmd file

Note that you can select the folders of your choice, this list is just an example.

mklink /j “C:\Users\Hans\Downloads” “D:\USERDATA\Hans\Downloads”
mklink /j “C:\Users\Hans\Contacts” “D:\USERDATA\Hans\Contacts”
mklink /j “C:\Users\Hans\Favourites” “D:\USERDATA\Hans\Favourites”
mklink /j “C:\Users\Hans\Music” “D:\USERDATA\Hans\Music”
mklink /j “C:\Users\Hans\OneDrive” “D:\USERDATA\Hans\OneDrive”
mklink /j “C:\Users\Hans\Pictures” “D:\USERDATA\Hans\Pictures”
mklink /j “C:\Users\Hans\Videos” “D:\USERDATA\Hans\Videos”
mklink /j “C:\Users\Hans\Searches” “D:\USERDATA\Hans\Searches”
pause

  • Use Windows Explorer to go to the folder C:\Users\Hans
  • Select the following folders while pressing the CTRL key: Contacts, Documents, Downloads, Favourites, Music, OneDrive, Pictures, Searches, Videos.

Note that you can select the folders of your choice, but make sure every folder selected is in your cmd script.

  • Press CTRL+X (Cut)
  • Navigate to the folder D:\USERDATA\Hans
  • Press CTRL+V (Paste)
  • Run the cmd file as Administrator and check that the junctions are created.

User_junctions_cmd

For your interest, on the Windows drive the little arrow in the corner of the folder icon reveals that these “folders” are now actually junctions.

User_junctions

Conclusion / Wrap up

With junctions you can replace a Windows folder with a “shortcut” to a different folder.

This can amongst others be handy when you have lack of disk space on the Windows drive.

It is strongly recommended to create only junctions that redirect to folders on fixed drives.

I have explained some examples of how you can use junctions, but you can use junctions for other applications as well. Beware that in some cases files in folders you want to make a junction for can be locked. Stopping the Windows Services or applications accessing those files can help, or starting Windows in Safe Mode (I must admit I did not try this but in theory it should work).

(c) 2016 hansmichiels.com – Do not steal the contents – spread the link instead – thank you.