脚本中间重启机器并继续脚本。

编程入门 行业动态 更新时间:2024-10-27 20:36:21
本文介绍了脚本中间重启机器并继续脚本。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用下面提到的主机名更改脚本&域自动加入。

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 :)

更多推荐

脚本中间重启机器并继续脚本。

本文发布于:2023-06-09 06:30:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/596874.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   重启   机器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!