Windows contextualization problem

@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
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!

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.

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

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

1 Like

@jfontan Thanks !

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…

I try new installation of Windows. Same trouble! :frowning:

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

> Set-ExecutionPolicy Unrestricted

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.

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

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   :

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:

# 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:

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

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.

1 Like

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!

Problem SOLVED

Still doesnt work for us at all. The only way to get the guest os to pick up the correct IP is for us to run the ps1 script manually once logged in. It doesn’t run automatically, even using the supplied VBS script. Additionally, when we run the script manually we are always prompted for the change in execution policy. (Explains why the powershell is endlessly running when we test the automatic script run). Removing the .opennebula-context and rebooting doesn’t work either. The opennebula service installs and seems to be running just fine but it also doesn’t do anything. We see the same result on Server 2008 R2, Server 2012 and Server 2016. All Linux OS’s we have tested work just fine. We have tried one-context-5.2.0.msi as well as one-context-5.3.80.msi - Neither work automatically.

No-one have any ideas? We are still struggling with our Windows machines.

Hi Marcus,

You’ll need to set the PowerShell execution policy via local policies when you prepare the image. (I don’t actually use the OpenNebula supplied context.ps1 here, so I can’t comment on the method they use to call the script during the sysprep specialization phase)

Alternatively if you find the command line that calls the context.ps1 script, you can add “-ExecutionPolicy Unrestricted” to it to override the system execution policy and force the script to run.

C:\windows\setupact.log (sysprep log file) should have more information about what is going on.

Cheers

Hi Paul,

Thanks so much for your reply - Your comments about the sysprep log file made me realize why the execution policy kept changing; its a result of sysprep generalizing the image… So instead I created a SetupComplete.cmd script with the following details:

set LOCALAPPDATA=%USERPROFILE%\AppData\Local
set PSExecutionPolicyPreference=Unrestricted
powershell "%systemdrive%\Progra~2\OpenNebula\context.ps1" -Argument >"%systemdrive%\myscript_log.txt" 2>&1

Now the script executes after the initial EULA acceptance and password config. Thanks for pointing me in the correct place! Really appreciate the help!

Hi all,
I would like to reopen this discussion because I’m facing a similar problem. In particular I’m not able to have internet connection.
I set up a WIN7 Enterprise VM and looking at the control panel “Network Connections” section it says Unidentified network.
This is strange because the IP settings are correct and the network is working properly when used for LINUX VM.
This is what I have checked:

  1. I’m able to see my network card and it is working.
  2. I already follow your suggestion and I’m able to run at startup the .vbs script and here you can find the output:

Loading Context FileChanging Hostname to Enabling Remote Desktop
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0

Enabling PingConfiguring Network SettingConfiguring Network Settings for ETH_0IP Realtek RTL8139C+ Fast Ethernet
NIC__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0

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

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

I seems to me it does not have any errors. Am I right?

What is strange to me is that if I try to ping the Default gateway it says “Destination Host unreachable”

Could you please help me?? Any suggestions or hints are really welcome!!!