-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNew-AzureVaultBKP.ps1
53 lines (39 loc) · 1.4 KB
/
New-AzureVaultBKP.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function New-AzureVaultBKP {
param(
[parameter(Mandatory)]
$name,
[parameter(Mandatory)]
$ResourceGroupName,
[parameter(Mandatory)]
$Location
)
#Login-AzureRmAccount
#Register-AzureRmResourceProvider -ProviderNamespace "Microsoft.RecoveryServices"
$regex = "Y|N"
$VaultParam = @{
'Name' = $Name
'ResourceGroupName' = $ResourceGroupName
'Location' = $Location
}
$VaultParam | Format-Table
Do {
$confirm = Read-Host "Confirm configuration [Y]es or [N]o?"
If($regex -notmatch $confirm) { Write-Warning "Invalid option, please hit the keys 'Y' or 'N'" }
} Until($confirm -match 'Y')
New-AzureRmRecoveryServicesVault @VaultParam
#Configure backup type as LRS
$Vault = Get-AzureRmRecoveryServicesVault -Name $Name
Set-AzureRmRecoveryServicesBackupProperties -Vault $Vault -BackupStorageRedundancy LocallyRedundant
#Create azure folder and download vault settings file
If (!(Test-Path "$env:SystemDrive\Azure_VaultSettings")) {
Set-Location $env:SystemDrive\
Mkdir Azure_VaultSettings
}
$Path = "$env:SystemDrive\Azure_VaultSettings"
$VaultSettings = @{
'Backup' = $true
'Vault' = $Vault
'Path' = $Path
}
Get-AzureRmRecoveryServicesVaultSettingsFile @VaultSettings
}