-
Notifications
You must be signed in to change notification settings - Fork 1
/
1-lab7-WAC.ps1
50 lines (36 loc) · 1.88 KB
/
1-lab7-WAC.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
# LAB: Windows Admin Center
# The goal of this lab is to access Windows Admin Center on the windowsmgmt VM from your computer
# and add VM Scale Set instances as managed nodes
#region Define variables
$resourceGroupName = 'otp-vms-rg'
#endregion
# Find out the VM Scale Set InstanceIDs
Get-AzVmssVM -ResourceGroupName $resourceGroupName -VMScaleSetName demoscaleset |
Select-Object -ExpandProperty InstanceId -OutVariable InstanceIDs
# windowmgmt VM and VM scale set instances are in the different subnets
# you need to modify a scope for the public profile of Windows Remote Management rule on the target instances
code .\EnableAccessFromWindowsmgmtVM.ps1
Invoke-AzVmssVMRunCommand -ResourceGroupName $resourceGroupName -VMScaleSetName 'demoScaleSet' -InstanceId $InstanceIDs[0] -CommandId 'RunPowerShellScript' -ScriptPath 'EnableAccessFromWindowsmgmtVM.ps1'
<# OUTPUT
Value[0] :
Code : ComponentStatus/StdOut/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Message :
Value[1] :
Code : ComponentStatus/StdErr/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Message :
Status : Succeeded
Capacity : 0
Count : 0
#>
Invoke-AzVmssVMRunCommand -ResourceGroupName $resourceGroupName -VMScaleSetName 'demoScaleSet' -InstanceId $InstanceIDs[1] -CommandId 'RunPowerShellScript' -ScriptPath 'EnableAccessFromWindowsmgmtVM.ps1'
# Get the public IP of the linuxjumpbox VM
$PublicIP = (Get-AzPublicIpAddress -ResourceGroupName $resourceGroupName -Name linuxjumpbox-ip).IpAddress
cd ~/.ssh
az ssh config --file config --ip $publicIP
# Magic of a port forwarding; WAC on windowsmgmt VM is listening on port 6516 (by default)
ssh -L 6515:192.168.2.4:6516 $PublicIP -N
# Open WAC (https://localhost:6515) and add VM Scale Set instances using their private IP addresses (192.168.3.4 and 192.168.3.5)