Created
May 30, 2024 15:52
-
-
Save epjuan21/a3c1172bc977e5b4c53699b62e4f609b to your computer and use it in GitHub Desktop.
BackUp Db To HDD
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
# Copiar BackUp de Xenco a Disco Duro ADATA Ubicado en Unidad E:\BackUps\BETANIA | |
$driveLetter = "E:" | |
# Establecer la contraseña de BitLocker en una variable | |
$password = <Passoword BitLocker> | |
#Obtener Ruta de la ultima copia de seguridad de la Base de Datos Betania | |
$PathToBackUpFile = Get-ChildItem -Path D:\Backup_SQL -Filter "*.7z" | Sort-Object LastAccessTime -Descending | Select-Object Fullname -First 1 | |
$Destination = "E:\BackUps\BETANIA" | |
# Convierte la contraseña en un objeto SecureString | |
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force | |
# Verificar si la unidad está protegida con BitLocker | |
$bitlockerInfo = Get-BitLockerVolume -MountPoint $driveLetter -ErrorAction SilentlyContinue | |
if ($bitlockerInfo) { | |
Write-Host "La unidad $driveLetter está protegida con BitLocker." | |
# Desbloquear el volumen de BitLocker con la contraseña proporcionada | |
Unlock-BitLocker -MountPoint $driveLetter -Password $securePassword | |
Copy-Item -Path $PathToBackUpFile.FullName -Destination $Destination -Force -PassThru | |
Lock-BitLocker -MountPoint $driveLetter | |
} else { | |
#Write-Host "La unidad $driveLetter NO está protegida con BitLocker." | |
Copy-Item -Path $PathToBackUpFile.FullName -Destination $Destination -Force -PassThru | |
Lock-BitLocker -MountPoint $driveLetter | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment