Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Backup-BitlockerasSystem
- $urlPSexec = 'https://live.sysinternals.com/psexec.exe'
- $psexecEXE = 'C:\Windows\Temp\psexec.exe'
- $out = [System.IO.Path]::GetTempFileName()
- if (!$(Test-Path $psexecEXE))
- {
- Write-Host "Downloading $urlPSexec to $psexecEXE"
- (New-Object System.Net.WebClient).DownloadFile($urlPSexec, $psexecEXE)
- }
- #The command to run as the system account. Using Start-Transcript to get the results
- [String]$backupCommand = "Start-Transcript -Path ""$out"";Backup-BitLockerKeyProtector -MountPoint 'C:' -KeyProtectorId " + '$((Get-BitLockerVolume -MountPoint "C:").KeyProtector[1].KeyProtectorId)'
- Write-Host "Running command as system: $backupCommand"
- #Start Powershell as the system account and run $backupCommand
- $procPsExec = Start-Process -PassThru -Wait -FilePath $psexecEXE -ArgumentList "-acceptEULA -s -i powershell -noprofile -command $backupcommand"
- Write-Host "PSExec process exited with code $($procPsExec.ExitCode)"
- if ($procPsExec.ExitCode -eq 0)
- {
- #Display Success message
- Write-Host "Bitlocker Backup was success"
- Write-Host $(Get-Content $out | Out-String)
- } else {
- #Display Failure
- Write-Host "Bitlocker Backup was failure"
- Write-Error $(Get-Content $out | Out-String)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement