forked from MicksITBlogs/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BitlockerSystem.ps1
64 lines (60 loc) · 2.16 KB
/
BitlockerSystem.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2015 v4.2.99
Created on: 2/25/2016 4:29 PM
Created by: Mick Pletcher
Filename: BitlockerSystem.ps1
===========================================================================
.DESCRIPTION
This script waits for the bitlocker process to begin. If the bitlocker
process does not begin within 5 minutes, the script exits with an error
code 1. If the process does begin, then the script waits until
bitlocker is complete with encrypting the system.
#>
#Declare Variables
Set-Variable -Name CurrentTime -Scope Local -Force
Set-Variable -Name Difference -Scope Local -Force
Set-Variable -Name Output1 -Scope Local -Force
Set-Variable -Name Output2 -Scope Local -Force
Set-Variable -Name Output3 -Scope Local -Force
Set-Variable -Name Process -Value $null -Scope Local -Force
Set-Variable -Name StartTime -Scope Local -Force
Clear-Host
$StartTime = Get-Date
$Output1 = "Waiting for Bitlocker Encryption to begin....."
$Output1
While ($Process -eq $null) {
Start-Sleep -Seconds 5
$Process = Get-Process -Name fvenotify -ErrorAction SilentlyContinue
$CurrentTime = Get-Date
$Difference = (New-TimeSpan -Start $StartTime -End $CurrentTime).minutes
If ($Difference -eq 5) {
Exit 1
}
}
$Output1 = $Output1 + "Completed"
Clear-Host
$Output1
$Output2 = "Bitlockering System....."
$Output2
while ($Process -ne $null) {
$Process = $null
$Process = Get-Process -Name fvenotify -ErrorAction SilentlyContinue
$Output3 = manage-bde -status $env:HOMEDRIVE
Clear-Host
$Output1
$Output2
Write-Host
$Output3[9].TRIM()
Start-Sleep -Seconds 60
}
Write-Host "Complete" -ForegroundColor Yellow
#Cleanup Variables
Remove-Variable -Name CurrentTime -Scope Local -Force
Remove-Variable -Name Difference -Scope Local -Force
Remove-Variable -Name Output1 -Scope Local -Force
Remove-Variable -Name Output2 -Scope Local -Force
Remove-Variable -Name Output3 -Scope Local -Force
Remove-Variable -Name Process -Scope Local -Force
Remove-Variable -Name StartTime -Scope Local -Force