Change Hostnames to UPPER case in SCVMM

Sometimes, when adding new hosts to SCVMM, for unknown reasons, they end up being a mix of upper and lower case.
Theres a couple of descriptions around, about how to fix it with SQL scripts. It seems they only change the names in tbl_ADHC_Hosts table, not those in tbl_ADHC_AgentServer.
This code changes it for both. If you want it to change them all to lower, replace “UPPER” with “LOWER” 😉
Make sure you take a backup of VirtualManagerDB first.
Restart SCVMMService afterwards (A refresh in the console should be enough).


SELECT [ComputerName], UPPER(LEFT([ComputerName], CHARINDEX('.', [ComputerName], 1) -1)) + 
RIGHT([ComputerName], LEN([ComputerName]) - CHARINDEX('.', [ComputerName], 1) + 1) 
FROM [VirtualManagerDB].[dbo].[tbl_ADHC_Host]

SELECT [ComputerName], UPPER(LEFT([ComputerName], CHARINDEX('.', [ComputerName], 1) -1)) + 
RIGHT([ComputerName], LEN([ComputerName]) - CHARINDEX('.', [ComputerName], 1) + 1) 
FROM [VirtualManagerDB].[dbo].[tbl_ADHC_AgentServer]

UPDATE [VirtualManagerDB].[dbo].[tbl_ADHC_Host] 
SET [ComputerName] = UPPER(LEFT([ComputerName], CHARINDEX('.', [ComputerName], 1) -1)) + 
RIGHT([ComputerName], LEN([ComputerName]) - CHARINDEX('.', [ComputerName], 1) + 1)

UPDATE [VirtualManagerDB].[dbo].[tbl_ADHC_AgentServer] 
SET [ComputerName] = UPPER(LEFT([ComputerName], CHARINDEX('.', [ComputerName], 1) -1)) + 
RIGHT([ComputerName], LEN([ComputerName]) - CHARINDEX('.', [ComputerName], 1) + 1)

Result :

vmmuppercase

Leave a Comment