-
Notifications
You must be signed in to change notification settings - Fork 0
/
Upgrade-Gen1ToTL.ps1
1107 lines (1023 loc) · 58.9 KB
/
Upgrade-Gen1ToTL.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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<#
.SYNOPSIS
Upgrades Azure VM from Gen1 to Trusted Launch Configuration with OS State preserved.
Script Version - 2.1.2
.DESCRIPTION
PREREQUISITES:
1. On-board to Gen1 to Trusted launch VM private preview at https://aka.ms/Gen1ToTLUpgrade.
2. Az.Compute, Az.Accounts PowerShell Module
3. Current Gen 1 VM is running.
4. VM Contributor rights on resource group.
5. If backup is enabled, Gen1 VM backup is configured with Enhanced policy.
1. Existing backup can be migrated to Enhanced policy using preview https://aka.ms/formBackupPolicyMigration.
6. ASR is not enabled for Gen1 VM. ASR currently does not supports Trusted launch VMs.
7. SSE CMK if enabled should be disabled during upgrade. It should be re-enabled post-upgrade.
8. Azure IaaS VM Agent should be installed and healthy.
STEPS:
1. Create csv with VMName, ResourceGroupName, EnableSecureBoot parameters.
2. Execute PowerShell script which will:
1. Check if current VM Size is compatible with Trusted launch.
2. Execute MBR to GPT OS Disk boot partition conversion.
3. De-allocate or Stop VM.
4. Update VM to Gen2-Trusted launch.
5. Start VM.
3. Validate health of workload and virtual machine.
4. Re-enable SSE CMK and disk encryptions.
.PARAMETER subscriptionId
Subscription ID for Gen1 VM.
.PARAMETER tenantDomain
Primary AAD Domain Name for authentication. (For example, contoso.onmicrosoft.com)
.PARAMETER csvLocation
Local file path location of csv containing vmName, vmResourceGroupName, enableSecureBoot details.
.PARAMETER batchSize
(Optional) Number of machines which should be processed in parallel. Default set to 5.
.PARAMETER useCloudshell
(Optional) Use cloud shell in Azure Portal for script execution.
.PARAMETER useSignedScript
(Optional) Use end to end signed script for upgrade.
.PARAMETER outputStorageAccountName
(Required with useSignedScript) Name of storage account where output and error file will be stored. Storage Blob Data Contributor or Storage Blob Data Owner access required on storage account.
.PARAMETER vmName
(Csv input parameter) Resource Name of Gen1 VM to be upgraded
.PARAMETER vmResourceGroupName
(Csv input parameter) Resource Group for Gen1 VM.
.PARAMETER enableSecureBoot
(Csv input parameter) If target Trusted Launch VM should be deployed with Secure Boot enabled (TRUE) or disabled (FALSE). This option should be disabled if VM is hosting custom or unsigned boot drivers which cannot be attested.
.EXAMPLE
.\Upgrade-Gen1ToTL.ps1 -subscriptionId $subscriptionId -tenantDomain contoso.onmicrosoft.com -csvLocation "C:\Temp\sampleCsv.csv"
Upgrade all VMs provided in csv from Gen1 to Trusted launch with specific parameter values.
.LINK
https://aka.ms/TrustedLaunch
.LINK
https://aka.ms/TrustedLaunchUpgrade
#>
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")]
param (
[Parameter(Mandatory = $true, HelpMessage = "Azure Subscription Id or Guid")]
[string][ValidateNotNullOrEmpty()]$subscriptionId,
[Parameter(Mandatory = $true, HelpMessage = "Azure Tenant domain")]
[string][ValidateNotNullOrEmpty()]$tenantDomain,
[Parameter(Mandatory=$false, HelpMessage = "The cloud environment where the VM exists.")]
[ValidateSet("AzureCloud","AzureChinaCloud","AzureUSGovernment")]
[string]$environment='AzureCloud',
[Parameter(Mandatory = $true, HelpMessage = "Location of csv containing Gen1 VM(s) details - vmName, vmResourceGroupName, EnableSecureBoot.")]
[string][ValidateNotNullOrEmpty()]$csvLocation,
[Parameter(Mandatory = $false, HelpMessage = "Number of machines which should be processed in parallel. Default set to 5.")]
[int][ValidateNotNullOrEmpty()]$batchSize,
[Parameter(Mandatory = $false, HelpMessage = "Use cloud shell in Azure Portal for script execution.")]
[switch]$useCloudshell,
[Parameter(Mandatory = $false, HelpMessage = "Use end to end signed script for upgrade.")]
[switch]$useSignedScript,
[Parameter(Mandatory = $false, HelpMessage = "Required if useSignedScript is set. Name of storage account where output and error file will be stored. Storage Blob Data Contributor or Storage Data Owner access required on storage account.")]
[string][ValidateNotNullOrEmpty()]$outputStorageAccountName
)
#region - Validate Pre-Requisites
try {
New-Variable -Name 'ERRORLEVEL' -Value 0 -Scope Script -Force
$PSVersion = $PSVersionTable.PSVersion
if ($PSVersion.Major -gt 7 -or ($PSVersion.Major -eq 7 -and $PSVersion.Minor -ge 2)) {
$messagetxt = "PowerShell version is greater than 7.2"
Write-Output $messageTxt
} else {
$messagetxt = "PowerShell version is not greater than 7.2 and does not meets requirements."
Write-Error $messagetxt
Set-Variable -Name ERRORLEVEL -Value -1 -Scope Script -Force
}
if ($useCloudshell) {
$workingDirectory = [system.string]::concat((Get-Location).Path, "/Gen1-TrustedLaunch-Upgrade")
} else {
if ((Test-Path $env:UserProfile -ErrorAction SilentlyContinue) -eq $true) {
$workingDirectory = "$env:UserProfile\Gen1-TrustedLaunch-Upgrade"
} else {
$messageTxt = "User profile directory not found. Defaulting to script execution location."
Write-Output $messagetxt
$workingDirectory = [system.string]::concat((Get-Location).Path, "\Gen1-TrustedLaunch-Upgrade")
}
}
if ((Test-Path $workingDirectory) -eq $true) {
$messageTxt = "Working Directory Already Setup $workingDirectory"
Write-Output $messageTxt
}
else {
$messageTxt = "Setting up working dir $workingDirectory"
Write-Output $messageTxt
New-Item -ItemType Directory -Path (Split-Path $workingDirectory -Parent) -Name (Split-Path $workingDirectory -Leaf) -ErrorAction 'Stop' | Out-Null
}
If ($useSignedScript -and !($outputStorageAccountName)) {
$messagetxt = "Output storage account name is required if useSignedScript is set."
Write-Error $messageTxt
Set-Variable -Name ERRORLEVEL -Value -1 -Scope Script -Force
}
$azPsModule = @(@{
ModuleName = 'Az.Accounts'
Version = [version]"2.8.0"
},
@{
ModuleName = 'Az.Compute'
Version = [version]"6.0.0"
},
@{
ModuleName = 'Az.Storage'
Version = [version]"5.8.0"
})
foreach ($azModule in $azPsModule) {
$module = Get-Module -ListAvailable -Name $azModule.ModuleName
# Check if the module is available
if ($module) {
# Check if the module version is greater than or equal to the minimum version
if ($module.Version -ge $azModule.Version) {
$messagetxt = "Module $($azModule.ModuleName) with minimum version $($azModule.Version) is available."
Write-Output $messageTxt
}
else {
$messagetxt = "Module $($azModule.ModuleName) is available, but its version is lower than the minimum version $($azModule.Version). Upgrading module on local machine."
Write-warning $messageTxt
Update-Module $($azModule.ModuleName) -ErrorAction 'Stop' -Confirm:$false -Force
}
}
else {
$messagetxt = "Module $($azModule.ModuleName) is not available, proceeding with $($azModule.ModuleName) install."
Write-warning $messageTxt
Install-Module -Name $($azModule.ModuleName) -Repository PSGallery -Force -Confirm:$false -ErrorAction 'Stop'
}
}
}
catch [system.exception] {
$messageTxt = 'Error Exception Occurred' + "`n$($psitem.Exception.Message)" + "`nError Caused By: $(($psitem.InvocationInfo.Line).Trim())"
Write-Output $messageTxt
$ERRORLEVEL = -1
}
#endregion
#region - Connect Azure Subscription
If ($ERRORLEVEL -eq 0) {
try {
$messageTxt = "Connecting to Subscription $subscriptionId under $tenantDomain"
Write-Output $messageTxt
Update-AzConfig -EnableLoginByWam $false -ErrorAction 'Stop'
#region - Enable-AzAccount()
if ($useCloudshell) {
Set-AzContext -SubscriptionId $subscriptionId -tenant $tenantDomain -ErrorAction 'Stop'
} else {
$azureProfile = "$workingDirectory\AzureProfile-$subscriptionId.json"
$paramTestPath = @{
Path = $($azureProfile)
ErrorAction = 'Stop'
}
if (Test-Path @paramTestPath) {
$messageTxt = "Clearing previously cached Azure profile JSON"
Write-Output $messageTxt
Remove-Item -Path $azureProfile -Force -Confirm:$false -ErrorAction 'Stop' | Out-Null
}
$paramTestPath = @{
Path = $workingDirectory
PathType = 'Container'
ErrorAction = 'Stop'
}
if (-not (Test-Path @paramTestPath)) {
$paramNewItem = @{
Path = $workingDirectory
ItemType = 'directory'
ErrorAction = 'Stop'
}
New-Item @paramNewItem | Out-Null
}
$paramConnectAzAccount = @{
subscriptionId = $subscriptionID
Tenant = $tenantDomain
ErrorAction = 'Stop'
}
if ($environment) {
$paramConnectAzAccount.Add('Environment', $environment)
}
Connect-AzAccount @paramConnectAzAccount
$paramSaveAzContext = @{
Path = $($azureProfile)
Force = $true
ErrorAction = 'Stop'
}
Save-AzContext @paramSaveAzContext | Out-Null
}
#endregion
#region - Check for feature registration
If ((Get-AzProviderFeature -ProviderNamespace "Microsoft.Compute" -FeatureName "Gen1ToTLMigrationPreview").RegistrationState -ne "Registered") {
$messageTxt = "Feature Gen1ToTLMigrationPreview is not registered. Registering now."
Write-Warning $messagetxt
Register-AzProviderFeature -ProviderNamespace "Microsoft.Compute" -FeatureName "Gen1ToTLMigrationPreview" -ErrorAction 'Stop'
do {
$registrationState = (Get-AzProviderFeature -ProviderNamespace "Microsoft.Compute" -FeatureName "Gen1ToTLMigrationPreview").RegistrationState
$messagetxt = "Registration state: $registrationState"
Write-Output $messagetxt
Start-Sleep -Seconds 10
} while ($registrationState -ne "Registered")
} else {
$messagetxt = "Feature Gen1ToTLMigrationPreview is already registered."
Write-Output $messagetxt
}
#endregion
}
catch [System.Exception] {
$messageTxt = 'Error Exception Occurred' + "`n$($psitem.Exception.Message)" + "`nError Caused By: $(($psitem.InvocationInfo.Line).Trim())"
Write-Output $messageTxt
Set-Variable -Name ERRORLEVEL -Value -1 -Scope Script -Force
}
}
#endregion
if ($ERRORLEVEL -eq 0) {
#region - Main script
if (-not $batchSize) {
[int]$batchSize = 5
}
$importVmArray = Import-Csv $csvLocation -ErrorAction 'Stop'
foreach ($element in $importVmArray) {
$element | Add-Member -MemberType NoteProperty -Name 'subscriptionId' -Value $subscriptionId
$element | Add-Member -MemberType NoteProperty -Name 'tenantDomain' -Value $tenantDomain
if ($useCloudshell) {
$element | Add-Member -MemberType NoteProperty -Name 'useCloudShell' -Value $true
}
if ($useSignedScript) {
$element | Add-Member -MemberType NoteProperty -Name 'useSignedScript' -Value $true
$element | Add-Member -MemberType NoteProperty -Name 'storageAccountName' -Value $outputStorageAccountName
}
}
$importVmArray | ForEach-Object -ThrottleLimit $batchSize -Parallel {
#region - Functions
function Get-ErrorLevel {
<#
.SYNOPSIS
Get ERRORLEVEL variable value
.DESCRIPTION
Get ERRORLEVEL variable value
.OUTPUTS
None.
.NOTES
#>
#region - Get ERRORLEVEL variable value
$script:ERRORLEVEL
#endregion
}
function Set-ErrorLevel {
<#
.SYNOPSIS
Set ERRORLEVEL variable value
.DESCRIPTION
Set ERRORLEVEL variable value
.PARAMETER level
ERRORLEVEL level [int] parameter.
.OUTPUTS
$ERRORLEVEL
.NOTES
#>
param
(
[Parameter(Mandatory = $false)]
[int]$level = 0
)
#region - Set Errorlevel
$script:ERRORLEVEL = $level
#endregion
}
function Write-InitLog {
param
(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$logDirectory,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$vmName
)
try {
$logStamp = (Get-Date -Format yy.MM.dd-HH.mm.ss)
$script:logFile = "$logDirectory\$($vmName)-Gen1-TL-Upgrade-" + $logStamp + '.log'
} catch [system.exception] {
$messageTxt = "Error Exception Occurred `nWrite-InitLog() `n$($psitem.Exception.Message)"
Write-Output $messageTxt
Set-ErrorLevel -1
return $ERRORLEVEL
}
}
function Write-LogEntry {
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
$logMessage,
[Parameter(Mandatory = $false)]
[int]$logSeverity = 1,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[String]$logComponent
)
try {
$time = Get-Date -Format 'HH:mm:ss.ffffff'
$date = Get-Date -Format 'MM-dd-yyyy'
$message = "<![LOG[$logMessage" + "]LOG]!><time=`"$time`" date=`"$date`" component=`"$logComponent`" context=`"`" type=`"$logSeverity`" thread=`"`" file=`"`">"
$paramOutFile = @{
Append = $true
Encoding = 'UTF8'
FilePath = $logFile
NoClobber = $true
}
$message | Out-File @paramOutFile
} catch [system.exception] {
$messageTxt = "Error Exception Occurred `nWrite-LogEntry() `n$($psitem.Exception.Message)"
Write-Output $messageTxt
Set-ErrorLevel -1
return $ERRORLEVEL
}
}
#endregion
$importVm = $_
$vmName = $importVm.vmName
$vmResourceGroupName = $importVm.vmResourceGroupName
$subscriptionId = $importVm.subscriptionID
$tenantDomain = $importVm.tenantDomain
$useCloudshell = $importVm.useCloudShell
$outputStorageAccountName = $importVm.storageAccountName
$useSignedScript = $importVm.useSignedScript
if ($importVm.enableSecureBoot) {
$enableSecureBoot = [system.convert]::ToBoolean($importVm.enableSecureBoot)
}
else { $enableSecureBoot = $true }
[bool]$gen2Vm = $false
[bool]$tlVm = $false
#region - Validate Pre-Requisites
try {
Set-Errorlevel 0 | Out-Null
Get-Errorlevel | Out-Null
if ($useCloudshell) {
$workingDirectory = [system.string]::concat((Get-Location).Path, "/Gen1-TrustedLaunch-Upgrade")
} else {
if ((Test-Path $env:UserProfile -ErrorAction SilentlyContinue) -eq $true) {
$workingDirectory = "$env:UserProfile\Gen1-TrustedLaunch-Upgrade"
} else {
$messageTxt = "User profile directory not found. Defaulting to script execution location."
Write-Output $messagetxt
$workingDirectory = [system.string]::concat((Get-Location).Path, "\Gen1-TrustedLaunch-Upgrade")
}
}
Write-InitLog -logDirectory $workingDirectory -vmName $vmName
$messageTxt = "Script Version: 2.1.2"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Setup-PreRequisites"
$inputParam = @{
'VM name' = $vmName
'Resource group name' = $vmResourceGroupName
'Subscription ID' = $subscriptionId
'Tenant Domain' = $tenantDomain
'Use Cloud Shell' = $useCloudshell
'Use Signed Script' = $useSignedScript
'Output Storage Account Name' = $outputStorageAccountName
'Enable Secure Boot' = $enableSecureBoot
}
$messageTxt = $inputParam.GetEnumerator() | ForEach-Object {"$($PSItem.Key) = $($PSItem.Value)"}
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Setup-PreRequisites"
$messageTxt = "Processing VM $vmName under resource group $vmResourceGroupName with Secure boot $($importVm.enableSecureBoot)"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Setup-PreRequisites"
}
catch [system.exception] {
$messageTxt = 'Error Exception Occurred' + "`n$($psitem.Exception.Message)" + "`nError Caused By: $(($psitem.InvocationInfo.Line).Trim())"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "Setup-PreRequisites"
Set-ErrorLevel -1
return $ERRORLEVEL
}
#endregion
#region - Connect Azure Subscription
If ($ERRORLEVEL -eq 0) {
try {
$messageTxt = "Connecting to Subscription $subscriptionId under $tenantDomain"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Connect-AzSubscription"
#region - Enable-AzAccount()
If ($useCloudshell -eq $true) {
Set-AzContext -SubscriptionId $subscriptionId -tenant $tenantDomain -ErrorAction 'Stop'
} else {
$azureProfile = "$workingDirectory\AzureProfile-$subscriptionId.json"
$paramTestPath = @{
Path = $($azureProfile)
ErrorAction = 'Stop'
}
if (Test-Path @paramTestPath) {
$paramImportAzContext = @{
Path = $($azureProfile)
ErrorAction = 'Stop'
}
Import-AzContext @paramImportAzContext | Out-Null
} else {
$paramTestPath = @{
Path = $workingDirectory
PathType = 'Container'
ErrorAction = 'Stop'
}
if (-not (Test-Path @paramTestPath)) {
$paramNewItem = @{
Path = $workingDirectory
ItemType = 'directory'
ErrorAction = 'Stop'
}
New-Item @paramNewItem | Out-Null
}
$paramConnectAzAccount = @{
subscriptionId = $subscriptionID
Tenant = $tenantDomain
ErrorAction = 'Stop'
}
if ($environment) {
$paramConnectAzAccount.Add('Environment', $environment)
}
Connect-AzAccount @paramConnectAzAccount
$paramSaveAzContext = @{
Path = $($azureProfile)
Force = $true
ErrorAction = 'Stop'
}
Save-AzContext @paramSaveAzContext | Out-Null
}
}
#endregion
}
catch [System.Exception] {
$messageTxt = 'Error Exception Occurred' + "`n$($psitem.Exception.Message)" + "`nError Caused By: $(($psitem.InvocationInfo.Line).Trim())"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "Connect-AzSubscription"
Set-ErrorLevel -1
return $ERRORLEVEL
}
}
#endregion
#region - Current VM Configuration
If ($ERRORLEVEL -eq 0) {
try {
$messageTxt = "Mapping existing configuration for $vmName under $vmResourceGroupName"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Get-AzVM"
$paramGetAzVm = @{
ResourceGroupName = $vmResourceGroupName
Name = $vmName
ErrorAction = 'Stop'
}
$currentVm = Get-AzVM @paramGetAzVm
$CurrentVMConfig = @{
osdisk = $currentvm.StorageProfile.OsDisk
vmsize = $currentvm.HardwareProfile.VmSize
location = $currentVm.Location
securityType = $currentVm.SecurityProfile.SecurityType
}
$osDiskParam = @{
ResourceGroupName = $currentVm.ResourceGroupName
Name = $CurrentVMConfig.osdisk.Name
ErrorAction = 'Stop'
}
$currentOsDisk = Get-AzDisk @osDiskParam
$currentOsDiskConfig = @{
sku = $currentOsDisk.sku.Name
diskSize = $currentOsDisk.DiskSizeGB
HyperVGen = $currentOsDisk.HyperVGeneration
osType = $currentOsDisk.OsType
encryption = $currentOsDisk.Encryption
}
if ($currentOsDiskConfig.HyperVGen -eq "V2") {
if ($CurrentVMConfig.securityType) {
$messagetxt = "VM $vmName under resource group $vmResourceGroupName is already Trusted launch, no further action required."
Write-Output $messagetxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Get-AzVM"
[bool]$tlVm = $true
[bool]$gen2Vm = $true
}
else {
$messageTxt = "VM $vmName under resource group $vmResourceGroupName is running as Gen2. MBR2GPT conversion will be skipped."
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Get-AzVM"
[bool]$gen2Vm = $true
}
}
if ($currentOsDiskConfig.osType -eq "Linux") {
$paramGetAzVm = @{
ResourceGroupName = $vmResourceGroupName
Name = $vmName
Status = $true
ErrorAction = 'Stop'
}
$currentOs = Get-AzVM @paramGetAzVm
$messageTxt = "OS Type of Source VM is $($currentOsDiskConfig.osType) and OS Name is $($currentOs.OsName)."
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Get-AzVM"
}
#region - Validate SKU Support
If ($tlVm -eq $false) {
$messageTxt = "Validating VM SKU $($CurrentVMConfig.vmsize) for $vmname is supported for Trusted launch"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Get-AzVM"
$gen2Support = $null
$tlvmSupport = $null
$skuDetail = Get-AzComputeResourceSku -Location $($CurrentVMConfig.location) -ErrorAction 'Stop' | `
Where-Object { $psitem.Name -eq $($CurrentVMConfig.vmsize) }
$gen2Support = $skuDetail | Select-Object -Property Capabilities -ExpandProperty Capabilities | Where-Object { $psitem.Name -eq "HyperVGenerations" }
$tlvmSupport = $skuDetail | Select-Object -Property Capabilities -ExpandProperty Capabilities | Where-Object { $psitem.Name -eq "TrustedLaunchDisabled" }
if (($gen2Support.value.Split(",")[-1] -eq "V2") -and !($tlvmSupport)) {
$messageTxt = "VM SKU $($CurrentVMConfig.vmsize) supported for TLVM. Proceeding to create TLVM."
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Get-AzVM"
}
else {
$messageTxt = "VM SKU $($CurrentVMConfig.vmsize) not supported for Trusted launch. Update VM Size to Trusted launch Supported SKU. For more details, https://aka.ms/TrustedLaunch"
Write-Error $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "Get-AzVM"
Set-ErrorLevel -1
return $ERRORLEVEL
}
}
#endregion
}
catch [System.Exception] {
$messageTxt = 'Error Exception Occurred' + "`n$($psitem.Exception.Message)" + "`nError Caused By: $(($psitem.InvocationInfo.Line).Trim())"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "Get-AzVM"
Set-ErrorLevel -1
return $ERRORLEVEL
}
}
#endregion
#region - MBR to GPT Validation
if ($ERRORLEVEL -eq 0) {
try {
if ($gen2Vm -eq $false) {
if ($currentOsDiskConfig.osType -ne "Linux") {
if ($currentOs.OsName -contains '2016') {
$messagetxt = "Windows Server 2016 does not supports native MBR to GPT upgrade. Please follow offline upgrade path available in GitHub repo. Terminating script"
Write-Error $messagetxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "MBR-GPT-Validation"
Set-ErrorLevel -1
}
else {
$messageTxt = "Validating MBR to GPT conversion support for $vmname"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Validation"
If ($useSignedScript -eq $true) {
$messageTxt = "Using signed script for executing MBR to GPT validation"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Validation"
$messageTxt = "Creating container gen1log in storage account $outputStorageAccountName"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Validation"
$ctx = New-AzStorageContext -StorageAccountName $outputStorageAccountName -UseConnectedAccount -erroraction 'stop'
New-AzStoragecontainer -Name "gen1log" -Context $ctx -ErrorAction 'SilentlyContinue' | Out-Null
$messageTxt = "Generating SAS URL for output file in storage account $outputStorageAccountName"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Validation"
$sasToken = New-AzStorageContainerSASToken -Context $ctx -Name "gen1log" -Permission rawl -StartTime $((Get-Date).AddMinutes(-5)) -ExpiryTime $((Get-Date).AddHours(1)) -ErrorAction 'Stop'
$outputBlobSasUri = "https://$outputStorageAccountName.blob.core.windows.net/gen1log/$vmName-mbr2gpt-validate-output.log?" + $sasToken
$errorBlobSasUri = "https://$outputStorageAccountName.blob.core.windows.net/gen1log/$vmName-mbr2gpt-validate-error.log?" + $sasToken
$messageTxt = "Executing MBR to GPT validation for $vmName"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Validation"
$paramInvokeAzVMRunCommand = @{
ResourceGroupName = $vmResourceGroupName
VMName = $vmName
Location = $CurrentVMConfig.location
RunCommandName = [system.string]::Concat($vmName, "-MBR2GPT-Validate")
SourceScriptUri = "https://raw.githubusercontent.com/AjKundnani/Gen1-TrustedLaunch/main/artifacts/Validate-MBRToGPT.ps1"
OutputBlobUri = $outputBlobSasUri
ErrorBlobUri = $errorBlobSasUri
ErrorAction = 'Stop'
}
Set-AzVMRunCommand @paramInvokeAzVMRunCommand | Out-Null
$outputLog = (Get-AzStorageBlobContent -Blob "$vmName-mbr2gpt-validate-output.log" -Container "gen1log" -Context $ctx).ICloudBlob.DownloadText()
$errorLog = (Get-AzStorageBlobContent -Blob "$vmName-mbr2gpt-validate-error.log" -Container "gen1log" -Context $ctx).ICloudBlob.DownloadText()
if ($errorLog.Length -gt 0 -or $outputLog.Length -eq 0) {
$messagetxt = "MBR to GPT support validation for Windows $vmname failed. Terminating script execution."
Write-Error $messagetxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "MBR-GPT-Validation"
Set-ErrorLevel -1
}
else {
Remove-Item -Path "$vmName-mbr2gpt-validate-output.log" -Force -Confirm:$false
Remove-Item -Path "$vmName-mbr2gpt-validate-error.log" -Force -Confirm:$false
$messagetxt = "MBR to GPT support validation for Windows $vmname completed successfully."
Write-Output $messagetxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Validation"
}
} else {
$commandId = "RunPowerShellScript"
$scriptString = "MBR2GPT /validate /allowFullOS"
$paramInvokeAzVMRunCommand = @{
ResourceGroupName = $vmResourceGroupName
VMName = $vmName
CommandId = $commandId
ScriptString = $scriptString
ErrorAction = 'Stop'
}
$mbrtogptValidate = Invoke-AzVMRunCommand @paramInvokeAzVMRunCommand
# Write-Output $mbrtogptValidate
if ($mbrtogptValidate.Value[-1].Message -or !($mbrtogptValidate.Value[0].Message)) {
$messagetxt = "MBR to GPT support validation for Windows $vmname failed. Terminating script execution."
Write-Error $messagetxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "MBR-GPT-Validation"
Set-ErrorLevel -1
}
else {
$messagetxt = "MBR to GPT support validation for Windows $vmname completed successfully."
Write-Output $messagetxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Validation"
}
}
}
}
}
}
catch [System.Exception] {
$messageTxt = 'Error Exception Occurred' + "`n$($psitem.Exception.Message)" + "`nError Caused By: $(($psitem.InvocationInfo.Line).Trim())"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "MBR-GPT-Validation"
Set-ErrorLevel -1
return $ERRORLEVEL
}
}
#endregion
#region - MBR to GPT conversion
if ($ERRORLEVEL -eq 0) {
try {
if ($gen2Vm -eq $false) {
if ($currentOsDiskConfig.osType -eq "Linux") {
$messageTxt = "Assuming MBR to GPT conversion has been completed as per documented pre-requisites. Proceeding with Trusted launch upgrade."
Write-Warning $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 2 -logComponent "MBR-GPT-Execution"
# $commandId = "RunShellScript"
# switch ($currentOs.OsName) {
# "Ubuntu" {
# $scriptString = "gdisk /dev/sda \
# partprobe /dev/sda \
# grub-install /dev/sda"
# }
# default {
# $scriptString = "gdisk /dev/sda \
# partprobe /dev/sda \
# grub2-install /dev/sda"
# }
# }
}
else {
$messageTxt = "Executing MBR to GPT conversion on $vmname"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Execution"
if ($useSignedScript -eq $true) {
$messageTxt = "Using signed script for executing MBR to GPT validation"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Execution"
$messageTxt = "Creating container gen1log in storage account $outputStorageAccountName"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Execution"
$ctx = New-AzStorageContext -StorageAccountName $outputStorageAccountName -UseConnectedAccount -erroraction 'stop'
New-AzStoragecontainer -Name "gen1log" -Context $ctx -ErrorAction 'SilentlyContinue' | Out-Null
$messageTxt = "Generating SAS URL for output file in storage account $outputStorageAccountName"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Execution"
$sasToken = New-AzStorageContainerSASToken -Context $ctx -Name "gen1log" -Permission rawl -StartTime $((Get-Date).AddMinutes(-5)) -ExpiryTime $((Get-Date).AddHours(1)) -ErrorAction 'Stop'
$outputBlobSasUri = "https://$outputStorageAccountName.blob.core.windows.net/gen1log/$vmName-mbr2gpt-convert-output.log?" + $sasToken
$errorBlobSasUri = "https://$outputStorageAccountName.blob.core.windows.net/gen1log/$vmName-mbr2gpt-convert-error.log?" + $sasToken
$messageTxt = "Executing MBR to GPT conversion for $vmName"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Execution"
$paramInvokeAzVMRunCommand = @{
ResourceGroupName = $vmResourceGroupName
VMName = $vmName
Location = $CurrentVMConfig.location
RunCommandName = [system.string]::Concat($vmName, "-MBR2GPT-Convert")
SourceScriptUri = "https://raw.githubusercontent.com/AjKundnani/Gen1-TrustedLaunch/main/artifacts/Convert-MBRToGPT.ps1"
OutputBlobUri = $outputBlobSasUri
ErrorBlobUri = $errorBlobSasUri
ErrorAction = 'Stop'
}
Set-AzVMRunCommand @paramInvokeAzVMRunCommand | Out-Null
$outputLog = (Get-AzStorageBlobContent -Blob "$vmName-mbr2gpt-convert-output.log" -Container "gen1log" -Context $ctx).ICloudBlob.DownloadText()
$errorLog = (Get-AzStorageBlobContent -Blob "$vmName-mbr2gpt-convert-error.log" -Container "gen1log" -Context $ctx).ICloudBlob.DownloadText()
if ($errorLog.Length -gt 0 -or $outputLog.Length -eq 0) {
$messagetxt = "MBR to GPT support conversion for Windows $vmname failed. Terminating script execution."
Write-Error $messagetxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "MBR-GPT-Execution"
Set-ErrorLevel -1
}
else {
Remove-Item -Path "$vmName-mbr2gpt-convert-output.log" -Force -Confirm:$false
Remove-Item -Path "$vmName-mbr2gpt-convert-error.log" -Force -Confirm:$false
$messagetxt = "MBR to GPT support conversion for Windows $vmname completed successfully."
Write-Output $messagetxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Execution"
}
} else {
$commandId = "RunPowerShellScript"
$scriptString = "MBR2GPT /convert /allowFullOS"
$paramInvokeAzVMRunCommand = @{
ResourceGroupName = $vmResourceGroupName
VMName = $vmName
CommandId = $commandId
ScriptString = $scriptString
ErrorAction = 'Stop'
}
$mbrtogpt = Invoke-AzVMRunCommand @paramInvokeAzVMRunCommand
# Write-Output $mbrtogpt
if ($mbrtogpt.Value[-1].Message -or !($mbrtogpt.Value[0].Message)) {
$messagetxt = "MBR to GPT conversion for Windows $vmname failed. Terminating script execution."
Write-Error $messagetxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "MBR-GPT-Execution"
Set-ErrorLevel -1
}
else {
$messagetxt = "MBR to GPT conversion for Windows $vmname completed successfully."
Write-Output $messagetxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "MBR-GPT-Execution"
}
}
}
}
}
catch [System.Exception] {
$messageTxt = 'Error Exception Occurred' + "`n$($psitem.Exception.Message)" + "`nError Caused By: $(($psitem.InvocationInfo.Line).Trim())"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "MBR-GPT-Execution"
Set-ErrorLevel -1
return $ERRORLEVEL
}
}
#endregion
#region - Upgrade VM to Trusted launch
if ($ERRORLEVEL -eq 0) {
try {
if ($tlvm -eq $false) {
$messageTxt = "De-allocating $vmname"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Upgrade-AzVM"
$paramStopAzVm = @{
ResourceGroupName = $vmResourceGroupName
Name = $vmName
Force = $true
Confirm = $false
ErrorAction = 'Stop'
}
Stop-AzVm @paramStopAzVm | Out-Null
$messageTxt = "Updating security type for $vmname to Trusted launch"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Upgrade-AzVM"
$paramUpdateAzVm = @{
ResourceGroupName = $vmResourceGroupName
VM = $currentVm
SecurityType = 'TrustedLaunch'
EnableVtpm = $true
ErrorAction = 'Stop'
}
if ($enableSecureBoot -eq $true) {
$paramUpdateAzVm.Add('EnableSecureBoot', $true)
}
else { $paramUpdateAzVm.Add('EnableSecureBoot', $false) }
Update-AzVM @paramUpdateAzVm | Out-Null
$messageTxt = "Starting $vmname"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Upgrade-AzVM"
$paramStartAzVm = @{
ResourceGroupName = $vmResourceGroupName
Name = $vmName
ErrorAction = 'Stop'
}
Start-AzVM @paramStartAzVm | Out-Null
}
}
catch [System.Exception] {
$messageTxt = 'Error Exception Occurred' + "`n$($psitem.Exception.Message)" + "`nError Caused By: $(($psitem.InvocationInfo.Line).Trim())"
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 1 -logComponent "Upgrade-AzVM"
Set-ErrorLevel -1
return $ERRORLEVEL
}
}
#endregion
#region - closure
if ($ERRORLEVEL -eq 0) {
$messageTxt = "Gen1 to Trusted launch upgrade complete for $vmName."
Write-Output $messageTxt
Write-LogEntry -logMessage $messageTxt -logSeverity 3 -logComponent "Update-AzVM"
}
#endregion
}
#endregion
}
# SIG # Begin signature block
# MIIoQQYJKoZIhvcNAQcCoIIoMjCCKC4CAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCC2y2ic3DdfE49D
# beLMYjbjDu6H/A04e2Dm65EPC7KHsqCCDYswggYJMIID8aADAgECAhMzAAADhNlo
# fWbMdUuhAAAAAAOEMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p
#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