Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GenerateForm {
- #region Helper functions
- function Update-EventList {
- $tgtSearch = ""
- if($SearchText.Text){
- $tgtSearch = $SearchText.Text
- }
- $EventList.BeginUpdate()
- $EventList.Items.Clear()
- $script:eventTab.GetEnumerator()| Sort-Object -Property Key |
- where {$_.Key -match $tgtSearch -or $_.Value.FullFormat -match $tgtSearch} | %{
- if($EventDescriptionRadio.Checked){
- $EventList.Items.Add($_.Value.Description)
- }
- else {
- $EventList.Items.Add($_.Key)}
- }
- $EventList.EndUpdate()
- }
- #endregion
- ########################################################################
- # Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.8.0
- # Generated On: 7/14/2013 3:52 PM
- # Generated By: Luc Dekens
- ########################################################################
- #region Import the Assemblies
- [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
- [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
- #endregion
- #region Generated Form Objects
- $EventOMaticForm = New-Object System.Windows.Forms.Form
- $EventDescriptionRadio = New-Object System.Windows.Forms.RadioButton
- $vSphereServer = New-Object System.Windows.Forms.ComboBox
- $EventNameRadio = New-Object System.Windows.Forms.RadioButton
- $vsphereinfo = New-Object System.Windows.Forms.Label
- $EventSelectedNumber = New-Object System.Windows.Forms.Label
- $groupBox1 = New-Object System.Windows.Forms.GroupBox
- $EventNumber = New-Object System.Windows.Forms.Label
- $Search = New-Object System.Windows.Forms.Button
- $SearchText = New-Object System.Windows.Forms.TextBox
- $EventClear = New-Object System.Windows.Forms.Button
- $FinishButton = New-Object System.Windows.Forms.Button
- $EventPlusRadio = New-Object System.Windows.Forms.CheckBox
- $GenerateCodeButton = New-Object System.Windows.Forms.Button
- $SelectedEventList = New-Object System.Windows.Forms.ListBox
- $label4 = New-Object System.Windows.Forms.Label
- $EventList = New-Object System.Windows.Forms.ListBox
- $label2 = New-Object System.Windows.Forms.Label
- $ConnectButton = New-Object System.Windows.Forms.Button
- $label1 = New-Object System.Windows.Forms.Label
- $EventToolTip = New-Object System.Windows.Forms.ToolTip
- $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
- #endregion
- #region Generated Event Script Blocks
- #----------------------------------------------
- #Generated Event Script Blocks
- #----------------------------------------------
- $FinishClicked = {
- $EventOMaticForm.Close()
- }
- $SearchTextFocusOn = {
- $EventOMaticForm.AcceptButton = $Search
- }
- $SearchTextFocusOff = {
- $EventOMaticForm.AcceptButton = $FinishButton
- }
- $EventMouseMove = {
- param(
- $obj,
- [System.Windows.Forms.MouseEventArgs]$mEventArgs
- )
- $listIndex = $obj.IndexFromPoint($mEventArgs.Location)
- if($listIndex -ge 0 -and $listIndex -lt $obj.Items.Count){
- if($EventToolTip.GetToolTip($obj) -ne $script:eventTab[$obj.Items[$listIndex]].FullFormat){
- $EventToolTip.SetToolTip($obj,$script:eventTab[$obj.Items[$listIndex]].FullFormat)
- }
- }
- else{
- $EventToolTip.Hide($obj)
- }
- }
- $EventRadioChanged = {
- Update-EventList
- }
- $EventClicked = {
- param(
- $obj,
- [System.Windows.Forms.MouseEventArgs]$mEventArgs
- )
- $obj.BeginUpdate()
- if($obj -eq $EventList){
- if($EventDescriptionRadio.Checked){
- $selectedEvent = $script:eventTab.GetEnumerator() | Sort-Object -Property Key |
- where {$EventList.SelectedItem -eq $_.Value.Description}
- }
- else {
- $selectedEvent = $script:eventTab.GetEnumerator() | Sort-Object -Property Key |
- where {$EventList.SelectedItem -eq $_.Key}
- }
- if(!$SelectedEventList.Items.Contains($selectedEvent.Key)){
- $SelectedEventList.Items.Add($selectedEvent.Key)
- }
- }
- else{
- $SelectedEventList.Items.Remove($SelectedEventList.SelectedItem)
- }
- $obj.EndUpdate()
- $EventSelectedNumber.Text = "$($SelectedEventList.Items.Count)"
- # }
- }
- $SearchClicked = {
- $EventList.BeginUpdate()
- $EventList.Items.Clear()
- $script:eventTab.GetEnumerator()|
- where {$_.Key -match $SearchText.Text -or $_.Value.FullFormat -match $SearchText.Text} | %{
- if($EventDescriptionRadio.Checked){
- $EventList.Items.Add($script:eventTab[$_.Key].FullFormat)
- }
- else {
- $EventList.Items.Add($_.Key)
- }
- }
- $EventList.EndUpdate()
- $EventNumber.Text = "$($EventList.Items.Count)"
- }
- $SearchTextChanged = {
- if(!$SearchText.Text){
- $EventList.BeginUpdate()
- $EventList.Items.Clear()
- if($EventDescriptionRadio.Checked){
- $script:eventTab.Keys | %{
- $EventList.Items.Add($script:eventTab[$_].FullFormat)
- }
- }
- else {
- $script:eventTab.Keys | %{$EventList.Items.Add($_)}
- }
- $EventList.EndUpdate()
- $EventNumber.Text = "$($EventList.Items.Count)"
- }
- }
- $EventClearClicked = {
- $SelectedEventList.BeginUpdate()
- $SelectedEventList.Items.Clear()
- $SelectedEventList.EndUpdate()
- $EventSelectedNumber.Text = ""
- }
- $FormInit = {
- $vSphereServer.Items.Clear()
- if($script:vServers){
- $vSphereServer.Items.AddRange($script:vServers)
- }
- if($global:DefaultVIServer){
- if($script:vServers -notcontains $global:DefaultVIServer.Name) {
- $script:vServers += $global:DefaultVIServer.Name
- }
- $vSphereServer.Text = $global:DefaultVIServer.Name
- $script:eventTab = [ordered]@{}
- $vsphereinfo.Text = $global:DefaultVIServer.ExtensionData.Content.About.FullName
- $si = Get-View ServiceInstance -Server $global:DefaultVIServer
- $eventMgr = Get-View $si.Content.EventManager -Server $global:DefaultVIServer
- $eventMgr.Description.EventInfo | %{
- if('ExtendedEvent','EventEx' -contains $_.Key){
- $tabKey = $_.FullFormat.Split('|')[0]
- }
- else{
- $tabKey = $_.Key
- }
- if(!$tabKey -eq ""){
- $script:eventTab.Add($tabKey,$_)
- }
- }
- Update-EventList
- $EventNumber.Text = "$($EventList.Items.Count)"
- }
- else{
- $vsphereinfo.Text = "<No vSphere Server connected>"
- }
- }
- $vSphereServerFocusOn = {
- $EventOMaticForm.AcceptButton = $ConnectButton
- }
- $vSphereServerFocusOff = {
- $EventOMaticForm.AcceptButton = $FinishButton
- }
- $ConnectClicked = {
- $sessionID = $global:defaultviservers | where {$_.Name -eq $vSphereServer.Text} |
- Select -First 1 -ExpandProperty SessionId
- if($sessionId){
- Connect-VIServer -Server $vSphereServer.Text -Session $sessionId
- }
- else{
- Connect-VIServer -Server $vSphereServer.Text
- }
- $vSphereServer.Text = $global:DefaultVIServer.Name
- $vsphereinfo.text = $global:DefaultVIServer.ExtensionData.Content.About.FullName
- if($script:vServers -notcontains $vSphereServer.Text){
- $script:vServers += $vSphereServer.Text
- }
- & $FormInit
- }
- $GenerateCodeClicked = {
- if($SelectedEventList.Items.Count -ne 0){
- $events = $SelectedEventList.Items[0..($SelectedEventList.Items.Count - 1)]
- if($EventPlusRadio.Checked){
- $code = "Get-VIEventPlus -EventType "
- $code += ('"' + [string]::Join('","',$events) + '"')
- }
- else{
- $code = "Get-VIEvent -MaxSamples ([int]::MaxValue) | Where-Object {"
- $expressions = @()
- $SelectedEventList.Items[0..($SelectedEventList.Items.Count - 1)] | %{
- $event =$script:eventTab[$_]
- if($event.Key -eq "ExtendedEvent"){
- $expressions += ('($_ -is [VMware.Vim.ExtendedEvent] -and $_.FullFormat -match "^' + $_ + '")')
- }
- elseif($event.Key -eq "EventEx"){
- $expressions += ('($_ -is [VMware.Vim.EventEx] -and $_.FullFormat -match "^' + $_ + '")')
- }
- else{
- $expressions += ('$_ -is [VMware.Vim.' + $_ + ']')
- }
- }
- $code += [string]::Join(' -or ',$expressions)
- $code += '}'
- }
- [Windows.Forms.Clipboard]::SetText($code)
- }
- }
- $OnLoadForm_StateCorrection = {
- #Correct the initial state of the form to prevent the .Net maximized form issue
- $EventOMaticForm.WindowState = $InitialFormWindowState
- }
- #endregion
- #region Generated Form Code
- $EventOMaticForm.BackgroundImageLayout = 0
- $EventOMaticForm.CancelButton = $FinishButton
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 18
- $System_Drawing_Point.Y = 0
- $EventOMaticForm.Location = $System_Drawing_Point
- $EventOMaticForm.Text = "Event-O-Matic v$($eventomaticVersion)"
- $EventOMaticForm.Name = "EventOMaticForm"
- $EventOMaticForm.DataBindings.DefaultDataSourceUpdateMode = 0
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 582
- $System_Drawing_Size.Height = 357
- $EventOMaticForm.ClientSize = $System_Drawing_Size
- $EventOMaticForm.AcceptButton = $FinishButton
- $EventOMaticForm.FormBorderStyle = 3
- $EventOMaticForm.add_Load($FormInit)
- $EventDescriptionRadio.TabIndex = 7
- $EventDescriptionRadio.Name = "EventDescriptionRadio"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 97
- $System_Drawing_Size.Height = 24
- $EventDescriptionRadio.Size = $System_Drawing_Size
- $EventDescriptionRadio.UseVisualStyleBackColor = $True
- $EventDescriptionRadio.Text = "Description"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 110
- $System_Drawing_Point.Y = 279
- $EventDescriptionRadio.Location = $System_Drawing_Point
- $EventDescriptionRadio.DataBindings.DefaultDataSourceUpdateMode = 0
- $EventDescriptionRadio.add_CheckedChanged($EventRadioChanged)
- $EventOMaticForm.Controls.Add($EventDescriptionRadio)
- $vSphereServer.FormattingEnabled = $True
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 267
- $System_Drawing_Size.Height = 21
- $vSphereServer.Size = $System_Drawing_Size
- $vSphereServer.DataBindings.DefaultDataSourceUpdateMode = 0
- $vSphereServer.Name = "vSphereServer"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 110
- $System_Drawing_Point.Y = 25
- $vSphereServer.Location = $System_Drawing_Point
- $vSphereServer.TabIndex = 0
- $EventOMaticForm.Controls.Add($vSphereServer)
- $EventNameRadio.TabIndex = 6
- $EventNameRadio.Name = "EventNameRadio"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 76
- $System_Drawing_Size.Height = 24
- $EventNameRadio.Size = $System_Drawing_Size
- $EventNameRadio.UseVisualStyleBackColor = $True
- $EventNameRadio.Text = "Name"
- $EventNameRadio.Checked = $True
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 18
- $System_Drawing_Point.Y = 279
- $EventNameRadio.Location = $System_Drawing_Point
- $EventNameRadio.DataBindings.DefaultDataSourceUpdateMode = 0
- $EventNameRadio.TabStop = $True
- $EventNameRadio.add_Click($EventRadioButton)
- $EventNameRadio.add_CheckedChanged($EventRadioChanged)
- $EventOMaticForm.Controls.Add($EventNameRadio)
- $vsphereinfo.TabIndex = 0
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 267
- $System_Drawing_Size.Height = 20
- $vsphereinfo.Size = $System_Drawing_Size
- $vsphereinfo.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",7.25,0,3,1)
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 110
- $System_Drawing_Point.Y = 48
- $vsphereinfo.Location = $System_Drawing_Point
- $vsphereinfo.DataBindings.DefaultDataSourceUpdateMode = 0
- $vsphereinfo.Name = "vsphereinfo"
- $EventOMaticForm.Controls.Add($vsphereinfo)
- $EventSelectedNumber.TabIndex = 0
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 45
- $System_Drawing_Size.Height = 18
- $EventSelectedNumber.Size = $System_Drawing_Size
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 341
- $System_Drawing_Point.Y = 114
- $EventSelectedNumber.Location = $System_Drawing_Point
- $EventSelectedNumber.DataBindings.DefaultDataSourceUpdateMode = 0
- $EventSelectedNumber.Name = "EventSelectedNumber"
- $EventOMaticForm.Controls.Add($EventSelectedNumber)
- $groupBox1.TabIndex = 0
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 200
- $System_Drawing_Size.Height = 42
- $groupBox1.Size = $System_Drawing_Size
- $groupBox1.Text = "Show"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 18
- $System_Drawing_Point.Y = 262
- $groupBox1.Location = $System_Drawing_Point
- $groupBox1.DataBindings.DefaultDataSourceUpdateMode = 0
- $groupBox1.TabStop = $False
- $groupBox1.Name = "groupBox1"
- $EventOMaticForm.Controls.Add($groupBox1)
- $EventNumber.TabIndex = 0
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 40
- $System_Drawing_Size.Height = 18
- $EventNumber.Size = $System_Drawing_Size
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 74
- $System_Drawing_Point.Y = 114
- $EventNumber.Location = $System_Drawing_Point
- $EventNumber.DataBindings.DefaultDataSourceUpdateMode = 0
- $EventNumber.Name = "EventNumber"
- $EventOMaticForm.Controls.Add($EventNumber)
- $Search.TabIndex = 3
- $Search.Name = "Search"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 75
- $System_Drawing_Size.Height = 23
- $Search.Size = $System_Drawing_Size
- $Search.UseVisualStyleBackColor = $True
- $Search.Text = "Search"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 384
- $System_Drawing_Point.Y = 84
- $Search.Location = $System_Drawing_Point
- $Search.DataBindings.DefaultDataSourceUpdateMode = 0
- $Search.add_Click($SearchClicked)
- $EventOMaticForm.Controls.Add($Search)
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 267
- $System_Drawing_Size.Height = 20
- $SearchText.Size = $System_Drawing_Size
- $SearchText.DataBindings.DefaultDataSourceUpdateMode = 0
- $SearchText.Name = "SearchText"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 110
- $System_Drawing_Point.Y = 85
- $SearchText.Location = $System_Drawing_Point
- $SearchText.TabIndex = 2
- $SearchText.add_Leave($SearchTextFocusOff)
- $SearchText.add_Enter($SearchTextFocusOn)
- $EventOMaticForm.Controls.Add($SearchText)
- $EventClear.TabIndex = 8
- $EventClear.Name = "EventClear"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 51
- $System_Drawing_Size.Height = 22
- $EventClear.Size = $System_Drawing_Size
- $EventClear.UseVisualStyleBackColor = $True
- $EventClear.Text = "Clear"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 407
- $System_Drawing_Point.Y = 262
- $EventClear.Location = $System_Drawing_Point
- $EventClear.DataBindings.DefaultDataSourceUpdateMode = 0
- $EventClear.add_Click($EventClearClicked)
- $EventOMaticForm.Controls.Add($EventClear)
- $FinishButton.TabIndex = 11
- $FinishButton.Name = "FinishButton"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 91
- $System_Drawing_Size.Height = 23
- $FinishButton.Size = $System_Drawing_Size
- $FinishButton.UseVisualStyleBackColor = $True
- $FinishButton.Text = "Finish"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 460
- $System_Drawing_Point.Y = 321
- $FinishButton.Location = $System_Drawing_Point
- $FinishButton.DataBindings.DefaultDataSourceUpdateMode = 0
- $FinishButton.DialogResult = 1
- $FinishButton.add_Click($FinishClicked)
- $EventOMaticForm.Controls.Add($FinishButton)
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 138
- $System_Drawing_Size.Height = 24
- $EventPlusRadio.Size = $System_Drawing_Size
- $EventPlusRadio.Text = "Use Get-VIEventPlus"
- $EventPlusRadio.Name = "EventPlusRadio"
- $EventPlusRadio.UseVisualStyleBackColor = $True
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 18
- $System_Drawing_Point.Y = 320
- $EventPlusRadio.Location = $System_Drawing_Point
- $EventPlusRadio.DataBindings.DefaultDataSourceUpdateMode = 0
- $EventPlusRadio.TabIndex = 9
- $EventOMaticForm.Controls.Add($EventPlusRadio)
- $GenerateCodeButton.TabIndex = 10
- $GenerateCodeButton.Name = "GenerateCodeButton"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 113
- $System_Drawing_Size.Height = 23
- $GenerateCodeButton.Size = $System_Drawing_Size
- $GenerateCodeButton.UseVisualStyleBackColor = $True
- $GenerateCodeButton.Text = "Generate Code"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 162
- $System_Drawing_Point.Y = 321
- $GenerateCodeButton.Location = $System_Drawing_Point
- $GenerateCodeButton.DataBindings.DefaultDataSourceUpdateMode = 0
- $GenerateCodeButton.add_Click($GenerateCodeClicked)
- $EventOMaticForm.Controls.Add($GenerateCodeButton)
- $SelectedEventList.FormattingEnabled = $True
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 270
- $System_Drawing_Size.Height = 121
- $SelectedEventList.Size = $System_Drawing_Size
- $SelectedEventList.DataBindings.DefaultDataSourceUpdateMode = 0
- $SelectedEventList.Name = "SelectedEventList"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 281
- $System_Drawing_Point.Y = 135
- $SelectedEventList.Location = $System_Drawing_Point
- $SelectedEventList.TabIndex = 5
- $SelectedEventList.add_Click($EventClicked)
- $EventOMaticForm.Controls.Add($SelectedEventList)
- $label4.TabIndex = 0
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 54
- $System_Drawing_Size.Height = 16
- $label4.Size = $System_Drawing_Size
- $label4.Text = "Selected"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 281
- $System_Drawing_Point.Y = 115
- $label4.Location = $System_Drawing_Point
- $label4.DataBindings.DefaultDataSourceUpdateMode = 0
- $label4.Name = "label4"
- $EventOMaticForm.Controls.Add($label4)
- $EventList.FormattingEnabled = $True
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 256
- $System_Drawing_Size.Height = 121
- $EventList.Size = $System_Drawing_Size
- $EventList.DataBindings.DefaultDataSourceUpdateMode = 0
- $EventList.Name = "EventList"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 18
- $System_Drawing_Point.Y = 135
- $EventList.Location = $System_Drawing_Point
- # $EventList.Sorted = $True
- $EventList.TabIndex = 4
- $EventList.add_MouseMove($EventMouseMove)
- $EventList.add_Click($EventClicked)
- $EventOMaticForm.Controls.Add($EventList)
- $label2.TabIndex = 0
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 49
- $System_Drawing_Size.Height = 18
- $label2.Size = $System_Drawing_Size
- $label2.Text = "Events"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 18
- $System_Drawing_Point.Y = 114
- $label2.Location = $System_Drawing_Point
- $label2.DataBindings.DefaultDataSourceUpdateMode = 0
- $label2.Name = "label2"
- $EventOMaticForm.Controls.Add($label2)
- $ConnectButton.TabIndex = 1
- $ConnectButton.Name = "ConnectButton"
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 75
- $System_Drawing_Size.Height = 23
- $ConnectButton.Size = $System_Drawing_Size
- $ConnectButton.UseVisualStyleBackColor = $True
- $ConnectButton.Text = "Connect"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 383
- $System_Drawing_Point.Y = 22
- $ConnectButton.Location = $System_Drawing_Point
- $ConnectButton.DataBindings.DefaultDataSourceUpdateMode = 0
- $ConnectButton.add_Click($ConnectClicked)
- $EventOMaticForm.Controls.Add($ConnectButton)
- $label1.TabIndex = 0
- $System_Drawing_Size = New-Object System.Drawing.Size
- $System_Drawing_Size.Width = 85
- $System_Drawing_Size.Height = 17
- $label1.Size = $System_Drawing_Size
- $label1.Text = "vSphere Server"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 18
- $System_Drawing_Point.Y = 27
- $label1.Location = $System_Drawing_Point
- $label1.DataBindings.DefaultDataSourceUpdateMode = 0
- $label1.Name = "label1"
- $EventOMaticForm.Controls.Add($label1)
- $EventTooltip.ToolTipTitle = "Description"
- #endregion
- #region RunForm Diakog
- #Save the initial state of the form
- $InitialFormWindowState = $EventOMaticForm.WindowState
- #Init the OnLoad event to correct the initial state of the form
- $EventOMaticForm.add_Load($OnLoadForm_StateCorrection)
- #Show the Form
- $EventOMaticForm.ShowDialog()| Out-Null
- #endregion
- }
- #region Main
- if(!$PSVersionTable -or $PSVersionTable.PSVersion.Major -lt 3){
- Write-Error "The script requires at least PowerShell v3."
- return
- }
- Try {
- Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction Stop
- }
- Catch {
- Write-Error "The script requires that the PowerCLI pssnapin is loaded."
- return
- }
- $eventomaticVersion = "3.2"
- $eventomaticIni = ".\Event-O-Matic.ini"
- if(Test-Path -Path $eventomaticIni){
- $script:vServers = @(Get-Content -Path $eventomaticIni)
- }
- # Show form
- GenerateForm
- $script:vServers | Set-Content -Path $eventomaticIni -Force -Confirm:$false
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement