# Problems with hostname contextualization on Windows

**URL:** <https://forum.opennebula.io/t/problems-with-hostname-contextualization-on-windows/4938>\
**Category:** Product Support\
**Created:** [September 19, 2017, 7:38am UTC](https://forum.opennebula.io/t/problems-with-hostname-contextualization-on-windows/4938 "2017-09-19T07:38:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![asantamarta](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@asantamarta](https://forum.opennebula.io/u/asantamarta)\
**Post date:** [September 19, 2017, 7:38am UTC](https://forum.opennebula.io/t/problems-with-hostname-contextualization-on-windows/4938/1 "2017-09-19T07:38:33Z")

</div>

Hi,

I’m getting an error on trying to rename a Windows host with context variables at VM creation time. Network related context variables are being changed without problems, but hostname not.

Looking at the logs this is the output:  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Windows PowerShell transcript start  
Start time: 20170919083900  
Username: WORKGROUP\SYSTEM  
RunAs User: WORKGROUP\SYSTEM  
Machine: WIN-MDTFJMR535S (Microsoft Windows NT 6.3.9600.0)  
Host Application: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noExit -ExecutionPolicy Unrestricted -file C:\Program Files (x86)\OpenNebula\context.ps1  
Process ID: 760  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Running Script: C:\Program Files (x86)\OpenNebula\context.ps1

```
martes, 19 de septiembre de 2017 8:39:00

Detecting contextualization data
- Looking for CONTEXT ISO
Get-WMIObject : Critical error
At C:\Program Files (x86)\OpenNebula\context.ps1:544 char:17
+ $contextDrive = Get-WMIObject Win32_Volume | ? { $_.Label -eq "CONTEXT" }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], Managemen
   tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
   ommands.GetWmiObjectCommand

  ... Not found
- Looking for VMware tools
  ... Not found in C:\Program Files (x86)\VMware\VMware Tools\vmtoolsd.exe
  ... Not found in C:\Program Files (x86)\VMware\VMware Tools\vmtoolsd.exe
  ... Found in C:\Program Files\VMware\VMware Tools\vmtoolsd.exe
- Extend partitions
Changing Hostname to NOMBREGUAY
Get-WmiObject : Critical error
At C:\Program Files (x86)\OpenNebula\context.ps1:389 char:25
+ $ComputerInfo = Get-WmiObject -Class Win32_ComputerSystem
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], Managemen
   tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
   ommands.GetWmiObjectCommand

You cannot call a method on a null-valued expression.
At C:\Program Files (x86)\OpenNebula\context.ps1:392 char:9
+ $ret = $ComputerInfo.rename($context_hostname)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

... Success
... Rebooting
Restart-Computer : Failed to restart the computer WIN-SCS9P81S7NV with the
following error message: Critical error .
At C:\Program Files (x86)\OpenNebula\context.ps1:415 char:13
+ Restart-Computer -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (WIN-SCS9P81S7NV:String) [Rest
   art-Computer], InvalidOperationException
    + FullyQualifiedErrorId : RestartcomputerFailed,Microsoft.PowerShell.Comma
   nds.RestartComputerCommand

**********************
Windows PowerShell transcript end
End time: 20170919083910
**********************

```

Those are the vOneCloud logs from the machine:  
Tue Sep 19 06:38:27 2017 [Z0][VM][I]: New state is ACTIVE  
Tue Sep 19 06:38:27 2017 [Z0][VM][I]: New LCM state is PROLOG  
Tue Sep 19 06:38:28 2017 [Z0][VM][I]: New LCM state is BOOT  
Tue Sep 19 06:38:28 2017 [Z0][VMM][I]: Generating deployment file: /var/lib/one/vms/48/deployment.0  
Tue Sep 19 06:38:28 2017 [Z0][VMM][I]: Successfully execute transfer manager driver operation: tm\_context.  
Tue Sep 19 06:38:28 2017 [Z0][VMM][I]: Successfully execute network driver operation: pre.  
Tue Sep 19 06:38:53 2017 [Z0][VMM][I]: Successfully execute virtualization driver operation: deploy.  
Tue Sep 19 06:38:53 2017 [Z0][VMM][I]: Successfully execute network driver operation: post.  
Tue Sep 19 06:38:53 2017 [Z0][VM][I]: New LCM state is RUNNING

Thank you!

* * *

**Versions of the related components and OS (frontend, hypervisors, VMs):**  
vOneCloud 5.4, with Windows contextualization 5.4.0.4 (available here: [Windows server context](https://forum.opennebula.io/t/windows-server-context/4807/18)), on VMWare vCenter 6.0

**Steps to reproduce:**

**Current results:**

**Expected results:**

---

<div class="post-metadata">

**Author:** ![vholer](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/vholer/32/4392_2.png) [@vholer](https://forum.opennebula.io/u/vholer)\
**Post date:** [September 19, 2017, 8:45am UTC](https://forum.opennebula.io/t/problems-with-hostname-contextualization-on-windows/4938/2 "2017-09-19T08:45:04Z")

</div>

Hi @asantamarta, I have opened a bug ([https://github.com/OpenNebula/addon-context-windows/issues/35](https://github.com/OpenNebula/addon-context-windows/issues/35)) and I’ll first try to reproduce. I’ll let you know here. Thank you. Vlastimil

---

<div class="post-metadata">

**Author:** ![vholer](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/vholer/32/4392_2.png) [@vholer](https://forum.opennebula.io/u/vholer)\
**Post date:** [September 21, 2017, 4:33pm UTC](https://forum.opennebula.io/t/problems-with-hostname-contextualization-on-windows/4938/3 "2017-09-21T16:33:27Z")

</div>

I have added a check if the Windows Management Instrumentation (WMI) is working properly, so it shouldn’t do partial contextualization now. If you want, you can check here [one-context-5.4.0.6.msi](https://canada1.discourse-cdn.com/flex031/uploads/opennebula/original/2X/4/4acb49945554ebe692b68b0895d7e34475fe340f.msi) (26 KB). Thank you.

---

<div class="post-metadata">

**Author:** ![asantamarta](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@asantamarta](https://forum.opennebula.io/u/asantamarta)\
**Post date:** [September 26, 2017, 10:22am UTC](https://forum.opennebula.io/t/problems-with-hostname-contextualization-on-windows/4938/4 "2017-09-26T10:22:36Z")

</div>

Thank you so much, that worked like a charm!!

Just to mention, if you can be so kind to update the msi package location at the documentation ([http://docs.opennebula.org/5.4/operation/vm\_setup/vcenter.html](http://docs.opennebula.org/5.4/operation/vm_setup/vcenter.html)) I think many people at my situation could benefit from this.

Again, thank you!

---

<div class="post-metadata">

**Author:** ![vholer](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/vholer/32/4392_2.png) [@vholer](https://forum.opennebula.io/u/vholer)\
**Post date:** [September 28, 2017, 5:44pm UTC](https://forum.opennebula.io/t/problems-with-hostname-contextualization-on-windows/4938/5 "2017-09-28T17:44:08Z")

</div>

Hello @asantamarta, we have released new stable version 5.4.1 ([https://github.com/OpenNebula/addon-context-windows/releases/tag/v5.4.1](https://github.com/OpenNebula/addon-context-windows/releases/tag/v5.4.1)) and updated the docs. Thank you for your help!

Best regards,  
Vlastimil Holer
