forked from seansp-zz/Framework-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_vhd_from_azure_vm.ps1
More file actions
51 lines (40 loc) · 2.28 KB
/
create_vhd_from_azure_vm.ps1
File metadata and controls
51 lines (40 loc) · 2.28 KB
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
#
# Copies user VHDs it finds for VMs in the reference resource group into the 'clean-vhds'
# storage container. The target blobs will have the name of the VM, as a .vhd
#
# Author: John W. Fawcett, Principal Software Development Engineer, Microsoft
#
param (
[Parameter(Mandatory=$false)] [string] $sourceSA="smokesrc",
[Parameter(Mandatory=$false)] [string] $sourceRG="smoke_source_resource_group",
[Parameter(Mandatory=$false)] [string] $sourceContainer="vhds",
[Parameter(Mandatory=$false)] [string] $sourceExtension=".vhd",
#
# Normally you don't need to change these...
[Parameter(Mandatory=$false)] [string] $destSA="smokesrc",
[Parameter(Mandatory=$false)] [string] $destRG="smoke_source_resource_group",
[Parameter(Mandatory=$false)] [string] $destContainer="clean-vhds",
[Parameter(Mandatory=$false)] [string] $destExtension="-Smoke-1.vhd",
[Parameter(Mandatory=$false)] [string] $location="westus",
[Parameter(Mandatory=$false)] [string] $VMFlavor="Standard_D2_v2",
[Parameter(Mandatory=$false)] [string[]] $vmNames=""
)
$sourceSA = $sourceSA.Trim()
$sourceRG = $sourceRG.Trim()
$sourceContainer = $sourceContainer.Trim()
$destSA = $destSA.Trim()
$destRG = $destRG.Trim()
$destContainer = $destContainer.Trim()
$location = $location.Trim()
$VMFlavor = $VMFlavor.Trim()
$destExtension = $destExtension.Trim()
Start-Transcript C:\temp\transcripts\create_vhd_from_azure_vm.log -Force
$regionSuffix = ("---" + $location + "-" + $VMFlavor.ToLower()) -replace " ","-"
$regionSuffix = $regionSuffix -replace "_","-"
$fullSuffix = $regionSuffix + $destExtension
Write-Host "Launching jobs to copy machine image from $sourceRG/$sourceSA/$sourceContainer to $destRG/$destSA/$destContainer..." -ForegroundColor Yellow
C:\Framework-Scripts\copy_single_image_container_to_container.ps1 -sourceSA $sourceSA -sourceRG $sourceRG -sourceContainer $sourceContainer -destSA $destSA `
-destRG $destRG -sourceExtension ".vhd" -destExtension $fullSuffix -destContainer $destContainer `
-location $location -makeDronesFromAll "False" -overwriteVHDs "True" -vmNamesIn $vmNames
Write-Host "Machines are ready for assimilation..."
Stop-Transcript