Created
November 16, 2018 18:27
-
-
Save steviecoaster/9763661a1bfae924e253a265b5b468ca to your computer and use it in GitHub Desktop.
Get a toast on Windows 10 when a workstation finishes encrypting with Bitlocker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-BitlockerEncryptionToast { | |
[cmdletBinding()] | |
Param( | |
[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] | |
[string] | |
$Computername | |
) | |
Start-Job -ScriptBlock { | |
If ($using:Computername) { | |
$Session = New-PSSession -ComputerName $using:Computername | |
} | |
Function Get-Percentage { | |
If ($using:Computername) { | |
$script:EncryptionPercentage = Invoke-Command -Session $Session -ScriptBlock { (Get-BitLockerVolume).EncryptionPercentage } | |
} | |
Else { | |
$script:EncryptionPercentage = (Get-BitLockerVolume).EncryptionPercentage | |
} | |
} | |
#Get the value currently, before dropping into the while loop. | |
Get-Percentage | |
#Sleep for 5 minutes between checks, as encryption does take some time to complete | |
While ($EncryptionPercentage -lt 100) { | |
Start-Sleep -Seconds (60 * 5) | |
Get-Percentage | |
} | |
$Header = New-BTHeader -Id 1 -Title "Encryption Complete!" | |
New-BurntToastNotification -Text "Encryption on $($using:Computername) has completed!" -Header $Header -Silent | |
Get-PSSession | Remove-PSSession | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment