„Active Directory/backup-ad.ps1“ hinzufügen
This commit is contained in:
parent
546528bb98
commit
b21d8f183c
1 changed files with 19 additions and 0 deletions
19
Active Directory/backup-ad.ps1
Normal file
19
Active Directory/backup-ad.ps1
Normal 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
|
Loading…
Reference in a new issue