WordPress.com
function Compare-Service{function OnApplicationLoad {return $true}function OnApplicationExit {#Note: This function runs after the form is closed#TODO: Add custom code to clean up and unload snapins when the application exits}#endregion Application Functions#----------------------------------------------# Generated Form Function#----------------------------------------------function Call-SystemInformation_pff {#----------------------------------------------#region Import the Assemblies#----------------------------------------------[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")[void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")[void][reflection.assembly]::Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization") #get-pssnapin -Registered -ErrorAction silentlycontinue#endregion Import Assemblies#----------------------------------------------#region Generated Form Objects#----------------------------------------------[System.Windows.Forms.Application]::EnableVisualStyles()$form1 = New-Object System.Windows.Forms.Form$btnRefresh = New-Object System.Windows.Forms.Button $btngetdata=New-Object System.Windows.Forms.Button$rtbPerfData = New-Object System.Windows.Forms.RichTextBox#$pictureBox1 = New-Object System.Windows.Forms.PictureBox $lblServicePack = New-Object System.Windows.Forms.Label $lblDBName= New-Object System.Windows.Forms.Label$lblOS = New-Object System.Windows.Forms.Label $lblExpire = New-Object System.Windows.Forms.Label$statusBar1 = New-Object System.Windows.Forms.StatusBar$btnClose = New-Object System.Windows.Forms.Button#$comboServers = New-Object System.Windows.boBox$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState $txtComputerName1 = New-Object System.Windows.Forms.TextBox $txtComputerName2 = New-Object System.Windows.Forms.TextBox $dataGrid1 = New-Object System.Windows.Forms.DataGrid $Chart = New-object System.Windows.Forms.DataVisualization.Charting.Chart #$dataGrid1 = new-object System.windows.forms.DataGridView#endregion Generated Form Objects#----------------------------------------------# User Generated Script#----------------------------------------------Function Compare-Service{param( [Parameter(Mandatory=$true)] [string]$Computer1, [Parameter(Mandatory=$true)] [string]$Computer2 )$Object =@()try {$ServicesOnComputer1 = Get-WMIObject -ComputerName $Computer1 -Class Win32_service -ErrorAction Stop }Catch [Exception]{[System.Windows.Forms.MessageBox]::Show("The $Computer1 host entered does not exist or cannot be contacted. Please try again!!!!");}try {$ServicesOnComputer2 = Get-WMIObject -ComputerName $Computer2 -Class Win32_service -ErrorAction Stop}Catch [Exception]{[System.Windows.Forms.MessageBox]::Show("The $Computer2 host entered does not exist or cannot be contacted. Please try again");}$d=Compare-Object -ReferenceObject $ServicesOnComputer1 -DifferenceObject $ServicesOnComputer2 -Property Name, StartMode, State, Status -PassThru `| Sort-Object DisplayName, SystemName | Select-Object SystemName, DisplayName, StartMode, State, Status foreach($Ser in $D){$SystemName = $Ser.SystemName$DisplayName = $Ser.DisplayName$StartMode =$Ser.StartMode $State = $Ser.State$Status =$Ser.Status$Object += New-Object PSObject -Property @{Name= $SystemName.ToUpper();DisplayName= $DisplayName;StartMode=$StartMode;State=$State;Status=$Status;}} $dt = new-Object Data.datatable $First = $true foreach ($item in $Object){ $DR = $DT.NewRow() $Item.PsObject.get_properties() | foreach { If ($first) { $Col = new-object Data.DataColumn $Col.ColumnName = $_.Name.ToString() $DT.Columns.Add($Col) } if ($_.value -eq $null) { $DR.Item($_.Name) = "[empty]" } ElseIf ($_.IsArray) { $DR.Item($_.Name) =[string]::Join($_.value ,";") } Else { $DR.Item($_.Name) = $_.value } } $DT.Rows.Add($DR) # $array.AddRange($DR) $First = $false } $dataGrid1.DataSource = $dt } $Close={ $form1.close()} $GetData={ if((Test-Connection -ComputerName $txtComputerName1.text -Count 1 -ea 0) -and (Test-Connection -ComputerName $txtComputerName2.text -Count 1 -ea 0)) { $statusBar1.text="Getting the Service Related Information...Please wait" Compare-Service -Computer1 $txtComputerName1.text -Computer2 $txtComputerName2.text } ELSE { [void][System.Windows.Forms.MessageBox]::Show("could not connect to a given computer, Please check") $statusBar1.text="Computer Name is Invalid.please check" } # $rtbPerfData.text=$data.Trim() $txtComputerName1.usewaitcursor=$False $errorActionPreference="Continue" $statusBar1.Text="Ready" }# --End User Generated Script--#----------------------------------------------# Generated Events#----------------------------------------------$Form_StateCorrection_Load={#Correct the initial state of the form to prevent the .Net maximized form issue$form1.WindowState = $InitialFormWindowState}#----------------------------------------------#region Generated Form Code#----------------------------------------------## form1#$form1.Controls.Add($btnRefresh)#$form1.Controls.Add($rtbPerfData)#$form1.Controls.Add($pictureBox1)$form1.Controls.Add($lblServicePack)$form1.Controls.Add($lblOS) $form1.Controls.Add($lblDBName)$form1.Controls.Add($statusBar1) $form1.Controls.Add($btnClose) $form1.Controls.Add($txtComputerName1) $Form1.controls.add($Chart) $Form1.controls.add($txtComputerName2) $Form1.controls.add($lblExpire)$form1.ClientSize = New-Object System.Drawing.Size(900,600)$form1.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation #$form1.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::SizableToolWindow $form1.Name = "form1"$form1.Text = "Service Comparison Tool "$form1.add_Load($PopulateList)# create chart object $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Width = 850 $System_Drawing_Size.Height = 450$dataGrid1.Size = $System_Drawing_Size $dataGrid1.DataBindings.DefaultDataSourceUpdateMode = 0 $dataGrid1.HeaderForeColor = [System.Drawing.Color]::FromArgb(255,0,0,0) $dataGrid1.Name = "dataGrid1" $dataGrid1.DataMember = "" $dataGrid1.TabIndex = 0 $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X =13 $System_Drawing_Point.Y = 72$dataGrid1.Location = $System_Drawing_Point $Chart.visible=$FALSE$form1.Controls.Add($dataGrid1) $dataGrid1.CaptionText='Service Comparison'## btnRefresh#$btnRefresh.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation $btnRefresh.Enabled = $TRUE$btnRefresh.Location = New-Object System.Drawing.Point(420,35)$btnRefresh.Name = "btnRefresh"$btnRefresh.Size = New-Object System.Drawing.Size(72,20)$btnRefresh.TabIndex = 7$btnRefresh.Text = "CmpSvc"$btnRefresh.UseVisualStyleBackColor = $True$btnRefresh.add_Click($GetData) # # # btnClose# $btnClose.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation $btngetdata.Enabled = $TRUE $btnClose.Location = New-Object System.Drawing.Point(500,35)$btnClose.Name = "btnClose"$btnClose.Size = New-Object System.Drawing.Size(72,20)$btnClose.TabIndex = 3$btnClose.Text = "Close"$btnClose.UseVisualStyleBackColor = $True$btnClose.add_Click($Close)# # lblDBName#$lblDBName.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation $lblDBName.Font = New-Object System.Drawing.Font("Lucida Console",8.25,1,3,1)$lblDBName.Location = New-Object System.Drawing.Point(13,10)$lblDBName.Name = "lblDBName"$lblDBName.Size = New-Object System.Drawing.Size(178,23)$lblDBName.TabIndex = 0$lblDBName.Text = "Enter the Name:Server 1 "$lblDBName.Visible = $TRUE # #$txtComputerName1.text #txtComputerName1 $txtComputerName1.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation $txtComputerName1.Location = New-Object System.Drawing.Point(200, 10) $txtComputerName1.Name = "txtComputerName1" $txtComputerName1.TabIndex = 1 $txtComputerName1.Size = New-Object System.Drawing.Size(200,70) $txtComputerName1.visible=$TRUE# # # lblExpire#$lblExpire.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation $lblExpire.Font = New-Object System.Drawing.Font("Lucida Console",8.25,1,3,1)$lblExpire.Location = New-Object System.Drawing.Point(13,35)$lblExpire.Name = "lblExpire"$lblExpire.Size = New-Object System.Drawing.Size(178,23)$lblExpire.TabIndex = 0$lblExpire.Text = "Enter the Name:Server 2 "$lblExpire.Visible = $TRUE ##$txtComputerName2.text #txtComputerName2 $txtComputerName2.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation $txtComputerName2.Location = New-Object System.Drawing.Point(200, 35) $txtComputerName2.Name = "txtComputerName2" $txtComputerName2.TabIndex = 1 $txtComputerName2.Size = New-Object System.Drawing.Size(200,70) $txtComputerName2.visible=$TRUE## lblServicePack#$lblServicePack.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation $lblServicePack.Font = New-Object System.Drawing.Font("Lucida Console",8.25,1,3,1)$lblServicePack.Location = New-Object System.Drawing.Point(13,100)$lblServicePack.Name = "lblServicePack"$lblServicePack.Size = New-Object System.Drawing.Size(278,23)$lblServicePack.TabIndex = 0$lblServicePack.Text = "ServicePack"$lblServicePack.Visible = $False## lblOS#$lblOS.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation $lblOS.Font = New-Object System.Drawing.Font("Lucida Console",8.25,1,3,1)$lblOS.Location = New-Object System.Drawing.Point(12,77)$lblOS.Name = "lblOS"$lblOS.Size = New-Object System.Drawing.Size(278,23)$lblOS.TabIndex = 2$lblOS.Text = "User Information"$lblOS.Visible = $False## statusBar1#$statusBar1.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation $statusBar1.Location = New-Object System.Drawing.Point(0,365)$statusBar1.Name = "statusBar1"$statusBar1.Size = New-Object System.Drawing.Size(390,22)$statusBar1.TabIndex = 5$statusBar1.Text = "statusBar1" ##>$rtbPerfData.BackColor = [System.Drawing.Color]::FromArgb(255,255,255,255)$rtbPerfData.BorderStyle = [System.Windows.Forms.BorderStyle]::None $rtbPerfData.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation $rtbPerfData.Font = New-Object System.Drawing.Font("Lucida Console",8.25,0,3,1)$rtbPerfData.Location = New-Object System.Drawing.Point(13,120)$rtbPerfData.Name = "rtbPerfData"$rtbPerfData.Size = New-Object System.Drawing.Size(450,200)$rtbPerfData.TabIndex = 6$rtbPerfData.Text = ""#Save the initial state of the form$InitialFormWindowState = $form1.WindowState #Init the OnLoad event to correct the initial state of the form$form1.add_Load($Form_StateCorrection_Load)#Show the Formreturn $form1.ShowDialog()} #End Function#Call OnApplicationLoad to initializeif(OnApplicationLoad -eq $true){#Create the formCall-SystemInformation_pff | Out-Null#Perform cleanupOnApplicationExit}}Compare-Service ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- wordpress passing data between pages
- wordpress business templates
- wordpress rss feed not working
- wordpress jquery is not defined
- create wordpress blog
- wordpress roles editor
- wordpress full rss feed
- wordpress rss feed settings
- wordpress rss feed plugin
- wordpress display rss feed
- wordpress rss feed link
- wordpress rss feed to post