-
-
Save irwins/66f84ea30409be0564b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------------------------ | |
# Source File Information (DO NOT MODIFY) | |
# Source ID: 0e2b4026-3710-4ec0-8aef-f79ad0cbfae0 | |
# Source File: C:\scripts\forms\demo.psf | |
#------------------------------------------------------------------------ | |
<# | |
.NOTES | |
-------------------------------------------------------------------------------- | |
Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2015 v4.2.95 | |
Generated on: 10/15/2015 12:24 AM | |
Generated by: Irwin | |
Organization: Centric | |
-------------------------------------------------------------------------------- | |
.DESCRIPTION | |
GUI script generated by PowerShell Studio 2015 | |
#> | |
#---------------------------------------------- | |
#region Application Functions | |
#---------------------------------------------- | |
#endregion Application Functions | |
#---------------------------------------------- | |
# Generated Form Function | |
#---------------------------------------------- | |
function Call-demo_psf { | |
#---------------------------------------------- | |
#region Import the Assemblies | |
#---------------------------------------------- | |
[void][reflection.assembly]::Load('mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System.Data, 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('System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') | |
[void][reflection.assembly]::Load('System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | |
[void][reflection.assembly]::Load('System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') | |
#endregion Import Assemblies | |
#---------------------------------------------- | |
#region Generated Form Objects | |
#---------------------------------------------- | |
[System.Windows.Forms.Application]::EnableVisualStyles() | |
$formGetServices = New-Object 'System.Windows.Forms.Form' | |
$buttonGetService = New-Object 'System.Windows.Forms.Button' | |
$textboxComputerName = New-Object 'System.Windows.Forms.TextBox' | |
$labelComputerName = New-Object 'System.Windows.Forms.Label' | |
$buttonClose = New-Object 'System.Windows.Forms.Button' | |
$buttonOK = New-Object 'System.Windows.Forms.Button' | |
$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' | |
#endregion Generated Form Objects | |
#---------------------------------------------- | |
# User Generated Script | |
#---------------------------------------------- | |
$formGetServices_Load={ | |
#TODO: Initialize Form Controls here | |
#$buttonGetService.Enabled = $false | |
$textboxComputerName.Text = $env:COMPUTERNAME | |
} | |
$buttonClose_Click={ | |
#TODO: Place custom script here | |
$formGetServices.Close() | |
} | |
$buttonOK_Click={ | |
#TODO: Place custom script here | |
} | |
$buttonGetService_Click={ | |
#TODO: Place custom script here | |
try{ | |
Get-Service -ComputerName $textboxComputerName.Text.Trim() | Out-GridView -Title "Get Services on $($textboxComputerName.Text.Trim())" | |
} | |
catch{ | |
#[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") | |
[void][System.Windows.Forms.MessageBox]::Show("Can't get services on $($textboxComputerName.Text)","ComputerName") | |
} | |
} | |
$textboxComputerName_TextChanged={ | |
#TODO: Place custom script here | |
$buttonGetService.Enabled = $false | |
if ( $textboxComputerName.Text.Trim() -ne "" ) { | |
$buttonGetService.Enabled = $true | |
} | |
} | |
# --End User Generated Script-- | |
#---------------------------------------------- | |
#region Generated Events | |
#---------------------------------------------- | |
$Form_StateCorrection_Load= | |
{ | |
#Correct the initial state of the form to prevent the .Net maximized form issue | |
$formGetServices.WindowState = $InitialFormWindowState | |
} | |
$Form_Cleanup_FormClosed= | |
{ | |
#Remove all event handlers from the controls | |
try | |
{ | |
$buttonGetService.remove_Click($buttonGetService_Click) | |
$textboxComputerName.remove_TextChanged($textboxComputerName_TextChanged) | |
$buttonClose.remove_Click($buttonClose_Click) | |
$buttonOK.remove_Click($buttonOK_Click) | |
$formGetServices.remove_Load($formGetServices_Load) | |
$formGetServices.remove_Load($Form_StateCorrection_Load) | |
$formGetServices.remove_FormClosed($Form_Cleanup_FormClosed) | |
} | |
catch [Exception] | |
{ } | |
} | |
#endregion Generated Events | |
#---------------------------------------------- | |
#region Generated Form Code | |
#---------------------------------------------- | |
$formGetServices.SuspendLayout() | |
# | |
# formGetServices | |
# | |
$formGetServices.Controls.Add($buttonGetService) | |
$formGetServices.Controls.Add($textboxComputerName) | |
$formGetServices.Controls.Add($labelComputerName) | |
$formGetServices.Controls.Add($buttonClose) | |
$formGetServices.Controls.Add($buttonOK) | |
$formGetServices.AcceptButton = $buttonGetService | |
$formGetServices.ClientSize = '536, 123' | |
$formGetServices.FormBorderStyle = 'FixedDialog' | |
$formGetServices.MaximizeBox = $False | |
$formGetServices.MinimizeBox = $False | |
$formGetServices.Name = 'formGetServices' | |
$formGetServices.StartPosition = 'CenterScreen' | |
$formGetServices.Text = 'Get Services' | |
$formGetServices.add_Load($formGetServices_Load) | |
# | |
# buttonGetService | |
# | |
$buttonGetService.Location = '93, 88' | |
$buttonGetService.Name = 'buttonGetService' | |
$buttonGetService.Size = '350, 23' | |
$buttonGetService.TabIndex = 2 | |
$buttonGetService.Text = 'GetService' | |
$buttonGetService.UseVisualStyleBackColor = $True | |
$buttonGetService.add_Click($buttonGetService_Click) | |
# | |
# textboxComputerName | |
# | |
$textboxComputerName.Location = '172, 26' | |
$textboxComputerName.Name = 'textboxComputerName' | |
$textboxComputerName.Size = '352, 20' | |
$textboxComputerName.TabIndex = 1 | |
$textboxComputerName.add_TextChanged($textboxComputerName_TextChanged) | |
# | |
# labelComputerName | |
# | |
$labelComputerName.Location = '12, 29' | |
$labelComputerName.Name = 'labelComputerName' | |
$labelComputerName.Size = '125, 23' | |
$labelComputerName.TabIndex = 0 | |
$labelComputerName.Text = 'ComputerName' | |
# | |
# buttonClose | |
# | |
$buttonClose.Location = '12, 88' | |
$buttonClose.Name = 'buttonClose' | |
$buttonClose.Size = '75, 23' | |
$buttonClose.TabIndex = 3 | |
$buttonClose.Text = '&Close' | |
$buttonClose.UseVisualStyleBackColor = $True | |
$buttonClose.add_Click($buttonClose_Click) | |
# | |
# buttonOK | |
# | |
$buttonOK.Anchor = 'Bottom, Right' | |
$buttonOK.DialogResult = 'OK' | |
$buttonOK.Location = '449, 88' | |
$buttonOK.Name = 'buttonOK' | |
$buttonOK.Size = '75, 23' | |
$buttonOK.TabIndex = 4 | |
$buttonOK.Text = '&OK' | |
$buttonOK.UseVisualStyleBackColor = $True | |
$buttonOK.add_Click($buttonOK_Click) | |
$formGetServices.ResumeLayout() | |
#endregion Generated Form Code | |
#---------------------------------------------- | |
#Save the initial state of the form | |
$InitialFormWindowState = $formGetServices.WindowState | |
#Init the OnLoad event to correct the initial state of the form | |
$formGetServices.add_Load($Form_StateCorrection_Load) | |
#Clean up the control events | |
$formGetServices.add_FormClosed($Form_Cleanup_FormClosed) | |
#Show the Form | |
return $formGetServices.ShowDialog() | |
} #End Function | |
#Call the form | |
Call-demo_psf | Out-Null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment