lunedì 30 dicembre 2019

VMWare VSPhere - RENAME VIRTUAL MACHINE and it's files (rename multiple file using PowerCLI )

WARNING: play with VM files could damage the virtual machine itself and make it unusable, do it at your own risk and only if you know what you are doing! (better if you have a backup!)

If you want to rename a virtual machine, you can simply do it from the web interface.
The problem with this is that you'll obtain the new name in the vcenter web console but then the folder on the disk will remain with the old name and also the files inside will remain with old names and this could be confusing and lead to errors, we need a way to maintain consistency.

The safest and best way is to do a cold vmotion to a different datastore. During the migration vsphere will fix folder name and files name to match the new name.
But there are times when you cannot or don't want to use this approach.
For example if you have a really big vm that would require a lot of time to move and you cannot keep it powered down too much time. Or maybe you don't have another datastore where to move the machine, or you don't have enough space on another datastore and so on.

Another way to fix the name mismatch is to manually edit folder name, files name and their content to match the new name.
This approach is RISKY! if you make some mistake you'll break down your machine and make it unusable!
I suggest you to first try these steps on a small test machine to better understand how it works, what you can and cannot do and to get confortable with the steps and their results.

Some notes:
1. the vm must be turned off during these steps
2. the vm must be removed from the vcenter inventory
3. it's better to NOT HAVE any snapshot in place, snapshot files make your life harder and more prone to errors and issues, so please delete every snapshot from the vm before proceed if you can

Here the general idea to rename virtual machine and it's files:
1. turn off VM
2. delete all the snapshots (if you can do it )
3. check from the config where the vm is located on the datastore (the path)
4. remove the vm from the vcenter inventory
5. rename the vm folder
6. rename all the files to reflect the new vm name
7. edit the .vmx and all the (small) .vmdk files in order to replace the old name with the new one
(do the same for the .vmsd file if you didn't delete all the snapshots), don't try to edit .vmsn files or other file extensions, they are binary and not editable
8. from the vcenter web interface browse the datastore, right click on the .vmx file and "register vm" with the new name
9. power on the vm to check if everything is fine

In case you didnt' removed the snapshot before the rename task, you could have surprises now, especially if you now revert to one of the snapshot. We didn't edit the binary snapshot files, so reverting to them will put the old name again in production somewhere, so in this case is better after the revert to check again all the files content and rename the old machine name with the new one where this applies.

RENAMING MULTIPLE FILES BY COMMAND

WARNING: manually touching vm files could corrupt the VM and make it unusable!

Instead of renaming the files one by one you could do it using a command.

There was a time when in VSPhere it was possible to rename multiple files from the shell using the command "RENAME" . It was a Perl command.

Now I'm using VSPhere 6.5 and it seems this command is not available anymore.

I didn't want to find a way to use Perl again, my idea was to find a new way, already available to do the same job.
So I find a simple way is using PowerCLI

Get the installation package from vmware download page and install it on your PC.

Here the idea :

FIRST TURN OFF THE VIRTUAL MACHINE (else the files will be locked as in use)

1. run powercli
2. connect to vcenter
3. go to vmstore disk
4. change working folder to the VM one (where the files to be renamed are located )
5. run the powershell command to rename the files

Now the detailed tasks with commands:

1. run powercli
2. Connect-VIServer (asks vcenter IP and credentials)
3. cd vmstore:
4. cd .\datacentername\datastorename\machinename

type ls to list the folder content

Now, let's say the machine is called SERVER01 , then the folder content would be something like this:

Name                       Type                 Id
----                       ----                 --
SERVER01.nvram             DatastoreFile
SERVER01.vmx               DatastoreFile
SERVER01-aux.xml           DatastoreFile
SERVER01.vmxf              DatastoreFile
SERVER01-flat.vmdk         DatastoreFile
SERVER01.vmsd              DatastoreFile
SERVER01.vmdk              DatastoreFile
vmware-3.log               DatastoreFile
vmware-2.log               DatastoreFile
vmware-1.log               DatastoreFile
vmware.log                 DatastoreFile

Now, we want to rename all those SERVER01* files into SERVER02* , type the command:

5. ls SERVER01* | rename-item -newname {$_.name -replace 'SERVER01','SERVER02'}

The "ls SERVER01*" is used to get the list of files to be renamed, we are interested just in files starting with SERVER01

the rename-item is the powercli command to rename a file

then we need to pass the new filename to the -newname parameter

to create the new name we use the actual name ( $_.name ) where we replace the string SERVER01 with the string SERVER02

This command will iterate between all the files returned by the ls command and one by one rename the file.

Please remember that if you rename the VM files like this, you need also to edit .vmx file and all of the small .vmdk files in order to fix the filenames inside, to not broke the references.
See below what I mean in detail

good luck

venerdì 30 agosto 2019

Windows 10 - UEFI - USB Bootable Key - install.wim too big for FAT32 (>4GB)

Hi,
I was trying to prepare a Windows 10 USB bootable setup Key today.
It was for a uefi system, so I formatted the key FAT32 and copied all the files from the DVD but it stopped with an error about install.wim too big for the support (it was >4GB in size).

I found this nice article explaining how to bypass the issue:
https://win10.guru/usb-install-media-with-larger-than-4gb-wim-file/

To make it short:
- delete all partitions from your usb key
- create a 1GB FAT32 partition
- create another partition with the rest of the space and format it NTFS
- copy all the files and folders EXCEPT "sources" folder, from the DVD to the FAT32 partition
- on the FAT32 partition create a "sources" folder and copy the \sources\boot.wim" file in it from dvd
- copy ALL the files and folders from the DVD to the NTFS partition

this key should be able to boot , the windows setup should appear and you should be able to install windows succesfully, at least it worked in my case

obviously, when I write "DVD" it could be also an ISO files mounted on the PC as source of the files

good luck
and thanks to Kari Finn and Martin aka Cereberus

martedì 2 aprile 2019

Permanently set and save process Priority

Usually we set the process priority using task manager, the problem is that once the process get restarted you loose the priority set.

You can play with the registry to solve this.

Let's say the process you want to start in LOW priority is "notepad.exe"

this is the registry location to look for (if you don't find the folder names, you need to create them) :


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe\PerfOptions]


And then you need to create these 2 DWORD keys:

"CpuPriorityClass"=dword:00000001
"IoPriority"=dword:00000000

where the values 1 and 0 come from this table:

CpuPriorityClass Value Priority 
1 Idle2 Normal3 High5 Below Normal6 Above Normal 
IoPriority Value Priority 
0 Very Low1 Low2 Normal

lunedì 4 marzo 2019

W10 - HIGH DPI SCALING FIX BLURRY APPS

On W10 due to high resolution screens, often the user set the screen scaling to better read the texts and icons, for example to 150%

After that, it happens that some app's text appears to be blurry, out of focus.

You can fix this in 3 places:
1. control panel, apply to the system
2. single app
3. registry

1- Using Control Panel, apply to the System
start menu, settings, system, display, here you have "Scale and layout " set for example to "150%",
click the link "Advanced Scaling Settings" and activate the option "Let Windows try to fix apps so they're not blurry"

2-single app
navigate to the executable file of the app (just as an example: c:\program file\blurryapp\blurry.exe" )
right click on the .exe file
"compatibility" tab
"change settings for all users" (if this is what you want)
"change high DPI settings"
select "Override high DPI scaling behavior." option
and then select "Application" in Scaling performed by

3. registry (this is useful for control panel apps , dll run by RUNDLL32.exe and similar)
When the blurry app does not have an executable (like the apps in the control panel for example) you can use the registry.
An example is Microsoft System Configuration Manager. It's window is blurry when scaling is activated.
Proceed like this:

regedit
create this key:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]

then create a STRING value, where the name is the executable path and the value is "HIGHDPIAWARE"

in the RUNDLL32.exe case it's like this (you can copy and paste this into a .reg file, double click it to insert in the registry)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Windows\\System32\\rundll32.exe"="HIGHDPIAWARE"

Once the setting is in the registry, simply close and reopen the app and it will be ok, no reboot is needed.

I used HKLM because is the simplest one, it applies to all user profiles of the machine, already existing and new one when they will be created




lunedì 21 gennaio 2019

Windows change keyboard layout in remote desktop always revert to default (eng)

Hi,
if you are experiencing Windows (2016 server in my case) in remote desktop to automatically change the Keyboard Layout to the default (ENG) one, whatever you set , you are in the right place.

In the last days I fought against my Windows 2016 server. I set the keyboard layout to ITA but without apparent reason it automatically revert to ENG anytime .

I tried in many way to fix it, but it always reverted to ENG, also if in the control panel I deleted any keyboard layout and left just the one I wanted.

Solution:

open regedit, navigate here (be careful! Layout  - NOT Layouts )

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout

create this :

 IgnoreRemoteKeyboardLayout   DWORD   1

logout/login (or reboot the machine), the keyboard layout should be now the one selected from you, if the layout is not set to the correct one, set it , then it should not change anymore.


martedì 15 gennaio 2019

VmWare player / workstation bridged nic does not get IP Address and Virtualbox error : VERR_INTNET_FLT_IF_NOT_FOUND

On a pc where I was able to run virtualbox and vmware player using a bridged NIC , from one point in time on I was not able anymore to make them work.

I tried many of the solutions found in internet but noone was helping me.

In the end what did the job was to uninstall the nic drivers and install the windows default version like this:

1- windows device manager
2- find the NIC you are trying to use with virtualbox
3- check the driver version, maybe you need this in a later step
4- be sure to have somewhere this or other drivers version for this nic in case windows does not have any driver for it and you want to revert to the actual situation
5- uninstall it (and flag the "delete the driver software for this device" also)
6- run "scan for hardware changes"

If you are lucky, windows will detect the nic and install the windows default drivers for it, and in my case this solved the issue, probably the updated drivers I was using (from the vendor) was not compatible with virtualbox.

If you are not lucky, the nic will be detected but drivers not installed, in this case you should try to install a driver different from the one find in the point 3, maybe something older or something newer.
If you don't have any different version, in the worst case, you'll reinstall the same drivers in point 3 but probably you'll not solve your issue, but at least you'll be able to use your network like before, not from the virtual machine, sorry.