I've only found one case where this was actually required, and like Gary mentioned, I wrapped it in some logic to avoid rolling continuous reboots.
We ran into the case where "freshly minted" servers had some pending file renames that even with multiple restarts NEVER actually went away, so if we ran Boxstarter we ended up having to kill the cmd window as quickly as possible if we could log in between infinite reboots.
The resulting script can be run from a gist via Install-BoxstarterPackage -DisableReboots <gistUrl>
to clean up any files you put into $badFile (which you could make a list).
The one caveat to this script is it requires interactive prompting for the login credential. You could use a plain text password and assemble a credential if you trust your systems and network, I assume the worst.
Apologies that this seems to break the syntax highlighter.
Import-Module $env:appdata\Boxstarter\Boxstarter.Common
$badSpoolReg = '\??\C:\Windows\system32\spool\PRTPROCS\x64\1_hpcpp130.dll'
$badSpoolFile = 'C:\Windows\system32\spool\PRTPROCS\x64\1_hpcpp130.dll'
# Next bits taken from the 'Get-PendingReboot' module on the Script Gallery.
$Computer = $env:COMPUTERNAME
$HKLM = [UInt32] "0x80000002"
$WMI_Reg = [WMIClass] "\\$Computer\root\default:StdRegProv"
## Query PendingFileRenameOperations from the registry
$RegSubKeySM = $WMI_Reg.GetMultiStringValue($HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager\","PendingFileRenameOperations")
#$RegSubKeySM # Debug print of the list if you want to run by hand
$RegValuePFRO = $RegSubKeySM.sValue | where { $_ } # Ignore empty values
#$RegValuePFRO # Debug print of the list if you want to run by hand
# Credential is required for Create-BoxstarterTask
# Create-BoxstarterTask required to call Invoke-FromTask
# see https://github.com/mwrock/boxstarter/issues/121
$cred = Get-Credential
Create-BoxstarterTask $cred
# Perhaps could be improved using set membership comparison?
# like (if $badSpoolReg in $RegValuePFRO.Values?)
foreach ($path in $RegValuePFRO) {
if ($path -contains $badSpoolReg) {
write-output "Bogey on my six!"
Get-Service spooler | stop-service
Invoke-FromTask "rm -fo $badSpoolFile" # Files in "protected" paths require extra work to remove
$Boxstarter.RebootOk = $true # Need to enable this to allow Invoke-Reboot to work
Write-output "Took out the bogey, resetting system state"
Invoke-Reboot # Manually called but within a fairly good gate
} else {
write-output "No bogeys sighted Captain!"
}
}
Remove-BoxstarterTask