Domain Join issues

I’m troubleshooting a server build automation script and I cannot seem to get domain joining to work. Here’s what I’m working with:

$JoinDomain = '$DomainUser = Read-Host "Enter domain/username (domain admin)"

$DomainPW = Read-Host "Enter password" -AsSecureString

$DomainCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $DomainUser,$DomainPW

Add-Computer -DomainName $Domain -Credential $DomainCred;Start-Sleep -Seconds 20;Shutdown /r /t 0'

Invoke-VMScript -ScriptText $JoinDomain -VM $VM -GuestCredential $LocalCred -Verbose

This is throwing the following error:

Invoke-VMScript : 9/14/2018 11:02:04 AM Invoke-VMScript The guest operations agent could not be contacted.

At line:1 char:1

+ Invoke-VMScript -ScriptText $JoinDomain -VM $VM -GuestCredential $Loc ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (:) [Invoke-VMScript], GuestOperationsUnavailable

+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_GetProcessOutputInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

After getting this error, I tried to take complication out of the equation and run the following command, but got a different error:

PS Prompt> Add-Computer -ComputerName $vm -DomainName $Domain -Credential $DomainCred

Add-Computer : Computer name ServerName cannot be resolved with the exception: One or more errors occurred..

At line:1 char:1

+ Add-Computer -ComputerName $vm -DomainName $Domain -Credential $Domai ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument: (t-jacksrvr3:String) [Add-Computer], InvalidOperationException

+ FullyQualifiedErrorId : AddressResolutionException,Microsoft.PowerShell.Commands.AddComputerCommand

Does anyone do something similar, and if so, can you provide a little help? Thanks in advance.

submitted by /u/Moviefreak4702
[link] [comments]

Leave a Reply