Skip to content

Commit

Permalink
fixes #31 and #36 where the bitlocker module throws an exception duri…
Browse files Browse the repository at this point in the history
…ng attempts to reboot
  • Loading branch information
mwrock committed Nov 27, 2014
1 parent 8e9802d commit ee4a2c9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Boxstarter.Bootstrapper/Invoke-Reboot.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ about_boxstarter_variable_in_bootstrapper
$restartScript="Call PowerShell -NoProfile -ExecutionPolicy bypass -command `"Import-Module '$($Boxstarter.BaseDir)\Boxstarter.Bootstrapper\boxstarter.bootstrapper.psd1';Invoke-Boxstarter -RebootOk -NoPassword:`$$($Boxstarter.NoPassword.ToString())`""
New-Item "$startup\boxstarter-post-restart.bat" -type file -force -value $restartScript | Out-Null
}
if(Get-Module Bitlocker -ListAvailable){
Get-BitlockerVolume | ? {$_.ProtectionStatus -eq "On" -and $_.VolumeType -eq "operatingSystem"} | Suspend-Bitlocker -RebootCount 1 | out-null
try {
if(Get-Module Bitlocker -ListAvailable){
Get-BitlockerVolume | ? {$_.ProtectionStatus -eq "On" -and $_.VolumeType -eq "operatingSystem"} | Suspend-Bitlocker -RebootCount 1 | out-null
}
}
catch {} # There are several reports of the bitlocker module throwing errors
$Boxstarter.IsRebooting=$true
Restart
}
Expand Down
1 change: 1 addition & 0 deletions BuildScripts/releaseNotes.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<releaseNotes>
- Fixes failures from exceptions thrown from bitlocker module even when bitlocker is not in use.
- Fixes Invoke-Reboot from a nested package and bubbles up the reboot signal
- Update docs to reflect github as repo home and remove all codeplex links
- Fix for all write-host calls being logged to Boxstarter log file even when there is no install session in progress
Expand Down
18 changes: 18 additions & 0 deletions tests/Bootstrapper/Invoke-Reboot.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,22 @@ Describe "Invoke-Reboot" {
if(get-module bitlocker -ListAvailable){Assert-MockCalled Suspend-Bitlocker}
}
}

Context "When Get-BitlockerVolume throws an error" {
$Boxstarter.RebootOk=$true
$Boxstarter.IsRebooting=$false
Mock Get-BitlockerVolume { throw "some crazy error." }

Invoke-Reboot

it "will create Restart file" {
Assert-MockCalled New-Item
}
it "will restart" {
Assert-MockCalled Restart
}
it "will toggle reboot" {
$Boxstarter.IsRebooting | should be $true
}
}
}

0 comments on commit ee4a2c9

Please sign in to comment.