# Windows contextualization problem

**URL:** <https://forum.opennebula.io/t/windows-contextualization-problem/579>\
**Category:** Product Support\
**Created:** [April 9, 2015, 9:53am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579 "2015-04-09T09:53:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Antonio\_Gonzale](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/juan_antonio_gonzale/32/4336_2.png) [@Juan\_Antonio\_Gonzale](https://forum.opennebula.io/u/Juan_Antonio_Gonzale)\
**Post date:** [April 9, 2015, 9:53am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/1 "2015-04-09T09:53:00Z")

</div>

I’m trying to context a template with Windows 2008R2.

My template is in the way:

> **CONTEXT=[**  
> **DNS\_HOSTNAME=“$NAME”,**  
> **ETH0\_DNS=“212.128.130.11 212.128.130.10”,**  
> **ETH0\_IP=“$NIC[IP, NETWORK="Housing"]”,**  
> **ETH0\_SEARCH\_DOMAIN=“usal.es”,**  
> **HOST=“$NAME”,**  
> **NETWORK=“YES”,**  
> **SET\_HOSTNAME=“$NAME”,**  
> **USERNAME=“Administrador”**  
> **]**  
> CPU=“2”  
> DESCRIPTION=“Windows 2008 R2”  
> GRAPHICS=[KEYMAP=“es”,LISTEN=“0.0.0.0”,TYPE=“vnc”]  
> HYPERVISOR=“vcenter”  
> LOGO=“images/logos/windows8.png”  
> MEMORY=“2048”  
> NIC=[MODEL=“virtualvmxnet3”,NETWORK=“Housing”,NETWORK\_UNAME=“oneadmin”]  
> PUBLIC\_CLOUD=[TYPE=“vcenter”,VM\_TEMPLATE=“4239099c-beac-b987-1895-eea0b50525e5”]  
> SCHED\_REQUIREMENTS=“NAME="housing"”  
> SUNSTONE\_CAPACITY\_SELECT=“YES”  
> SUNSTONE\_NETWORK\_SELECT=“NO”  
> VCPU=“2”

And my problem is that the Windows doesnot configure the context.

I’ve the 2 files in c:\ and asigned the VBS to the starts scripts.

But when deploy a new VM, it doesnot configure correctly.

Could you help me? Is the correct form ETH0\_ for the device?

Thanks.

---

<div class="post-metadata">

**Author:** ![RaveNoX](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/ravenox/32/4290_2.png) [@RaveNoX](https://forum.opennebula.io/u/RaveNoX)\
**Post date:** [April 10, 2015, 3:36pm UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/2 "2015-04-10T15:36:57Z")

</div>

Try use this context scripts: [https://gist.github.com/RaveNoX/59f20b11d7c3ea13fed1](https://gist.github.com/RaveNoX/59f20b11d7c3ea13fed1)  
It works fine in my infrastructure.

Remember that startup scripts run with delay after windows starts.  
So wait some time after startup.

---

<div class="post-metadata">

**Author:** ![Juan\_Antonio\_Gonzale](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/juan_antonio_gonzale/32/4336_2.png) [@Juan\_Antonio\_Gonzale](https://forum.opennebula.io/u/Juan_Antonio_Gonzale)\
**Post date:** [April 13, 2015, 9:05am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/3 "2015-04-13T09:05:08Z")

</div>

Thanks.

I’ve trying with your scripts, but I’ve no success.

I’ve got a template of Windows, without sysprep, and I clone that and:  
install vmware tools  
add the scripts (yours, of course)  
shutdown the VM  
remove the network interface  
restart the VM  
execute sysprep and shutdown  
clone to template import from ONE

Perhaps the problem is in the template?

When I assign the IP, I use:  
CONTEXT=[ETH0\_IP="$NIC[IP, NETWORK=“Housing”]" ]

Is this correct?

Thanks.

---

<div class="post-metadata">

**Author:** ![wilma\_hermann](https://avatars.discourse-cdn.com/v4/letter/w/b4bc9f/32.png) [@wilma\_hermann](https://forum.opennebula.io/u/wilma_hermann)\
**Post date:** [April 14, 2015, 11:49am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/4 "2015-04-14T11:49:23Z")

</div>

Did you verify that the context script runs at all?

When I created a Windows machine, I found out that [this line](https://github.com/OpenNebula/addon-context-windows/blob/master/startup.vbs#L16) in the VBS does not work (I think it’s a bug). The line has to be `If IsEmpty(driveLetter) Then`

The code in GitHub (`If NOT Len(driveLetter) Then`) evaluates to `True` even if a CD-ROM-Drive is found (because if `Len` is positive, `NOT Len` is negative, but recognized as `True`). This assigns C as `driveLetter`. Under Windows, C isn’t very common for a CD-ROM-Drive, so this is likely to fail.

---

<div class="post-metadata">

**Author:** ![Yenya](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/yenya/32/4624_2.png) [@Yenya](https://forum.opennebula.io/u/Yenya)\
**Post date:** [April 27, 2016, 9:30am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/5 "2016-04-27T09:30:47Z")

</div>

@wilma_hermann: this worked for me, thanks!

At Github, they have two years old merge request which (apart from other things) fixes exactly this issue. I see the last commit is ~28 days ago, but the issues without a reply are much older. Is Github the proper place to report bugs against addon-context-windows?

---

<div class="post-metadata">

**Author:** ![VURoland](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/vuroland/32/7682_2.png) [@VURoland](https://forum.opennebula.io/u/VURoland)\
**Post date:** [June 29, 2016, 8:04pm UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/6 "2016-06-29T20:04:46Z")

</div>

@OpenNebula@jmelis we’ve wasted a good part of the day on this issue as well…

I noticed that the 4.12 documentation mentions contextualization files on a CD, but the 5.0 docs say the windows contextualization files should be on C:  
(where they are doomed to be “cleaned up” by a user some day)

The problem is in the disk lookup part of startup.vbs - as mentioned in the github comment of @Yenya - the code always results in just looking at C: for context files. [https://github.com/OpenNebula/addon-context-windows/pull/8/commits/54aed7ad13711d66b78c7201cf5f8d5ff2d141bc](https://github.com/OpenNebula/addon-context-windows/pull/8/commits/54aed7ad13711d66b78c7201cf5f8d5ff2d141bc)  
With the changed proposed by Yenya, it also looks at D:\CONTEXT (the cdrom) for those files, so contextualization works properly, with context files on a CD, not on local filesystem C:

quote from Github (thanks @Yenya):

wrong: If NOT Len(driveLetter) Then  
correct: If IsEmpty(driveLetter) Then

If this is fixed in the addon, people can use windows context. files in 5.0 on CD again.

cheers!

---

<div class="post-metadata">

**Author:** ![Yenya](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/yenya/32/4624_2.png) [@Yenya](https://forum.opennebula.io/u/Yenya)\
**Post date:** [June 29, 2016, 8:12pm UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/7 "2016-06-29T20:12:02Z")

</div>

I wonder whether the contextualization package for Windows is maintained, and if so, what is the proper way of suggesting fixes. I have several merge requests at github for more than month without any reaction from the package authors.

---

<div class="post-metadata">

**Author:** ![jfontan](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jfontan/32/18_2.png) [@jfontan](https://forum.opennebula.io/u/jfontan)\
**Post date:** [July 1, 2016, 11:05am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/8 "2016-07-01T11:05:44Z")

</div>

Sorry for the delay with this. I’m now working on merging pull requests.

---

<div class="post-metadata">

**Author:** ![jfontan](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jfontan/32/18_2.png) [@jfontan](https://forum.opennebula.io/u/jfontan)\
**Post date:** [July 1, 2016, 12:21pm UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/9 "2016-07-01T12:21:39Z")

</div>

Now most of the pull requests are merged and initial testing seems to be OK. Thanks for the patches.

---

<div class="post-metadata">

**Author:** ![VURoland](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/vuroland/32/7682_2.png) [@VURoland](https://forum.opennebula.io/u/VURoland)\
**Post date:** [July 1, 2016, 6:54pm UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/10 "2016-07-01T18:54:28Z")

</div>

@jfontan Thanks !

---

<div class="post-metadata">

**Author:** ![UAnton](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/uanton/32/6309_2.png) [@UAnton](https://forum.opennebula.io/u/UAnton)\
**Post date:** [July 23, 2016, 11:26am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/11 "2016-07-23T11:26:05Z")

</div>

Try install Windows with Contextualization. Not work for me. I put 2 files to C: and add startup script to GP. After restart Network card get IP 169.254.94.240…

 ![](https://canada1.discourse-cdn.com/flex031/uploads/opennebula/original/2X/f/f722b08775dd5c0abbab72fe4465e7e1ddccd610.png)

---

<div class="post-metadata">

**Author:** ![UAnton](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/uanton/32/6309_2.png) [@UAnton](https://forum.opennebula.io/u/UAnton)\
**Post date:** [July 25, 2016, 11:04am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/12 "2016-07-25T11:04:44Z")

</div>

I try new installation of Windows. Same trouble! ☹

---

<div class="post-metadata">

**Author:** ![jfontan](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jfontan/32/18_2.png) [@jfontan](https://forum.opennebula.io/u/jfontan)\
**Post date:** [July 26, 2016, 10:53am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/13 "2016-07-26T10:53:18Z")

</div>

It may be caused by the ExecutionPolicy. Can you try executing this command in PowerShell and rebooting the machine?

```auto
> Set-ExecutionPolicy Unrestricted

```

---

<div class="post-metadata">

**Author:** ![jfontan](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jfontan/32/18_2.png) [@jfontan](https://forum.opennebula.io/u/jfontan)\
**Post date:** [July 26, 2016, 10:57am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/14 "2016-07-26T10:57:48Z")

</div>

Also, can you check that a file called `C:\.opennebula-context` exists? If that’s the case and the IP is not being configured delete it and reboot again.

---

<div class="post-metadata">

**Author:** ![UAnton](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/uanton/32/6309_2.png) [@UAnton](https://forum.opennebula.io/u/UAnton)\
**Post date:** [July 26, 2016, 10:59am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/15 "2016-07-26T10:59:31Z")

</div>

I try this steps 100 times. Script set static DNS and Gateway but dont change IP.

---

<div class="post-metadata">

**Author:** ![UAnton](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/uanton/32/6309_2.png) [@UAnton](https://forum.opennebula.io/u/UAnton)\
**Post date:** [July 26, 2016, 11:23am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/16 "2016-07-26T11:23:05Z")

</div>

Script output:

```
PS C:\> .\context.ps1
Exception calling "Exists" with "1" argument(s): "Unknown error (0x80005000)"
At C:\context.ps1:47 char:12
+ if(!([ADSI]::Exists("WinNT://$computerName/$username"))) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : COMException

The property 'value' cannot be found on this object. Verify that the property exists and can be set.
At C:\context.ps1:60 char:5
+ $admin.UserFlags.value = $admin.UserFlags.value -bor 0x10000
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

The following exception occurred while retrieving member "CommitChanges": "Unknown error (0x80005000)"
At C:\context.ps1:61 char:5
+ $admin.CommitChanges()
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
    + FullyQualifiedErrorId : CatchFromBaseGetMember

Exception calling "Exists" with "1" argument(s): "Unknown error (0x80005000)"
At C:\context.ps1:71 char:28
+ if([ADSI]::Exists("WinNT://$computerName/$username")) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : COMException

Updated 6 rule(s).
Ok.

__GENUS : 2
__CLASS :__ PARAMETERS
__SUPERCLASS :
__DYNASTY :__ PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
PSComputerName :

__GENUS : 2
__CLASS :__ PARAMETERS
__SUPERCLASS :
__DYNASTY :__ PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 83
PSComputerName :

__GENUS : 2
__CLASS :__ PARAMETERS
__SUPERCLASS :
__DYNASTY :__ PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 66
PSComputerName :

__GENUS : 2
__CLASS :__ PARAMETERS
__SUPERCLASS :
__DYNASTY :__ PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
PSComputerName :

__GENUS : 2
__CLASS :__ PARAMETERS
__SUPERCLASS :
__DYNASTY :__ PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
PSComputerName :

__GENUS : 2
__CLASS :__ PARAMETERS
__SUPERCLASS :
__DYNASTY :__ PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
PSComputerName :
```

---

<div class="post-metadata">

**Author:** ![jfontan](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/jfontan/32/18_2.png) [@jfontan](https://forum.opennebula.io/u/jfontan)\
**Post date:** [July 26, 2016, 2:52pm UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/17 "2016-07-26T14:52:51Z")

</div>

Those errors you’re seeing belong to Admin password change, unrelated to the problem we have.

You may try to only configure networking in case some other part is exiting. At the end of `context.ps1` change the code to:

```auto
# Execute script
if(Test-Path $contextScriptPath) {
    $context = getContext $contextScriptPath
    # addLocalUser $context
    # renameComputer $context
    # enableRemoteDesktop
    # enablePing
    configureNetwork $context
    # runScripts $context $contextLetter
    # setContextualized
}

```

You can also enable tracing to check if it’s trying to configure the IP:

```auto
C:\> Set-PSDebug -Trace 1
C:\> .\context.ps1

```

---

<div class="post-metadata">

**Author:** ![Paul\_Batchelor](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/paul_batchelor/32/4193_2.png) [@Paul\_Batchelor](https://forum.opennebula.io/u/Paul_Batchelor)\
**Post date:** [July 26, 2016, 3:12pm UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/18 "2016-07-26T15:12:04Z")

</div>

I think your issue is here -

```
__GENUS : 2
__CLASS :__ PARAMETERS
__SUPERCLASS :
__DYNASTY :__ PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 66
PSComputerName : 

```

Return code 66 is “Invalid subnet mask” and you don’t appear to have one set in your context that I can see. I’d recommend that the subnet mask is set in the virtual network that you are using, it should come through to the VM as ETH0\_MASK for the script to read it. I would also recommend setting the default gateway if it is not set already.

---

<div class="post-metadata">

**Author:** ![UAnton](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/uanton/32/6309_2.png) [@UAnton](https://forum.opennebula.io/u/UAnton)\
**Post date:** [July 27, 2016, 7:16am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/19 "2016-07-27T07:16:02Z")

</div>

Thank you very much! In Virtual networks I set NETMASK = 24 it’s work in OpenNebula 4. I set 255.255.255.0 and all works fine!  
Thanks!

---

<div class="post-metadata">

**Author:** ![UAnton](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/uanton/32/6309_2.png) [@UAnton](https://forum.opennebula.io/u/UAnton)\
**Post date:** [September 4, 2016, 7:46am UTC](https://forum.opennebula.io/t/windows-contextualization-problem/579/20 "2016-09-04T07:46:34Z")

</div>

Problem SOLVED

[Next page](https://forum.opennebula.io/t/windows-contextualization-problem/579.md?page=2)
