对不起,我的英语不好。
我在运行Windows7的VMWare ESXi上有虚拟机。所有计算机都在域中,但有时它们会离开域,因此我需要重新加入域。我写了一个简单的脚本来做这件事:
$credential = New-Object System.Management.Automation.PsCredential("mydomain\user", (ConvertTo-SecureString "password" -AsPlainText -Force))
Add-Computer -WorkGroupName TEMP -Credential $credential
Add-Computer -DomainName "mydomain" -Credential $credential
Restart-Computer但是它不工作;我有这个错误:
Add-Computer : This command cannot be executed on target computer('') due to following error: An existing connection was forcibly closed by the remote host.
At C:\Tools\Re-Join.ps1:2 char:13
+ Add-Computer <<<< -WorkGroupName TEMP -Credential $credential
+ CategoryInfo : InvalidOperation: (:) [Add-Computer], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.AddComputerCommand<br>如果我手动加入'workgroup‘,然后运行脚本,一切正常。
发布于 2011-11-30 21:28:13
下面是我用来加入域的脚本:
$computer = Get-WmiObject Win32_ComputerSystem
$computer.JoinDomainOrWorkGroup("cloud.com" , "PASSWORD HERE", "USER", $null, 3)
Restart-Computer -Force发布于 2013-06-04 00:37:56
您可以在加入之前添加一个退出,重新加入域名之前不需要重新启动:
$computer.UnJoinDomainOrWorkGroup("PASSWORD HERE", "USER", 0)https://stackoverflow.com/questions/8301554
复制相似问题