-
Notifications
You must be signed in to change notification settings - Fork 0
/
Install-ASRProvider.psm1
57 lines (47 loc) · 2.19 KB
/
Install-ASRProvider.psm1
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
54
55
56
57
Function Install-ASRProvider{
<#
.SYNOPSIS
PowerShell module to automate Azure Site Recovery deployment workflows for Hyper-V VMs to Azure in a non-VMM environment.
.DESCRIPTION
PowerShell module to automate Azure Site Recovery deployment workflows for Hyper-V VMs to Azure in a non-VMM environment.
This function was tested using a WS2016 Virtual Machine configured as a Hyper-V Host using Nested Virtualization.
https://docs.microsoft.com/en-us/azure/site-recovery/site-recovery-deploy-with-powershell-resource-manager
The Install-ASRProvider.psm1 module downloads the ".\AzureSiteRecoveryProvider.exe" file from "https://aka.ms/downloaddra"(Microsoft could change this link at anytime)
to a local folder on the Hyper-V host that matches the $Path variable value in the Install-ASRProvider.psm1 module.
.PARAMETER Vault
Vault Object.
.PARAMETER Path
File Path .
.PARAMETER SiteName
SiteName.
.PARAMETER ServerFriendlyName
ServerFriendlyName.
.PARAMETER SiteIdentifier
SiteIdentifier.
.FUNCTIONALITY
PowerShell Language
/#>
Param(
[System.Object]$Vault,
[String]$SiteName,
[String]$ServerFriendlyName,
[String]$SiteIdentifier
)
[string]$ScriptPath = Split-Path (get-variable myinvocation -scope script).value.Mycommand.Definition -Parent
#Download site recovery provider file and credential file
Invoke-WebRequest -Uri "https://aka.ms/downloaddra" -OutFile "c:\ars\AzureSiteRecoveryProvider.exe"
$Path = "C:\ARS\"
$CredsFile = Get-AzureRmRecoveryServicesVaultSettingsFile -Vault $Vault -SiteIdentifier $SiteIdentifier -SiteFriendlyName $SiteName -Path $Path
$CredsFile.FilePath
#region extract the ASR Provider files, Install the ASR provider and Recovery Vaullt Agent and verify the Server Registration
#Extract Provider files
Set-Location -Path $Path
Start-Process -FilePath (".\AzureSiteRecoveryProvider.exe") -ArgumentList "/x:. /q" -Wait
#Install ASR Provider
C:\ARS\SETUPDR.EXE /i
#Register the Hyper-V host in the vault
$RegisterPath = "C:\Program Files\Microsoft Azure Site Recovery Provider\"
Set-Location -Path $RegisterPath
Start-Process (".\DRConfigurator.exe") -ArgumentList "/r /friendlyname $ServerFriendlyName /Credentials $($CredsFile.FilePath)"
Set-Location -Path "\"
}