Import-Module "C:\Users\Eric Sloof\Downloads\PowerShell\vitoolkitextensions-47867\coreModule\viToolkitExtensions.psm1" $Server = Connect-VIServer -Server 192.168.178.250 -User Administrator -Password vmware #Generated Form Function function GenerateForm { ######################################################################## # Code Generated By: SAPIEN Technologies PrimalForms 2009 v1.0.0.0 # Generated On: 3-4-2009 14:50 # Generated By: Eric Sloof ######################################################################## #region Import the Assembles [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null #endregion #region Generated Form Objects $form1 = New-Object System.Windows.Forms.Form $button1 = New-Object System.Windows.Forms.Button $label12 = New-Object System.Windows.Forms.Label $label11 = New-Object System.Windows.Forms.Label $label10 = New-Object System.Windows.Forms.Label $textBox3 = New-Object System.Windows.Forms.TextBox $textBox2 = New-Object System.Windows.Forms.TextBox $textBox1 = New-Object System.Windows.Forms.TextBox $label9 = New-Object System.Windows.Forms.Label $label8 = New-Object System.Windows.Forms.Label $label7 = New-Object System.Windows.Forms.Label $pictureBox9 = New-Object System.Windows.Forms.PictureBox $label6 = New-Object System.Windows.Forms.Label $label5 = New-Object System.Windows.Forms.Label $label4 = New-Object System.Windows.Forms.Label $label3 = New-Object System.Windows.Forms.Label $label2 = New-Object System.Windows.Forms.Label $label1 = New-Object System.Windows.Forms.Label $pictureBox8 = New-Object System.Windows.Forms.PictureBox $pictureBox7 = New-Object System.Windows.Forms.PictureBox $pictureBox6 = New-Object System.Windows.Forms.PictureBox $pictureBox5 = New-Object System.Windows.Forms.PictureBox $pictureBox4 = New-Object System.Windows.Forms.PictureBox $pictureBox3 = New-Object System.Windows.Forms.PictureBox $pictureBox2 = New-Object System.Windows.Forms.PictureBox $pictureBox1 = New-Object System.Windows.Forms.PictureBox #endregion Generated Form Objects #---------------------------------------------- #Generated Event Script Blocks #---------------------------------------------- #Provide Custom Code for events specified in PrimalForms. $button1_OnClick= { #TODO: Place custom script here $vm = Get-VM -Name "DC.NTPRO.LOCAL" $label1.Text = $vm.name $vmView = $vm | Get-View $vmView.CreateScreenshot_Task() $vmxPath = $vmView.Config.Files.VmPathName $pngPath = $vmxPath.Replace(".vmx", "-screenshot-0.png") Copy-TkeDatastoreFile -source $pngPath -sourceServer $Server -sourceDatacenter (get-datacenter -server $server) -destination "C:\Users\Eric Sloof\Documents\vm1.png" ($pictureBox1).ImageLocation = "C:\Users\Eric Sloof\Documents\vm1.png" $vm = Get-VM -Name "Connection" $label2.Text = $vm.name $vmView = $vm | Get-View $vmView.CreateScreenshot_Task() $vmxPath = $vmView.Config.Files.VmPathName $pngPath = $vmxPath.Replace(".vmx", "-screenshot-0.png") Copy-TkeDatastoreFile -source $pngPath -sourceServer $Server -sourceDatacenter (get-datacenter -server $server) -destination "C:\Users\Eric Sloof\Documents\vm2.png" ($pictureBox2).ImageLocation = "C:\Users\Eric Sloof\Documents\vm2.png" $vm = Get-VM -Name "VDM" $label3.Text = $vm.name $vmView = $vm | Get-View $vmView.CreateScreenshot_Task() $vmxPath = $vmView.Config.Files.VmPathName $pngPath = $vmxPath.Replace(".vmx", "-screenshot-0.png") Copy-TkeDatastoreFile -source $pngPath -sourceServer $Server -sourceDatacenter (get-datacenter -server $server) -destination "C:\Users\Eric Sloof\Documents\vm3.png" ($pictureBox3).ImageLocation = "C:\Users\Eric Sloof\Documents\vm3.png" $vm = Get-VM -Name "ESX4" $label4.Text = $vm.name $vmView = $vm | Get-View $vmView.CreateScreenshot_Task() $vmxPath = $vmView.Config.Files.VmPathName $pngPath = $vmxPath.Replace(".vmx", "-screenshot-0.png") Copy-TkeDatastoreFile -source $pngPath -sourceServer $Server -sourceDatacenter (get-datacenter -server $server) -destination "C:\Users\Eric Sloof\Documents\vm4.png" ($pictureBox4).ImageLocation = "C:\Users\Eric Sloof\Documents\vm4.png" $vm = Get-VM -Name "Router" $label5.Text = $vm.name $vmView = $vm | Get-View $vmView.CreateScreenshot_Task() $vmxPath = $vmView.Config.Files.VmPathName $pngPath = $vmxPath.Replace(".vmx", "-screenshot-0.png") Copy-TkeDatastoreFile -source $pngPath -sourceServer $Server -sourceDatacenter (get-datacenter -server $server) -destination "C:\Users\Eric Sloof\Documents\vm5.png" ($pictureBox5).ImageLocation = "C:\Users\Eric Sloof\Documents\vm5.png" $vm = Get-VM -Name "winxpvc2" $label6.Text = $vm.name $vmView = $vm | Get-View $vmView.CreateScreenshot_Task() $vmxPath = $vmView.Config.Files.VmPathName $pngPath = $vmxPath.Replace(".vmx", "-screenshot-0.png") Copy-TkeDatastoreFile -source $pngPath -sourceServer $Server -sourceDatacenter (get-datacenter -server $server) -destination "C:\Users\Eric Sloof\Documents\vm6.png" ($pictureBox6).ImageLocation = "C:\Users\Eric Sloof\Documents\vm6.png" $vm = Get-VM -Name "ESX3" $label7.Text = $vm.name $vmView = $vm | Get-View $vmView.CreateScreenshot_Task() $vmxPath = $vmView.Config.Files.VmPathName $pngPath = $vmxPath.Replace(".vmx", "-screenshot-0.png") Copy-TkeDatastoreFile -source $pngPath -sourceServer $Server -sourceDatacenter (get-datacenter -server $server) -destination "C:\Users\Eric Sloof\Documents\vm7.png" ($pictureBox7).ImageLocation = "C:\Users\Eric Sloof\Documents\vm7.png" $vm = Get-VM -Name "iback-up" $label8.Text = $vm.name $vmView = $vm | Get-View $vmView.CreateScreenshot_Task() $vmxPath = $vmView.Config.Files.VmPathName $pngPath = $vmxPath.Replace(".vmx", "-screenshot-0.png") Copy-TkeDatastoreFile -source $pngPath -sourceServer $Server -sourceDatacenter (get-datacenter -server $server) -destination "C:\Users\Eric Sloof\Documents\vm8.png" ($pictureBox8).ImageLocation = "C:\Users\Eric Sloof\Documents\vm8.png" $vm = Get-VM -Name "XP Client" $label9.Text = $vm.name $vmView = $vm | Get-View $vmView.CreateScreenshot_Task() $vmxPath = $vmView.Config.Files.VmPathName $pngPath = $vmxPath.Replace(".vmx", "-screenshot-0.png") Copy-TkeDatastoreFile -source $pngPath -sourceServer $Server -sourceDatacenter (get-datacenter -server $server) -destination "C:\Users\Eric Sloof\Documents\vm9.png" ($pictureBox9).ImageLocation = "C:\Users\Eric Sloof\Documents\vm9.png" } $handler_label10_Click= { #TODO: Place custom script here } #---------------------------------------------- #region Generated Form Code $form1.Text = 'NTPRO.NL VM BigBrother' $form1.Name = 'form1' $form1.DataBindings.DefaultDataSourceUpdateMode = 0 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 631 $System_Drawing_Size.Height = 589 $form1.ClientSize = $System_Drawing_Size $button1.TabIndex = 25 $button1.Name = 'button1' $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 25 $button1.Size = $System_Drawing_Size $button1.UseVisualStyleBackColor = $True $button1.Text = 'Get ScreenShot' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 214 $System_Drawing_Point.Y = 560 $button1.Location = $System_Drawing_Point $button1.DataBindings.DefaultDataSourceUpdateMode = 0 $button1.add_Click($button1_OnClick) $form1.Controls.Add($button1) $label12.TabIndex = 24 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 54 $System_Drawing_Size.Height = 19 $label12.Size = $System_Drawing_Size $label12.Text = 'Password' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 415 $System_Drawing_Point.Y = 536 $label12.Location = $System_Drawing_Point $label12.DataBindings.DefaultDataSourceUpdateMode = 0 $label12.Name = 'label12' $form1.Controls.Add($label12) $label11.TabIndex = 23 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 43 $System_Drawing_Size.Height = 20 $label11.Size = $System_Drawing_Size $label11.Text = 'User' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 213 $System_Drawing_Point.Y = 537 $label11.Location = $System_Drawing_Point $label11.DataBindings.DefaultDataSourceUpdateMode = 0 $label11.Name = 'label11' $form1.Controls.Add($label11) $label10.TabIndex = 22 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 63 $System_Drawing_Size.Height = 19 $label10.Size = $System_Drawing_Size $label10.Text = 'vCenter' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 10 $System_Drawing_Point.Y = 537 $label10.Location = $System_Drawing_Point $label10.DataBindings.DefaultDataSourceUpdateMode = 0 $label10.Name = 'label10' $label10.add_Click($handler_label10_Click) $form1.Controls.Add($label10) $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 145 $System_Drawing_Size.Height = 20 $textBox3.Size = $System_Drawing_Size $textBox3.DataBindings.DefaultDataSourceUpdateMode = 0 $textBox3.Name = 'textBox3' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 470 $System_Drawing_Point.Y = 534 $textBox3.Location = $System_Drawing_Point $textBox3.TabIndex = 21 $form1.Controls.Add($textBox3) $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 173 $System_Drawing_Size.Height = 20 $textBox2.Size = $System_Drawing_Size $textBox2.DataBindings.DefaultDataSourceUpdateMode = 0 $textBox2.Name = 'textBox2' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 241 $System_Drawing_Point.Y = 534 $textBox2.Location = $System_Drawing_Point $textBox2.TabIndex = 20 $form1.Controls.Add($textBox2) $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 157 $System_Drawing_Size.Height = 20 $textBox1.Size = $System_Drawing_Size $textBox1.DataBindings.DefaultDataSourceUpdateMode = 0 $textBox1.Name = 'textBox1' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 52 $System_Drawing_Point.Y = 533 $textBox1.Location = $System_Drawing_Point $textBox1.TabIndex = 19 $form1.Controls.Add($textBox1) $label9.TabIndex = 18 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 18 $label9.Size = $System_Drawing_Size $label9.Text = 'Virtual Machine 9' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 415 $System_Drawing_Point.Y = 516 $label9.Location = $System_Drawing_Point $label9.DataBindings.DefaultDataSourceUpdateMode = 0 $label9.Name = 'label9' $form1.Controls.Add($label9) $label8.TabIndex = 17 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 184 $System_Drawing_Size.Height = 16 $label8.Size = $System_Drawing_Size $label8.Text = 'Virtual Machine 8' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 213 $System_Drawing_Point.Y = 516 $label8.Location = $System_Drawing_Point $label8.DataBindings.DefaultDataSourceUpdateMode = 0 $label8.Name = 'label8' $form1.Controls.Add($label8) $label7.TabIndex = 16 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 18 $label7.Size = $System_Drawing_Size $label7.Text = 'Virtual Machine 7' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 516 $label7.Location = $System_Drawing_Point $label7.DataBindings.DefaultDataSourceUpdateMode = 0 $label7.Name = 'label7' $form1.Controls.Add($label7) $pictureBox9.TabIndex = 15 $pictureBox9.SizeMode = 4 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 150 $pictureBox9.Size = $System_Drawing_Size $pictureBox9.BorderStyle = 2 $pictureBox9.SizeMode = "Zoom" $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 414 $System_Drawing_Point.Y = 363 $pictureBox9.Location = $System_Drawing_Point $pictureBox9.TabStop = $False $pictureBox9.Name = 'pictureBox9' $pictureBox9.DataBindings.DefaultDataSourceUpdateMode = 0 $form1.Controls.Add($pictureBox9) $label6.TabIndex = 14 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 197 $System_Drawing_Size.Height = 19 $label6.Size = $System_Drawing_Size $label6.Text = 'Virtual Machine 6' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 419 $System_Drawing_Point.Y = 341 $label6.Location = $System_Drawing_Point $label6.DataBindings.DefaultDataSourceUpdateMode = 0 $label6.Name = 'label6' $form1.Controls.Add($label6) $label5.TabIndex = 13 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 207 $System_Drawing_Size.Height = 19 $label5.Size = $System_Drawing_Size $label5.Text = 'Virtual Machine 5' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 214 $System_Drawing_Point.Y = 341 $label5.Location = $System_Drawing_Point $label5.DataBindings.DefaultDataSourceUpdateMode = 0 $label5.Name = 'label5' $form1.Controls.Add($label5) $label4.TabIndex = 12 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 19 $label4.Size = $System_Drawing_Size $label4.Text = 'Virtual Machine 4' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 341 $label4.Location = $System_Drawing_Point $label4.DataBindings.DefaultDataSourceUpdateMode = 0 $label4.Name = 'label4' $form1.Controls.Add($label4) $label3.TabIndex = 11 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 196 $System_Drawing_Size.Height = 19 $label3.Size = $System_Drawing_Size $label3.Text = 'Virtual Machine 3' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 420 $System_Drawing_Point.Y = 165 $label3.Location = $System_Drawing_Point $label3.DataBindings.DefaultDataSourceUpdateMode = 0 $label3.Name = 'label3' $form1.Controls.Add($label3) $label2.TabIndex = 10 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 190 $System_Drawing_Size.Height = 20 $label2.Size = $System_Drawing_Size $label2.Text = 'Virtual Machine 2' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 214 $System_Drawing_Point.Y = 165 $label2.Location = $System_Drawing_Point $label2.DataBindings.DefaultDataSourceUpdateMode = 0 $label2.Name = 'label2' $form1.Controls.Add($label2) $label1.TabIndex = 9 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 20 $label1.Size = $System_Drawing_Size $label1.Text = 'Virtual Machine 1' $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 165 $label1.Location = $System_Drawing_Point $label1.DataBindings.DefaultDataSourceUpdateMode = 0 $label1.Name = 'label1' $form1.Controls.Add($label1) $pictureBox8.TabIndex = 8 $pictureBox8.SizeMode = 4 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 150 $pictureBox8.Size = $System_Drawing_Size $pictureBox8.BorderStyle = 2 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 213 $System_Drawing_Point.Y = 363 $pictureBox8.Location = $System_Drawing_Point $pictureBox8.TabStop = $False $pictureBox8.Name = 'pictureBox8' $pictureBox8.DataBindings.DefaultDataSourceUpdateMode = 0 $pictureBox8.BackgroundImageLayout = 4 $pictureBox8.SizeMode = "Zoom" $form1.Controls.Add($pictureBox8) $pictureBox7.TabIndex = 6 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 150 $pictureBox7.Size = $System_Drawing_Size $pictureBox7.BorderStyle = 2 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 363 $pictureBox7.Location = $System_Drawing_Point $pictureBox7.TabStop = $False $pictureBox7.Name = 'pictureBox7' $pictureBox7.DataBindings.DefaultDataSourceUpdateMode = 0 $pictureBox7.BackgroundImageLayout = 4 $pictureBox7.SizeMode = "Zoom" $form1.Controls.Add($pictureBox7) $pictureBox6.TabIndex = 5 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 150 $pictureBox6.Size = $System_Drawing_Size $pictureBox6.BorderStyle = 2 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 414 $System_Drawing_Point.Y = 188 $pictureBox6.Location = $System_Drawing_Point $pictureBox6.TabStop = $False $pictureBox6.Name = 'pictureBox6' $pictureBox6.DataBindings.DefaultDataSourceUpdateMode = 0 $pictureBox6.BackgroundImageLayout = 4 $pictureBox6.SizeMode = "Zoom" $form1.Controls.Add($pictureBox6) $pictureBox5.TabIndex = 4 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 150 $pictureBox5.Size = $System_Drawing_Size $pictureBox5.BorderStyle = 2 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 213 $System_Drawing_Point.Y = 188 $pictureBox5.Location = $System_Drawing_Point $pictureBox5.TabStop = $False $pictureBox5.Name = 'pictureBox5' $pictureBox5.DataBindings.DefaultDataSourceUpdateMode = 0 $pictureBox5.BackgroundImageLayout = 4 $pictureBox5.SizeMode = "Zoom" $form1.Controls.Add($pictureBox5) $pictureBox4.TabIndex = 3 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 150 $pictureBox4.Size = $System_Drawing_Size $pictureBox4.BorderStyle = 2 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 188 $pictureBox4.Location = $System_Drawing_Point $pictureBox4.TabStop = $False $pictureBox4.Name = 'pictureBox4' $pictureBox4.DataBindings.DefaultDataSourceUpdateMode = 0 $pictureBox4.BackgroundImageLayout = 4 $pictureBox4.SizeMode = "Zoom" $form1.Controls.Add($pictureBox4) $pictureBox3.TabIndex = 2 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 150 $pictureBox3.Size = $System_Drawing_Size $pictureBox3.BorderStyle = 2 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 414 $System_Drawing_Point.Y = 12 $pictureBox3.Location = $System_Drawing_Point $pictureBox3.TabStop = $False $pictureBox3.Name = 'pictureBox3' $pictureBox3.DataBindings.DefaultDataSourceUpdateMode = 0 $pictureBox3.BackgroundImageLayout = 4 $pictureBox3.SizeMode = "Zoom" $form1.Controls.Add($pictureBox3) $pictureBox2.TabIndex = 1 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 150 $pictureBox2.Size = $System_Drawing_Size $pictureBox2.BorderStyle = 2 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 213 $System_Drawing_Point.Y = 12 $pictureBox2.Location = $System_Drawing_Point $pictureBox2.TabStop = $False $pictureBox2.Name = 'pictureBox2' $pictureBox2.DataBindings.DefaultDataSourceUpdateMode = 0 $pictureBox2.BackgroundImageLayout = 4 $pictureBox2.SizeMode = "Zoom" $form1.Controls.Add($pictureBox2) $pictureBox1.TabIndex = 0 $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 200 $System_Drawing_Size.Height = 150 $pictureBox1.Size = $System_Drawing_Size $pictureBox1.BorderStyle = 2 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 12 $System_Drawing_Point.Y = 12 $pictureBox1.Location = $System_Drawing_Point $pictureBox1.TabStop = $False $pictureBox1.Name = 'pictureBox1' $pictureBox1.DataBindings.DefaultDataSourceUpdateMode = 0 $pictureBox1.BackgroundImageLayout = 4 $pictureBox1.SizeMode = "Zoom" $form1.Controls.Add($pictureBox1) #endregion Generated Form Code #Show the Form $form1.ShowDialog()| Out-Null } #End Function #Call the Function GenerateForm