我使用下面提到的主机名更改脚本&域自动加入。
Im using below mentioned script for hostname change & domain join automatically.
- $ ComputerName = Get-WmiObject Win32_ComputerSystem [System.Reflection.Assembly] :: LoadWithPartialName(' Microsoft.VisualBasic')| Out-Null $ name = [Microsoft.VisualBasic.Interaction] :: InputBox(" Enter Desired Computer Name") $ ComputerName.rename(" $ name") 重新启动 - 计算机 " 重新启动主机名更改后需要重新启动脚本需要在重新启动后继续" $ $ cred = New-Object System.Management.Automation.PsCredential(" My Domain ID" ,(ConvertTo-SecureString" My Domain Password" AsPlainText -Force)) Add-Computer -DomainName" Mydomain" -Credential $ cred 重启 - 计算机
我的要求是:一旦主机名被更改,它将要求重新启动,因此机器开始重新启动,此后重新启动完成后,剩余的脚本需要自动启动,这将加入域中的机器。
My requirement is : once hostname got changed and it will ask for restart, so machine starts restart, Here after restarting has been finished, the remaining script needs to start automatically which will join the machine in domain.
先谢谢。!!
推荐答案
我能想到的唯一方法是将它们分成两个脚本并让第一个更改名称,然后创建一个计划任务,以便在计算机重新启动后启动另一个脚本。
Only way I can think of doing it is to split them into two scripts and have the first one change the name and then create a scheduled task to start the other script once the computer has rebooted.
希望有人提供更好的解决方案:)
Hopefully someone offers a better solution :)
更多推荐
脚本中间重启机器并继续脚本。
发布评论