我设法使用脚本在干净的机器上安装SQL服务器。验证SQLServer安装是否需要重启
但有时脚本无法运行,因为机器需要重新启动。
我问:
1.Is有什么办法,如果在安装的SQLserver
需要 2.如果需要重新启动重启检测,重新启动它会自动
我设法使用脚本在干净的机器上安装SQL服务器。验证SQLServer安装是否需要重启
但有时脚本无法运行,因为机器需要重新启动。
我问:
1.Is有什么办法,如果在安装的SQLserver
需要 2.如果需要重新启动重启检测,重新启动它会自动
总之,当重新启动需要时,该值低于地方登录注册处..
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager
安装之前,您可以运行以下PowerShell脚本..
#Adapted from https://gist.github.com/altrive/5329377
#Based on <http://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542>
function Test-PendingReboot
{
if (Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -EA Ignore) { return $true }
if (Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -EA Ignore) { return $true }
if (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Name PendingFileRenameOperations -EA Ignore) { return $true }
try {
$util = [wmiclass]"\\.\root\ccm\clientsdk:CCM_ClientUtilities"
$status = $util.DetermineIfRebootPending()
if(($status -ne $null) -and $status.RebootPending){
return $true
}
}catch{}
return $false
}
如果上述函数返回true,你可以在下面的命令运行..
Restart-Computer -ComputerName "Server01", "Server02", "localhost"
服务器*表示某些名称服务器和本地主机代表本地计算机
参考文献:
http://ilovepowershell.com/2015/09/10/how-to-check-if-a-server-needs-a-reboot/
太棒了!在安装过程中检测到重新启动时,我正在考虑重新启动。从来没有想过在重启之前重启。这应该工作。非常感谢。 – AndyRaito
或者从命令行(cmd)安装午餐所以
C:\Users\username\Downloads\SQLEXPR_x64_ENU.exe /SKIPRULES=RebootRequiredCheck /ACTION=Install
拳头就是设置EXE位于跳过重启支票的地址和第二参数
对不起,我的意思是MS SQL Server的 – AndyRaito
你的意思是说'你想自动SQL服务器通过cmd行安装并寻找重启的方法“ – TheGameiswar
是的。由于在我的脚本中,当需要重新启动时,安装总是失败。如果在安装验证过程中需要重新启动,我正在寻找可以重新启动的方式。 – AndyRaito