„Active Directory/backup-ad.ps1“ hinzufügen

This commit is contained in:
Phil 2023-03-27 11:14:45 +02:00
parent 546528bb98
commit b21d8f183c

View file

@ -0,0 +1,19 @@
# Set the backup folder path
$backupFolder = "C:\ADBackup"
# Set the folder name and the date format
$backupFileName = "ADBackup_$(Get-Date -Format yyyy-MM-dd-HH-mm)"
# Set the path for the backup file
$backupFilePath = Join-Path $backupFolder $backupFileName
# Create a backup of the Active Directory
ntdsutil.exe "activate instance ntds" "ifm" "create full $backupFilePath" "quit" "quit"
# Compress the backup file
$zipFileName = $backupFileName + ".zip"
$zipFilePath = Join-Path $backupFolder $zipFileName
Compress-Archive -Path $backupFilePath -DestinationPath $zipFilePath -CompressionLevel Optimal
# Delete the org. Folder
Remove-Item -Path $backupFilePath -Recurse