Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Configure vCenter 7 Profile from PowerShell GUI

While working on POC of new feature VMware vCenter Server 7 Profiles, as there is no GUI available to configure it. At the moment of writing it can be only consumed and configured with Rest APIs. Although Rest API can be configured from vCenter Server developer center > API explorer, but it is not that easy and user friendly to use it. So I thought on writing and giving graphical user inteface with PowerShell script to do the related profile Rest API operations. Making end user process easier.

vmware vsphere vCenter server Profiles Powershell GUI vcsa appliance rest api esxi

You can execute the script with PowerShell and this GUI allows to do all vCenter Profile related tasks LIST, EXPORT, VALIDATE and IMPORT. With this you can ensure there is a Consistent configuration across all your vCenter Servers.

VMware vSphere vcenter server profiles REST APIs list export import validate Export Json configuration profile management network auth etc consistent configuration across all vCenters servers.png

Below script can used on PowerShell directly to execute. To more details check VMware vCenter Server 7 Profiles.

  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
#requires -Version 3
#Code Written by:  vJANVI - vCloud-lab.com

[void][reflection.assembly]::Load('System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[void][reflection.assembly]::Load('System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
[void][reflection.assembly]::Load('System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')

[System.Windows.Forms.Application]::EnableVisualStyles()
$formVMwareVCenterProfile = New-Object 'System.Windows.Forms.Form'
$buttonTargetLogin = New-Object 'System.Windows.Forms.Button'
$maskedtextboxTargetPassword = New-Object 'System.Windows.Forms.MaskedTextBox'
$label2 = New-Object 'System.Windows.Forms.Label'
$label3 = New-Object 'System.Windows.Forms.Label'
$textboxTargetUserName = New-Object 'System.Windows.Forms.TextBox'
$textboxTargetvCenter = New-Object 'System.Windows.Forms.TextBox'
$label1 = New-Object 'System.Windows.Forms.Label'
$maskedtextboxSourcePassword = New-Object 'System.Windows.Forms.MaskedTextBox'
$labelPassword = New-Object 'System.Windows.Forms.Label'
$labelUserName = New-Object 'System.Windows.Forms.Label'
$textboxSourceUserName = New-Object 'System.Windows.Forms.TextBox'
$groupbox4 = New-Object 'System.Windows.Forms.GroupBox'
$textboxImportValidate = New-Object 'System.Windows.Forms.TextBox'
$buttonValidateJSONConfigra = New-Object 'System.Windows.Forms.Button'
$buttonImportJSONConfigurat = New-Object 'System.Windows.Forms.Button'
$buttonLoadJSON = New-Object 'System.Windows.Forms.Button'
$labelJsonProfilePath = New-Object 'System.Windows.Forms.Label'
$textboxLoadJSONPath = New-Object 'System.Windows.Forms.TextBox'
$groupbox2 = New-Object 'System.Windows.Forms.GroupBox'
$buttonExport = New-Object 'System.Windows.Forms.Button'
$labelExportJSONPath = New-Object 'System.Windows.Forms.Label'
$textboxExportJsonPath = New-Object 'System.Windows.Forms.TextBox'
$groupbox1vCenterProfileConfiguration = New-Object 'System.Windows.Forms.GroupBox'
$buttonListProfiles = New-Object 'System.Windows.Forms.Button'
$textboxListProfile = New-Object 'System.Windows.Forms.TextBox'
$statusstrip1 = New-Object 'System.Windows.Forms.StatusStrip'
$buttonSourceLogin = New-Object 'System.Windows.Forms.Button'
$labelSourceVCenter = New-Object 'System.Windows.Forms.Label'
$textboxSourcevCenter = New-Object 'System.Windows.Forms.TextBox'
$toolstripstatuslabel1Status = New-Object 'System.Windows.Forms.ToolStripStatusLabel'
$savefiledialogExportJSON = New-Object 'System.Windows.Forms.SaveFileDialog'
$openfiledialogLoadJSON = New-Object 'System.Windows.Forms.OpenFileDialog'
$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'

function Get-vCenterAPISessionID
{
	#https://developer.vmware.com/docs/vsphere-automation/latest/appliance/infraprofile/configs/
			
	[CmdletBinding()]
	param (
		[Parameter(Position = 0, Mandatory = $true)]
		[System.String]$vCenter,
		[Parameter(Position = 1, Mandatory = $true)]
		[System.String]$username,
		[Parameter(Position = 2, Mandatory = $true)]
		[System.String]$password
	)
	$secureStringPassword = ConvertTo-SecureString $password -AsPlainText -Force
	$encryptedPassword = ConvertFrom-SecureString -SecureString $secureStringPassword
	$credential = New-Object System.Management.Automation.PsCredential($username, ($encryptedPassword | ConvertTo-SecureString))
	#$credential.GetNetworkCredential().Password
			
	if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
	{
		$certCallback = @'  
    using System;  
    using System.Net;  
    using System.Net.Security;  
    using System.Security.Cryptography.X509Certificates;  
    public class ServerCertificateValidationCallback  
    {  
        public static void Ignore()  
        {  
            if (ServicePointManager.ServerCertificateValidationCallback == null)  
            {  
                ServicePointManager.ServerCertificateValidationCallback +=  
                delegate   
                (  
                    Object Obj,  
                    X509Certificate certificate,  
                    X509Chain chain,  
                    SslPolicyErrors errors  
                )  
                {  
                    return true;  
                };  
            }  
        }  
    }  
'@
		Add-Type $certCallback
	} #if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
			
	#execute c# code and ignore invalid certificate error  
	[ServerCertificateValidationCallback]::Ignore();
			
	#Type credential and process to base 64  
	#$credential = Get-Credential -Message 'Type vCenter Password' -UserName 'administrator@vsphere.local'  
	$auth = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($credential.UserName + ':' + $credential.GetNetworkCredential().Password))
	$head = @{
		Authorization = "Basic $auth"
	}
			
	#Authenticate against vCenter  #old Url - https://$vCenter/rest/com/vmware/cis/session
	#https://developer.vmware.com/docs/vsphere-automation/latest/cis/api/session/post/
			
	$loginUrl = Invoke-WebRequest -Uri "https://$vCenter/rest/com/vmware/cis/session" -Method Post -Headers $head
			
	$token = ConvertFrom-Json $loginUrl.Content | Select-Object -ExpandProperty Value
	$session = @{ 'vmware-api-session-id' = $token }
	$session
}
	
$formVMwareVCenterProfile_Load={
	function Show-MessageBox
	{
		param (
			[string]$Message = "Show user friendly Text Message",
			[string]$Title = 'Title here',
			[ValidateRange(0, 5)]
			[Int]$Button = 0,
			[ValidateSet('None', 'Hand', 'Error', 'Stop', 'Question', 'Exclamation', 'Warning', 'Asterisk', 'Information')]
			[string]$Icon = 'Error'
		)
		#Note: $Button is equl to [System.Enum]::GetNames([System.Windows.Forms.MessageBoxButtons])   
		#Note: $Icon is equl to [System.Enum]::GetNames([System.Windows.Forms.MessageBoxIcon])   
		$MessageIcon = [System.Windows.Forms.MessageBoxIcon]::$Icon
		[System.Windows.Forms.MessageBox]::Show($Message, $Title, $Button, $MessageIcon)
	}
}
	
$buttonSourceLogin_Click={
	try
	{
		$global:sourceSession = Get-vCenterAPISessionID -vCenter $textboxSourcevCenter.Text -username $textboxSourceUserName.Text -password $maskedtextboxSourcePassword.Text
		$toolstripstatuslabel1Status.Text = 'Status: Connected to Source vCenter, Export Profile config'
		$buttonListProfiles.Enabled = $true
		$buttonExport.Enabled = $true
	}
	catch
	{
		$toolstripstatuslabel1Status.Text = 'Status: Source vCenter connection failed, Retry!'
	}
	
}
	
$buttonListProfiles_Click={
	function List-vCenterAPIProfile
	{
		[CmdletBinding()]
		param (
			[Parameter(Position = 0, Mandatory = $true)]
			[System.String]$vCenter,
			[Parameter(Position = 1, Mandatory = $true)]
			[System.Collections.Hashtable]$session
		)
			
		#curl -X GET 'https://marvel.vcloud-lab.com/api/appliance/infraprofile/configs' -H 'vmware-api-session-id: 2181a0349363fb44415a9f0110e9162e'
		#Main list vCenter API url  
		$listProfileAPIUrl = "https://$vCenter/api/appliance/infraprofile/configs"
		#List vCenter profiles from vcenter  
		$listProfileAPI = Invoke-WebRequest -Uri $listProfileAPIUrl -Method Get -Headers $session
		$listProfileJson = $listProfileAPI.Content
		#ConvertFrom-Json $listProfileJson
		$listProfileJson
	}
	$textboxListProfile.Text = List-vCenterAPIProfile -vCenter $textboxSourcevCenter.Text -session $sourceSession
}
	
$buttonExport_Click={
	$savefiledialogExportJSON.initialDirectory = 'C:\'
	$savefiledialogExportJSON.filter = "JSON File (*.JSON)| *.JSON"
	$savefiledialogExportJSON.ShowDialog() | Out-Null
	$savefiledialogExportJSON.AddExtension = $true
	$textboxExportJsonPath.text = $savefiledialogExportJSON.FileName
		
	function Export-vCenterAPIProfile
	{
		[CmdletBinding()]
		param (
			[Parameter(Position = 0, Mandatory = $true)]
			[System.String]$vCenter,
			[Parameter(Position = 1, Mandatory = $true)]
			[System.Collections.Hashtable]$session
		)
		#curl -X POST 'https://marvel.vcloud-lab.com/api/appliance/infraprofile/configs?action=export' -H 'vmware-api-session-id: 2181a0349363fb44415a9f0110e9162e' -H 'Content-type: application/json'
		#https://developer.vmware.com/docs/vsphere-automation/latest/appliance/data-structures/Infraprofile/Configs/ProfilesSpec/
		#https://developer.vmware.com/docs/vsphere-automation/latest/appliance/api/appliance/infraprofile/configsactionvalidatevmw-tasktrue/post/
		#Main export vCenter API url 
		$exportProfileAPIUrl = "https://$vCenter/api/appliance/infraprofile/configs?action=export"
		#export vCenter profiles from vcenter
	<#
	$headers = @{
	    'vmware-api-session-id' = $token  
	    'Content-type' = 'application/json'
	}
	#>
		$exportProfileAPI = Invoke-WebRequest -Uri $exportProfileAPIUrl -Method Post -Headers $session -ContentType 'application/json'
		#(ConvertFrom-Json (ConvertFrom-Json $exportProfileAPI.Content)).profiles | Format-List
		$exportProfileJson = $exportProfileAPI.Content
		$exportProfileJson
	}
		
	$jsonProfile = Export-vCenterAPIProfile -vCenter $textboxSourcevCenter.Text -session $sourceSession
	$jsonProfile | Out-File $textboxExportJsonPath.Text
		
	$toolstripstatuslabel1Status.Text = 'Status: Export Profile config, Connect to Target vCenter'
	$textboxLoadJSONPath.Text = $textboxExportJsonPath.Text
}
	
$buttonTargetLogin_Click={
	try
	{
		$global:TargetSession = Get-vCenterAPISessionID -vCenter $textboxTargetvCenter.Text -username $textboxTargetUserName.Text -password $maskedtextboxTargetPassword.Text
		$toolstripstatuslabel1Status.Text = 'Status: Connected to Target vCenter, Either Import or Validate Profile config'
		$buttonImportJSONConfigurat.Enabled = $true
		$buttonValidateJSONConfigra.Enabled = $true
	}
	catch
	{
		$toolstripstatuslabel1Status.Text = 'Status: Target vCenter connection failed, Retry!'
	}
	$textboxLoadJSONPath.Text = $textboxExportJsonPath.Text
}
	
$buttonLoadJSON_Click={
	$textboxLoadJSONPath.Text = $textboxExportJsonPath.Text
	$basePath = Split-Path $textboxLoadJSONPath.Text -Parent
	$openfiledialogLoadJSON.initialDirectory = $basePath
	$openfiledialogLoadJSON.filter = "JSON File (*.JSON)|*.JSON|All Files (*.*)|*.*"
	$openfiledialogLoadJSON.ShowDialog() | Out-Null
	$textboxLoadJSONPath.text = $openfiledialogLoadJSON.FileName
	$global:jsonFile = Get-Content $textboxLoadJSONPath.text
}
	
$buttonImportJSONConfigurat_Click={
	$global:jsonFile = Get-Content $textboxLoadJSONPath.text
	function Import-vCenterAPIProfile
	{
		[CmdletBinding()]
		param (
			[Parameter(Position = 0, Mandatory = $true)]
			[System.String]$vCenter,
			[Parameter(Position = 1, Mandatory = $true)]
			[System.Collections.Hashtable]$Session,
			[Parameter(Position = 2, Mandatory = $true)]
			[System.String]$JsonProfile
		)
		#curl -X POST 'https://marvel.vcloud-lab.com/api/appliance/infraprofile/configs?action=import&vmw-task=true' -H 'vmware-api-session-id: 2181a0349363fb44415a9f0110e9162e' -H 'Content-type: application/json'
		#Main validate vCenter API url 
		$importProfileAPIUrl = "https://$vCenter/api/appliance/infraprofile/configs?action=import&vmw-task=true"
		#export vCenter profiles from vcenter
			
		$headers = @{
			'vmware-api-session-id' = $Session['vmware-api-session-id']
			'Content-type'		    = 'application/json'
		}
			
		$body = @{
			'config_spec' = $JsonProfile
		}
			
		$importProfileAPI = Invoke-WebRequest -Uri $importProfileAPIUrl -Method Post -Headers $headers -Body (Convertto-json $body)
		$importProfileJson = $importProfileAPI.Content
		$importProfileJson
	}
	$textboxImportValidate.Text = Import-vCenterAPIProfile -vCenter $textboxTargetvCenter.Text -session $targetsession -JsonProfile $jsonFile
	$toolstripstatuslabel1Status.Text = 'Status: Imported profile on Target vCenter Server'
}
	
$buttonValidateJSONConfigra_Click={
	$global:jsonFile = Get-Content $textboxLoadJSONPath.text
	function Validate-vCenterAPIProfile
	{
		[CmdletBinding()]
		param (
			[Parameter(Position = 0, Mandatory = $true)]
			[System.String]$vCenter,
			[Parameter(Position = 1, Mandatory = $true)]
			[System.Collections.Hashtable]$session,
			[Parameter(Position = 2, Mandatory = $true)]
			[System.String]$JsonProfile
		)
		#curl -X POST 'https://marvel.vcloud-lab.com/api/appliance/infraprofile/configs?action=import&vmw-task=true' -H 'vmware-api-session-id: 2181a0349363fb44415a9f0110e9162e' -H 'Content-type: application/json'
		#Main validate vCenter API url
		$validateProfileAPIUrl = "https://$vCenter/api/appliance/infraprofile/configs?action=validate&vmw-task=true"
		#export vCenter profiles from vcenter
		$headers = @{
			'vmware-api-session-id' = $session['vmware-api-session-id']
			'Content-type'		    = 'application/json'
		}
		$body = Convertto-json @{
			'config_spec' = $JsonProfile
		}
			
		$validateProfileAPI = Invoke-WebRequest -Uri $validateProfileAPIUrl -Method Post -Headers $headers -Body $body
		$validateProfileJson = $validateProfileAPI.Content
		$validateProfileJson
	}
	$textboxImportValidate.Text = Validate-vCenterAPIProfile -vCenter $textboxTargetvCenter.Text -session $targetsession -JsonProfile $jsonFile
	$toolstripstatuslabel1Status.Text = 'Status: Validated profile on Target vCenter Server'
}
	
$Form_StateCorrection_Load=
{
	$formVMwareVCenterProfile.WindowState = $InitialFormWindowState
}
	
$Form_Cleanup_FormClosed=
{
	try
	{
		$buttonTargetLogin.remove_Click($buttonTargetLogin_Click)
		$buttonValidateJSONConfigra.remove_Click($buttonValidateJSONConfigra_Click)
		$buttonImportJSONConfigurat.remove_Click($buttonImportJSONConfigurat_Click)
		$buttonLoadJSON.remove_Click($buttonLoadJSON_Click)
		$buttonExport.remove_Click($buttonExport_Click)
		$buttonListProfiles.remove_Click($buttonListProfiles_Click)
		$buttonSourceLogin.remove_Click($buttonSourceLogin_Click)
		$formVMwareVCenterProfile.remove_Load($formVMwareVCenterProfile_Load)
		$formVMwareVCenterProfile.remove_Load($Form_StateCorrection_Load)
		$formVMwareVCenterProfile.remove_FormClosed($Form_Cleanup_FormClosed)
	}
	catch { Out-Null}
}
$formVMwareVCenterProfile.SuspendLayout()
$groupbox4.SuspendLayout()
$groupbox2.SuspendLayout()
$groupbox1vCenterProfileConfiguration.SuspendLayout()
$statusstrip1.SuspendLayout()

$formVMwareVCenterProfile.Controls.Add($buttonTargetLogin)
$formVMwareVCenterProfile.Controls.Add($maskedtextboxTargetPassword)
$formVMwareVCenterProfile.Controls.Add($label2)
$formVMwareVCenterProfile.Controls.Add($label3)
$formVMwareVCenterProfile.Controls.Add($textboxTargetUserName)
$formVMwareVCenterProfile.Controls.Add($textboxTargetvCenter)
$formVMwareVCenterProfile.Controls.Add($label1)
$formVMwareVCenterProfile.Controls.Add($maskedtextboxSourcePassword)
$formVMwareVCenterProfile.Controls.Add($labelPassword)
$formVMwareVCenterProfile.Controls.Add($labelUserName)
$formVMwareVCenterProfile.Controls.Add($textboxSourceUserName)
$formVMwareVCenterProfile.Controls.Add($groupbox4)
$formVMwareVCenterProfile.Controls.Add($groupbox2)
$formVMwareVCenterProfile.Controls.Add($groupbox1vCenterProfileConfiguration)
$formVMwareVCenterProfile.Controls.Add($statusstrip1)
$formVMwareVCenterProfile.Controls.Add($buttonSourceLogin)
$formVMwareVCenterProfile.Controls.Add($labelSourceVCenter)
$formVMwareVCenterProfile.Controls.Add($textboxSourcevCenter)
$formVMwareVCenterProfile.AutoScaleDimensions = '8, 17'
$formVMwareVCenterProfile.AutoScaleMode = 'Font'
$formVMwareVCenterProfile.ClientSize = '645, 708'
$formVMwareVCenterProfile.Name = 'formVMwareVCenterProfile'
$formVMwareVCenterProfile.Text = 'VMware vCenter Profiles             http://vcloud-lab.com'
$formVMwareVCenterProfile.add_Load($formVMwareVCenterProfile_Load)

$buttonTargetLogin.Location = '533, 400'
$buttonTargetLogin.Margin = '4, 4, 4, 4'
$buttonTargetLogin.Name = 'buttonTargetLogin'
$buttonTargetLogin.Size = '97, 26'
$buttonTargetLogin.TabIndex = 19
$buttonTargetLogin.Text = 'Login'
$buttonTargetLogin.UseCompatibleTextRendering = $True
$buttonTargetLogin.UseVisualStyleBackColor = $True
$buttonTargetLogin.add_Click($buttonTargetLogin_Click)

$maskedtextboxTargetPassword.Location = '128, 405'
$maskedtextboxTargetPassword.Margin = '4, 4, 4, 4'
$maskedtextboxTargetPassword.Name = 'maskedtextboxTargetPassword'
$maskedtextboxTargetPassword.Size = '286, 23'
$maskedtextboxTargetPassword.TabIndex = 18
$maskedtextboxTargetPassword.UseSystemPasswordChar = $True

$label2.AutoSize = $True
$label2.Location = '13, 405'
$label2.Margin = '4, 0, 4, 0'
$label2.Name = 'label2'
$label2.Size = '71, 21'
$label2.TabIndex = 17
$label2.Text = 'Password:'
$label2.UseCompatibleTextRendering = $True

$label3.AutoSize = $True
$label3.Location = '13, 376'
$label3.Margin = '4, 0, 4, 0'
$label3.Name = 'label3'
$label3.Size = '77, 21'
$label3.TabIndex = 16
$label3.Text = 'UserName:'
$label3.UseCompatibleTextRendering = $True

$textboxTargetUserName.Location = '128, 374'
$textboxTargetUserName.Margin = '4, 4, 4, 4'
$textboxTargetUserName.Name = 'textboxTargetUserName'
$textboxTargetUserName.Size = '286, 23'
$textboxTargetUserName.TabIndex = 15
$textboxTargetUserName.Text = 'administrator@vsphere.local'

$textboxTargetvCenter.Location = '130, 342'
$textboxTargetvCenter.Margin = '4, 4, 4, 4'
$textboxTargetvCenter.Name = 'textboxTargetvCenter'
$textboxTargetvCenter.Size = '502, 23'
$textboxTargetvCenter.TabIndex = 14
$textboxTargetvCenter.Text = 'Target FQDN or IP'

$label1.AutoSize = $True
$label1.Location = '13, 345'
$label1.Margin = '4, 0, 4, 0'
$label1.Name = 'label1'
$label1.Size = '103, 21'
$label1.TabIndex = 13
$label1.Text = 'Target vCenter:'
$label1.UseCompatibleTextRendering = $True

$maskedtextboxSourcePassword.Location = '128, 80'
$maskedtextboxSourcePassword.Margin = '4, 4, 4, 4'
$maskedtextboxSourcePassword.Name = 'maskedtextboxSourcePassword'
$maskedtextboxSourcePassword.Size = '286, 23'
$maskedtextboxSourcePassword.TabIndex = 12
$maskedtextboxSourcePassword.UseSystemPasswordChar = $True

$labelPassword.AutoSize = $True
$labelPassword.Location = '13, 81'
$labelPassword.Margin = '4, 0, 4, 0'
$labelPassword.Name = 'labelPassword'
$labelPassword.Size = '71, 21'
$labelPassword.TabIndex = 10
$labelPassword.Text = 'Password:'
$labelPassword.UseCompatibleTextRendering = $True

$labelUserName.AutoSize = $True
$labelUserName.Location = '13, 49'
$labelUserName.Margin = '4, 0, 4, 0'
$labelUserName.Name = 'labelUserName'
$labelUserName.Size = '77, 21'
$labelUserName.TabIndex = 9
$labelUserName.Text = 'UserName:'
$labelUserName.UseCompatibleTextRendering = $True

$textboxSourceUserName.Location = '128, 47'
$textboxSourceUserName.Margin = '4, 4, 4, 4'
$textboxSourceUserName.Name = 'textboxSourceUserName'
$textboxSourceUserName.Size = '286, 23'
$textboxSourceUserName.TabIndex = 8
$textboxSourceUserName.Text = 'administrator@vsphere.local'

$groupbox4.Controls.Add($textboxImportValidate)
$groupbox4.Controls.Add($buttonValidateJSONConfigra)
$groupbox4.Controls.Add($buttonImportJSONConfigurat)
$groupbox4.Controls.Add($buttonLoadJSON)
$groupbox4.Controls.Add($labelJsonProfilePath)
$groupbox4.Controls.Add($textboxLoadJSONPath)
$groupbox4.Location = '13, 436'
$groupbox4.Margin = '4, 4, 4, 4'
$groupbox4.Name = 'groupbox4'
$groupbox4.Padding = '4, 4, 4, 4'
$groupbox4.Size = '617, 226'
$groupbox4.TabIndex = 7
$groupbox4.TabStop = $False
$groupbox4.Text = 'Import and Validate vCenter profile configuration'
$groupbox4.UseCompatibleTextRendering = $True

$textboxImportValidate.Location = '8, 93'
$textboxImportValidate.Margin = '4, 4, 4, 4'
$textboxImportValidate.Multiline = $True
$textboxImportValidate.Name = 'textboxImportValidate'
$textboxImportValidate.ReadOnly = $True
$textboxImportValidate.Size = '601, 112'
$textboxImportValidate.TabIndex = 8

$buttonValidateJSONConfigra.Enabled = $False
$buttonValidateJSONConfigra.Location = '300, 55'
$buttonValidateJSONConfigra.Margin = '4, 4, 4, 4'
$buttonValidateJSONConfigra.Name = 'buttonValidateJSONConfigra'
$buttonValidateJSONConfigra.Size = '231, 30'
$buttonValidateJSONConfigra.TabIndex = 7
$buttonValidateJSONConfigra.Text = 'Validate JSON Configration'
$buttonValidateJSONConfigra.UseCompatibleTextRendering = $True
$buttonValidateJSONConfigra.UseVisualStyleBackColor = $True
$buttonValidateJSONConfigra.add_Click($buttonValidateJSONConfigra_Click)

$buttonImportJSONConfigurat.Enabled = $False
$buttonImportJSONConfigurat.Location = '65, 55'
$buttonImportJSONConfigurat.Margin = '4, 4, 4, 4'
$buttonImportJSONConfigurat.Name = 'buttonImportJSONConfigurat'
$buttonImportJSONConfigurat.Size = '227, 30'
$buttonImportJSONConfigurat.TabIndex = 6
$buttonImportJSONConfigurat.Text = 'Import JSON configuration'
$buttonImportJSONConfigurat.UseCompatibleTextRendering = $True
$buttonImportJSONConfigurat.UseVisualStyleBackColor = $True
$buttonImportJSONConfigurat.add_Click($buttonImportJSONConfigurat_Click)

$buttonLoadJSON.Location = '482, 24'
$buttonLoadJSON.Margin = '4, 4, 4, 4'
$buttonLoadJSON.Name = 'buttonLoadJSON'
$buttonLoadJSON.Size = '127, 26'
$buttonLoadJSON.TabIndex = 2
$buttonLoadJSON.Text = 'Load JSON'
$buttonLoadJSON.UseCompatibleTextRendering = $True
$buttonLoadJSON.UseVisualStyleBackColor = $True
$buttonLoadJSON.add_Click($buttonLoadJSON_Click)

$labelJsonProfilePath.AutoSize = $True
$labelJsonProfilePath.Location = '8, 24'
$labelJsonProfilePath.Margin = '4, 0, 4, 0'
$labelJsonProfilePath.Name = 'labelJsonProfilePath'
$labelJsonProfilePath.Size = '121, 21'
$labelJsonProfilePath.TabIndex = 1
$labelJsonProfilePath.Text = 'JSON profile path:'
$labelJsonProfilePath.UseCompatibleTextRendering = $True

$textboxLoadJSONPath.Location = '140, 24'
$textboxLoadJSONPath.Margin = '4, 4, 4, 4'
$textboxLoadJSONPath.Name = 'textboxLoadJSONPath'
$textboxLoadJSONPath.Size = '334, 23'
$textboxLoadJSONPath.TabIndex = 0
$textboxLoadJSONPath.Text = 'C:\testprofile.json'

$groupbox2.Controls.Add($buttonExport)
$groupbox2.Controls.Add($labelExportJSONPath)
$groupbox2.Controls.Add($textboxExportJsonPath)
$groupbox2.Location = '13, 269'
$groupbox2.Margin = '4, 4, 4, 4'
$groupbox2.Name = 'groupbox2'
$groupbox2.Padding = '4, 4, 4, 4'
$groupbox2.Size = '617, 65'
$groupbox2.TabIndex = 5
$groupbox2.TabStop = $False
$groupbox2.Text = 'Export vCenter profile configuration'
$groupbox2.UseCompatibleTextRendering = $True

$buttonExport.Enabled = $False
$buttonExport.Location = '482, 23'
$buttonExport.Margin = '4, 4, 4, 4'
$buttonExport.Name = 'buttonExport'
$buttonExport.Size = '127, 30'
$buttonExport.TabIndex = 2
$buttonExport.Text = 'Export'
$buttonExport.UseCompatibleTextRendering = $True
$buttonExport.UseVisualStyleBackColor = $True
$buttonExport.add_Click($buttonExport_Click)

$labelExportJSONPath.AutoSize = $True
$labelExportJSONPath.Location = '8, 27'
$labelExportJSONPath.Margin = '4, 0, 4, 0'
$labelExportJSONPath.Name = 'labelExportJSONPath'
$labelExportJSONPath.Size = '124, 21'
$labelExportJSONPath.TabIndex = 1
$labelExportJSONPath.Text = 'Export JSON Path:'
$labelExportJSONPath.UseCompatibleTextRendering = $True

$textboxExportJsonPath.Location = '140, 25'
$textboxExportJsonPath.Margin = '4, 4, 4, 4'
$textboxExportJsonPath.Name = 'textboxExportJsonPath'
$textboxExportJsonPath.Size = '334, 23'
$textboxExportJsonPath.TabIndex = 0
$textboxExportJsonPath.Text = 'C:\testprofile.json'

$groupbox1vCenterProfileConfiguration.Controls.Add($buttonListProfiles)
$groupbox1vCenterProfileConfiguration.Controls.Add($textboxListProfile)
$groupbox1vCenterProfileConfiguration.Location = '13, 112'
$groupbox1vCenterProfileConfiguration.Margin = '4, 4, 4, 4'
$groupbox1vCenterProfileConfiguration.Name = 'groupbox1vCenterProfileConfiguration'
$groupbox1vCenterProfileConfiguration.Padding = '4, 4, 4, 4'
$groupbox1vCenterProfileConfiguration.Size = '617, 149'
$groupbox1vCenterProfileConfiguration.TabIndex = 4
$groupbox1vCenterProfileConfiguration.TabStop = $False
$groupbox1vCenterProfileConfiguration.Text = 'List vCenter Profile Configuration'
$groupbox1vCenterProfileConfiguration.UseCompatibleTextRendering = $True

$buttonListProfiles.Enabled = $False
$buttonListProfiles.Location = '482, 32'
$buttonListProfiles.Margin = '4, 4, 4, 4'
$buttonListProfiles.Name = 'buttonListProfiles'
$buttonListProfiles.Size = '127, 28'
$buttonListProfiles.TabIndex = 1
$buttonListProfiles.Text = 'List Profiles'
$buttonListProfiles.UseCompatibleTextRendering = $True
$buttonListProfiles.UseVisualStyleBackColor = $True
$buttonListProfiles.add_Click($buttonListProfiles_Click)

$textboxListProfile.Location = '8, 68'
$textboxListProfile.Margin = '4, 4, 4, 4'
$textboxListProfile.Multiline = $True
$textboxListProfile.Name = 'textboxListProfile'
$textboxListProfile.ReadOnly = $True
$textboxListProfile.Size = '601, 73'
$textboxListProfile.TabIndex = 0

$statusstrip1.ImageScalingSize = '20, 20'
[void]$statusstrip1.Items.Add($toolstripstatuslabel1Status)
$statusstrip1.Location = '0, 683'
$statusstrip1.Name = 'statusstrip1'
$statusstrip1.Padding = '1, 0, 19, 0'
$statusstrip1.Size = '645, 25'
$statusstrip1.TabIndex = 3
$statusstrip1.Text = 'statusstrip1'

$buttonSourceLogin.Location = '535, 78'
$buttonSourceLogin.Margin = '4, 4, 4, 4'
$buttonSourceLogin.Name = 'buttonSourceLogin'
$buttonSourceLogin.Size = '97, 26'
$buttonSourceLogin.TabIndex = 2
$buttonSourceLogin.Text = 'Login'
$buttonSourceLogin.UseCompatibleTextRendering = $True
$buttonSourceLogin.UseVisualStyleBackColor = $True
$buttonSourceLogin.add_Click($buttonSourceLogin_Click)

$labelSourceVCenter.AutoSize = $True
$labelSourceVCenter.Location = '13, 16'
$labelSourceVCenter.Margin = '4, 0, 4, 0'
$labelSourceVCenter.Name = 'labelSourceVCenter'
$labelSourceVCenter.Size = '107, 21'
$labelSourceVCenter.TabIndex = 1
$labelSourceVCenter.Text = 'Source vCenter:'
$labelSourceVCenter.UseCompatibleTextRendering = $True

$textboxSourcevCenter.Location = '128, 16'
$textboxSourcevCenter.Margin = '4, 4, 4, 4'
$textboxSourcevCenter.Name = 'textboxSourcevCenter'
$textboxSourcevCenter.Size = '502, 23'
$textboxSourcevCenter.TabIndex = 0
$textboxSourcevCenter.Text = 'Source FQDN or IP'

$toolstripstatuslabel1Status.Name = 'toolstripstatuslabel1Status'
$toolstripstatuslabel1Status.Size = '231, 20'
$toolstripstatuslabel1Status.Text = 'Status: Connect to Source vCenter'

$openfiledialogLoadJSON.FileName = 'openfiledialogLoadJSON'
$statusstrip1.ResumeLayout()
$groupbox1vCenterProfileConfiguration.ResumeLayout()
$groupbox2.ResumeLayout()
$groupbox4.ResumeLayout()
$formVMwareVCenterProfile.ResumeLayout()

$InitialFormWindowState = $formVMwareVCenterProfile.WindowState
$formVMwareVCenterProfile.add_Load($Form_StateCorrection_Load)
$formVMwareVCenterProfile.add_FormClosed($Form_Cleanup_FormClosed)
$formVMwareVCenterProfile.ShowDialog()

Download this script here, It is also available on github.com.

Useful articles
VMWARE VSPHERE UPDATE MANAGER (VUM) - IMPORTING ESXI ISO AND CREATE UPGRADE BASELINE 
VMWARE VSPHERE UPDATE MANAGER (VUM) - UPGRADE ESXI OS 
ESXi 6.0 update offline bundle via esxcli commandline: DependencyError VIB bootbank requires VSAN ImageProfile
ESXi 6.5 upgrade bundle via command line: No Space Left On Device Error
Registering HPE ILO amplifier pack (Hardware support manager) with vCenter 7 Lifecycle manager
VMware LifeCycle Manager import updates bundle and patch ESXi server
How to update a patch on an ESXi host via command line
Add a Trusted Root Certificate to the Certificate Store VMware Photon OS
Patching update VMware vCenter Server Appliance from a zipped update bundle Web server
Backup VMware vCenter server using SMB protocol
VMware vCenter server backup error Path not exported by the remote filesystem

Go Back

Comment

Blog Search

Page Views

5936697

Follow me on Blogarama