-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-vm.ps1
39 lines (32 loc) · 1.71 KB
/
deploy-vm.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
Set-Location G:\OneDrive\Documents\GitHub\BeardLInux\bicep # yes use your own path here !!
$resourceGroupName = 'beardarc'
# I use the SecretsManagement PowerShell module to store my secrets which can be installed with `Install-Module SecretManagement`. I add secrets with `Set-Secret -Name nameofsecret -Secret secretvalue`.
# You will need to change this for your own environment
$admincredentials = New-Object System.Management.Automation.PSCredential ((Get-Secret -Name beardmi-benadmin-user -AsPlainText), (Get-Secret -Name beardmi-benadmin-pwd))
<#
# if you do not store them in secrets management use this
$admincredentials = New-Object System.Management.Automation.PSCredential ('username here ', (ConvertTo-SecureString -String 'password here' -AsPlainText))
#>
$date = Get-Date -Format yyyyMMddHHmmsss
$deploymentname = 'deploy_VM_{0}_{1}' -f $ResourceGroupName, $date # name of the deployment seen in the activity log
$deploymentConfig = @{
resourceGroupName = $resourceGroupName
Name = $deploymentname
TemplateFile = 'vm.bicep'
virtualMachineName = 'jump'
osDiskType = 'Premium_LRS'
virtualMachineSize = 'Standard_D8s_v3'
adminUsername = $admincredentials.UserName
adminPassword = $admincredentials.Password
publisher = 'MicrosoftWindowsDesktop'
offer = 'Windows-10'
sku = '21h1-ent-g2'
version = 'latest'
tags = @{
Important = 'This is controlled by Bicep'
creator = 'The Beard'
project = 'For Ben'
BenIsAwesome = $true
}
}
New-AzResourceGroupDeployment @deploymentConfig # -WhatIf # uncomment what if to see "what if" !!