Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xComputer fails while joining deleted machine #58

Closed
avishnyakov opened this issue Dec 16, 2016 · 15 comments · Fixed by #386
Closed

xComputer fails while joining deleted machine #58

avishnyakov opened this issue Dec 16, 2016 · 15 comments · Fixed by #386
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.

Comments

@avishnyakov
Copy link

If VM was added to the domain, then deleted-recreated-rebuilt, and then we try to use xComputer again, then joining fails with the error "can't join machine to domain cause it already exist"

Here is how to reproduce this issue:

  • build VM
  • join to DC with xComputer and name "my-dev"
  • delete VM
  • join to DC with xComputer and name "my-dev" <-- fails here

That could be fixed with the following code-check prior joining to the DC:

$machineName =  "my-dev"
$dcIpAddress = "10.0.0.10"

	# removing maching from the AD
	Write-Output  "`tChecking if VM exists in AD:[$machineName] via DC IP address:[$dcIpAddress]"
	try {
		
		$machine = get-adcomputer $machineName -Server $dcIpAddress -ErrorAction SilentlyContinue
	}
	catch {
		
	}
	
	if($machine -ne $null) {
		Write-Output  "`tRemoving VM from AD:[$machineName]"
		remove-adobject $machine  -Recursive -Server $dcIpAddress -Confirm:$false -ErrorAction SilentlyContinue
	}

In that case, if VM isn't inthe DC and it EXISTS in DC (from previous build), all be good.

@daBONDi
Copy link

daBONDi commented Feb 8, 2017

Got the same Problem, suck when you rebuilding multiple vms in vagrant and rejoin them to the domain.

But the Problem is the Active Directory Utilitys are not Installed on the Client Machine on the Domain join so no "Get-ADComputer..." and so need, need to do it with .net AD Objects

@avishnyakov
Copy link
Author

Ahahaha, exactly the same.

I put up that script in vagrant provisioned (ps, chef, whatever you've got) you make it happen.
However, the account (and security) to delete VMs from the AD has to be elevated. Make sure you've for some permissions to do that (in staging / prod) that would be kinda point to solve.

@avishnyakov
Copy link
Author

Meaning, xComputer should have additional property to indicate the user who actually HAS permissions to delete computer from AD. Just in case anyone would want to enhance xComputer.

@daBONDi
Copy link

daBONDi commented Feb 8, 2017

I realy hate the nda stuff microsoft put on thix xXxX Modules, realy destroys the mood on contributing :D

@avishnyakov
Copy link
Author

What'd you mean? What the NDA stuff you are talking about?

@daBONDi
Copy link

daBONDi commented Feb 8, 2017

For some Maintainer: Same as #55

@iainbrighton
Copy link
Contributor

iainbrighton commented Feb 8, 2017 via email

@avishnyakov
Copy link
Author

And then, potentially, sue you as you used their code somewhere else. Open source is such an open source ^_^

@daBONDi
Copy link

daBONDi commented Feb 8, 2017

Why make it open source then? Thats whyi don't will contribute anything marked with this :-) but i'm not a lawyer, maybe i'm overreacting :-)

Croudsourcing at it best!

@iainbrighton
Copy link
Contributor

iainbrighton commented Feb 8, 2017 via email

@daBONDi
Copy link

daBONDi commented Feb 8, 2017

Shouldn't the MIT License protect them in that case? I'm not a laywer, this case running into a chatroom :-)
Need to investigate the web to get some light on it :-)

@PlagueHO
Copy link
Member

@daBONDi , @iainbrighton , @avishnyakov - are any of you planning on submitting a fix for this one or shall I keep it open on the backlog (I'll get to it some day if no one else does)?

@PlagueHO PlagueHO added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. enhancement The issue is an enhancement request. and removed bug The issue is a bug. labels Jul 12, 2017
@iainbrighton
Copy link
Contributor

@PlagueHO I have no immediate plans on fixing it 😢. However, we should avoid taking a dependency on the ActiveDirectory module and may have to resort to WMI Win32_ComputerSystem 🏃.

@PlagueHO
Copy link
Member

@iainbrighton - OK I'll try and get to this one some day 😁 Good point about not depending on AD module!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
4 participants