mefellows / vagrant-windows-domain

Connects & removes your Windows Vagrant box from a Domain
MIT License
31 stars 8 forks source link

Getting Overflow Exception "Add-Computer : Value was either too large or too small for Int32." #31

Open HarshdeepSingh4084 opened 2 years ago

HarshdeepSingh4084 commented 2 years ago

First of all, great work creating this plugin. Thanks, it helped a lot.

Issue Description:

I am facing Add-Computer : Value was either too large or too small for Int32. error after every few tries (it's random). After getting this error, if I run the provision action again without any other change, it runs successfully the second time.

Screenshot of error:

image

Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "WindowsBox"
  config.vm.box_url = ENV['VAGRANT_SERVER_URL']
  config.winrm.username = 'johndoe'
  config.winrm.password = 'foobar'

  config.vm.provider :vsphere do |vsphere|
    vsphere.user = 'john_doe'
    vsphere.password = :ask
    vsphere.template_name = '~~~Templates/LAB - Windows Server 2022 Stnd'
    vsphere.vm_base_path = 'john_doe/vagrant_vms'
    vsphere.name = 'vlab018101'
    vsphere.customization_spec_name = '_Windows 2022 - All'
    vsphere.notes = "Windows 2022 Standard with Desktop\nCreated using:\nen-us_windows_server_2022_x64_dvd_620d7eac.iso"
  end

  config.vm.synced_folder '.', '/vagrant', disabled: true

  config.vm.provision :windows_domain do |domain|
    domain.domain = "nsldev.com"
    domain.username = "john_doe"
    domain.password = "foo_bar"
  end
end

In case of any more details required, please let me know.

mefellows commented 2 years ago

Hi! Thanks for the kind words. Unfortunately I don't have any time to work on this project these days (and it's been a long while since I last looked at the code!).

I think you'd need to pull out the PowerShell being used to get a sense of what value might be causing that Int32 issue.

HarshdeepSingh4084 commented 2 years ago

Hi! Thanks for the kind words. Unfortunately I don't have any time to work on this project these days (and it's been a long while since I last looked at the code!).

I think you'd need to pull out the PowerShell being used to get a sense of what value might be causing that Int32 issue.

Ok, I'll dig into the issue and update what I found. Maybe raise a PR if found solution.

HarshdeepSingh4084 commented 2 years ago

Couldn't find anything useful in my case but Add-Computer can fail for a lot of reasons, one of them could be having two NICs. The only solution I can find is to run a loop to retry Add-Computer (maybe twice or thrice) in case of failure. The condition to break the loop can be result of the command (Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain.