-
Notifications
You must be signed in to change notification settings - Fork 31
/
delete_backup_virtual_machine.ps1
39 lines (30 loc) · 1.21 KB
/
delete_backup_virtual_machine.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<#
=================================================================================================
Hot Backup Hyper-V VM's
Name: delete_backup_virtual_machine.ps1
Autor: Wanderlei Hüttel
Email: [email protected]
Versão 1.0 - 07/02/2019
Using cmdlets Windows Server Backup
https://docs.microsoft.com/en-us/powershell/module/windowsserverbackup/?view=win10-ps
=================================================================================================
#>
#======================== Not show warnings ========================#
$WarningPreference = "SilentlyContinue"
#======================== Check argument 1 (VM_NAME) is passed ========================#
if ($args.count -eq 0){
Write-Host "Parameter 1 is required! (VM_NAME)"
Exit 1
}
else{
$vm_name = $args[0]
}
#======================== Configuration ========================#
# Backup Target is a localhost shared folder because Windows Backup
# not accept copy to a single folder
$BackupTarget = "\\localhost\D$\backup_hyper-v\$vm_name"
#============ Remove the folder where the backups was saved ============#
if(Test-Path $BackupTarget){
Remove-Item -Recurse -Force $BackupTarget | Out-Null
}
Exit 0