是否有Powershell命令重新启动计算机并在没有任何用户输入的情况下运行脚本?

the*_*oob 0 powershell sharepoint

我正在运行一个PowerShell脚本,它安装了sharepoint先决条件.在需要重新启动安装服务器并且必须运行另一个脚本之后

有没有办法在powershell中自动化这个过程?

重启并恢复?

Ans*_*ers 5

在重新引导之前,将第二个脚本添加到HKLM下RunOnce项.

New-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce `
  -Name "SPPreReq" -PropertyType String -Value "powershell -File C:\foo.ps1"
Restart-Computer
Run Code Online (Sandbox Code Playgroud)