forked from mschippr/azurescripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSingleWin10Template.PS1
More file actions
118 lines (107 loc) · 3.66 KB
/
SingleWin10Template.PS1
File metadata and controls
118 lines (107 loc) · 3.66 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Request a new Azure Resource Manager Virtual Network
# Dynamic Public IP Address for AZULABDT01
New-AzureRmPublicIpAddress `
-ResourceGroupName "EUS-ARM-PRD-ENV" `
-Location "East US" `
-Name "EUS-ARM-PRD-ENV-VN-PIP-AZULABDT01" `
-AllocationMethod "Dynamic" ;
# Create an Azure Resource Manager
# Virtual Machine configuration
$newVMConfigParams = @{
"VMName" = "AZULABDT01" ;
"VMSize" = "Standard_DS2_v2_Promo" ;
} ;
$newAzureRmVMConfig = `
New-AzureRmVMConfig `
@newVMConfigParams ;
# Configure the Azure Resource Manager
# Virtual Machine operating system
$newAzureRmVMOperatingSystemParams = @{
"VM" = $newAzureRmVMConfig ;
"Windows" = $true ;
"ComputerName" = "AZULABDT01" ;
"Credential" = ( `
Get-Credential `
-Message "Please input new local administrator username and password.") ;
"ProvisionVMAgent" = $true ;
"EnableAutoUpdate" = $true ;
} ;
$AzureVirtualMachine = `
Set-AzureRmVMOperatingSystem `
@newAzureRmVMOperatingSystemParams ;
# Configure the Azure Resource Manager
# Virtual Machine source image
$newAzureRmVMSourceImageParams = @{
"PublisherName" = "MicrosoftVisualStudio" ;
"Version" = "latest" ;
"Skus" = "Windows-10-N-x64" ;
"VM" = $AzureVirtualMachine ;
"Offer" = "Windows" ;
} ;
$AzureVirtualMachine = `
Set-AzureRmVMSourceImage `
@newAzureRmVMSourceImageParams ;
# Create an Azure Resource Manager
# Virtual Machine network interface
$newAzureRmVMNetworkInterfaceParams = @{
"Name" = "EUS-ARM-PRD-ENV-VMNI-AZULABDT01" ;
"ResourceGroupName" = "EUS-ARM-PRD-ENV" ;
"Location" = "East US" ;
"SubnetId" = (
(
Get-AzureRmVirtualNetwork `
-ResourceGroupName "EUS-ARM-PRD-ENV" `
).Subnets | `
Where-Object { $_.Name -eq "Subnet-PRD-ENV-WIN" }
).Id ;
"PublicIpAddressId" = (
Get-AzureRmPublicIpAddress `
-Name "EUS-ARM-PRD-ENV-VN-PIP-AZULABDT01" `
-ResourceGroupName "EUS-ARM-PRD-ENV"
).Id ;
} ;
$newAzureRmVMNetworkInterface = `
New-AzureRmNetworkInterface `
@newAzureRmVMNetworkInterfaceParams ;
# Add Azure Resource Manager
# Virtual Machine network interface
# to Azure Virtual Machine
$AzureVirtualMachine = `
Add-AzureRmVMNetworkInterface `
-VM $AzureVirtualMachine `
-Id $newAzureRmVMNetworkInterface.Id ;
# Get the Existing Azure Resource Manager
# storage account for Virtual Machine
# VHD creation
$ExistingAzureRmStorageAccount = `
Get-AzureRmStorageAccount `
-Name "eus0storage0account01" `
-ResourceGroupName "EUS-ARM-PRD-ENV" ;
# Construct Azure Virtual Machine
# operating system VHD disk Uri
$newAzureRmOperatingSystemDiskUri = `
$ExistingAzureRmStorageAccount.PrimaryEndpoints.Blob.ToString() + `
"vhds/" + `
$newAzureRmVMConfig.Name + `
"_OperatingSystem" + `
".vhd" ;
# Configure the Azure Resource Manager
# Virtual Machine operating system disk
$newOperatingSystemDiskParams = @{
"Name" = "OperatingSystem" ;
"CreateOption" = "fromImage" ;
"VM" = $AzureVirtualMachine ;
"VhdUri" = $newAzureRmOperatingSystemDiskUri ;
} ;
$AzureVirtualMachine = `
Set-AzureRmVMOSDisk `
@newOperatingSystemDiskParams ;
# Create an Azure Resource Manager
# Virtual Machine now
$newAzureRmVirtualMachineParams = @{
"ResourceGroupName" = "EUS-ARM-PRD-ENV" ;
"Location" = "East US" ;
"VM" = $AzureVirtualMachine ;
} ;
New-AzureRmVM `
@newAzureRmVirtualMachineParams ;