Advertisement
AugustineW

Printer Query GUI - Front-line support tool

Sep 27th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Load-PrinterQueryGUI {
  2. #--//////////////////////-----
  3. #Purpose: Search Print server query across one or all print servers available.
  4. #Created: Gus Whitehouse
  5.  
  6. #Description: This GUI is designed to assist tech staff provide front line support for printers and print servers.
  7. #-----
  8. #Inputs -->> Requires a CSV file containing a list of available print servers for quiery
  9. # > Uses the Get-Printer cmdlet available only in Windows 10
  10. # --> Support: https://technet.microsoft.com/en-us/library/hh918358.aspx
  11. # Makes use of the AddRecord function available in previous pastebin posts
  12. # --> http://pastebin.com/WW5CujK6
  13.  
  14.     Function AddRecord
  15.     {
  16.     [CmdletBinding()]
  17.         Param
  18.         (
  19.             [Parameter(
  20.             Mandatory=$true,
  21.             ValueFromPipeline=$true)
  22.             ][string]$Column1,
  23.             [Parameter(
  24.             Mandatory=$true,
  25.             ValueFromPipeline=$true)
  26.             ][string]$Column2,
  27.             [Parameter(
  28.             Mandatory=$true,
  29.             ValueFromPipeline=$true)
  30.             ][string]$Column3,
  31.             [Parameter(
  32.             Mandatory=$true,
  33.             ValueFromPipeline=$true)
  34.             ][string]$Column4,
  35.             [Parameter(
  36.             Mandatory=$false)
  37.             ][string]$status
  38.         )
  39.         Begin{}
  40.         Process
  41.         {
  42.             $rowitem = New-Object System.Windows.Forms.ListViewItem($Column1)
  43.             Switch($status){
  44.                 "Normal"{$rowitem.ForeColor = [System.Drawing.Color]::FromArgb(255,0,100,0)}
  45.                 ("Offline","Error,Offline"){$rowitem.ForeColor = [System.Drawing.Color]::FromArgb(255,139,0,0)}
  46.                 "TonerLow"{$rowitem.ForeColor = [System.Drawing.Color]::FromArgb(255,244,164,96)}
  47.             }
  48.        
  49.             $rowitem.SubItems.Add($Column2)
  50.             $rowitem.SubItems.Add($Column3)
  51.             $rowitem.SubItems.Add($Column4)
  52.             $lstVDetails.Items.AddRange($rowitem)
  53.         }
  54.         End
  55.         {
  56.             $PrinterHeader.Width = -2
  57.             $Serverheader.Width = -2
  58.             $Portheader.Width = -2
  59.             $Locationheader.Width = -2
  60.         }
  61.     }
  62.  
  63.  
  64. #region Import the Assemblies
  65. [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
  66. [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
  67. #endregion
  68.  
  69. #region Generated Form Objects
  70. $frmPrinterQuery = New-Object System.Windows.Forms.Form
  71. $rdoLocation = New-Object System.Windows.Forms.RadioButton
  72. $lblSAPPrinter = New-Object System.Windows.Forms.Label
  73. $label2 = New-Object System.Windows.Forms.Label
  74. $lstVDetails = New-Object System.Windows.Forms.ListView
  75. $btnClose = New-Object System.Windows.Forms.Button
  76. $cmbPrintServer = New-Object System.Windows.Forms.ComboBox
  77. $btnCopyPath = New-Object System.Windows.Forms.Button
  78. $statusBar1 = New-Object System.Windows.Forms.StatusBar
  79. $btnSearch = New-Object System.Windows.Forms.Button
  80. $rdoIPAddress = New-Object System.Windows.Forms.RadioButton
  81. $rdoBarcode = New-Object System.Windows.Forms.RadioButton
  82. $label1 = New-Object System.Windows.Forms.Label
  83. $txtPrinterName = New-Object System.Windows.Forms.TextBox
  84. $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
  85. $PrinterHeader = New-Object System.Windows.Forms.ColumnHeader
  86. $ServerHeader = New-Object System.Windows.Forms.ColumnHeader
  87. $PortHeader = New-Object System.Windows.Forms.ColumnHeader
  88. $LocationHeader = New-Object System.Windows.Forms.ColumnHeader
  89. #endregion Generated Form Objects
  90.  
  91. #----------------------------------------------
  92. #Generated Event Script Blocks
  93. #----------------------------------------------
  94. $btnCopyPath_OnClick=
  95. {
  96.     #Easy copy path in format \\printserver\printer for easy install via run command.
  97.     $printpath = "\\" + $lstVDetails.SelectedItems[0].SubItems[1].Text + "\" + $lstVDetails.SelectedItems[0].text
  98.     $clipboardData = $printpath
  99.     [Windows.Forms.Clipboard]::Clear();
  100.     [Windows.Forms.Clipboard]::SetText("$clipboardData")
  101. }
  102.  
  103. $lstVDetails_ItemActivate=
  104. {
  105.     #Dynamic query printer status and location details and display in statusbar;  Assuming your print admins are diligent with filling out all printer fields.
  106.     $Servername = $lstVDetails.SelectedItems[0].SubItems[1].Text
  107.     $printerdetails = Get-Printer -ComputerName ($ServerName) | Where-Object{$_.sharename -eq "$($lstVDetails.SelectedItems[0].Text)" -and $_.DeviceType -eq "Print"} | Select *
  108.     $description = "$($printerdetails.comment) -STATUS: $($printerdetails.printerstatus)"
  109.     #Write-Host $description
  110.     $statusBar1.text = $description
  111. }
  112.  
  113. $btnClose_OnClick=
  114. {
  115. #TODO: Place custom script here
  116.     $frmPrinterQuery.Close()
  117. }
  118.  
  119. $btnSearch_OnClick=
  120. {
  121. #TODO: Place custom script here
  122.     #Form Validation
  123.     $contextMenuStripService.Items.Clear()
  124.     $lblSAPPrinter.Text = ""
  125.     If($txtPrinterName -eq ""){$statusBar1.Text = "Searching all Printers"}
  126.     If($rdoBarcode.Checked -eq $false -and $rdoIPAddress.Checked -eq $false -and $rdoLocation.Checked -eq $false){$statusBar1.Text = "Please select Barcode, IP Address or Location";return}
  127.  
  128.     #Clear data from form
  129.     $lstVDetails.items.Clear()  
  130.    
  131.     #inform operator of impending search
  132.     $statusBar1.text = "Searching Print Servers.... Please Wait"
  133.  
  134.     #Check form selections - radio buttons
  135.     If($rdoBarcode.Checked)
  136.     {
  137.         $filter = "name"
  138.     }
  139.     If($rdoIPAddress.Checked)
  140.     {
  141.         $filter = "PortName"
  142.     }
  143.     If($rdoLocation.Checked)
  144.     {
  145.         $filter = "location"
  146.     }
  147.    
  148.     #Determine what server chosen in list;        
  149.     Switch($cmbPrintServer.Text)
  150.     {
  151.         "All Print Servers" #All printers in list;
  152.         {
  153.             #Advise operator of lengthy query of multiple print servers
  154.             $statusBar1.text = "WARNING: This may take a while.."
  155.  
  156.             #Cycle through all servers in drop down list;
  157.             $cmbPrintServer.Items | ForEach{
  158.                                         #Validate server is on for query
  159.                                         If(Test-Connection $_ -quiet -Count 1)
  160.                                         {
  161.                                             #Store Get-Printer query result based on radio button selected
  162.                                             $Found += Get-Printer -ComputerName $_ -ErrorAction SilentlyContinue | Where-Object{$_.($filter) -like "*$($txtPrinterName.text)*" -and $_.DeviceType -eq "Print"} | Select *  
  163.                                         }  
  164.                                     }
  165.         }
  166.         Default #All other selected printers in drop down list
  167.         {
  168.             #Validate server is on for query
  169.             If(Test-Connection $cmbPrintServer.Text -quiet -Count 1)
  170.             {
  171.                 #Store Get-Printer query result based on radio button selected
  172.                 $Found = Get-Printer -ComputerName $cmbPrintServer.Text -ErrorAction SilentlyContinue | Where-Object{$_.($filter) -like "*$($txtPrinterName.text)*" -and $_.DeviceType -eq "Print"} | Select *
  173.             }
  174.         }
  175.     }
  176.  
  177.     If($Found.count -gt 1) #Query multiple records found;
  178.     {
  179.         ForEach($record in $found)
  180.         {
  181.             #Add list items based on multiple selection
  182.             AddRecord -Column1 $record.ShareName -Column2 $record.ComputerName -Column3 $record.PortName -Column4 $record.Location -status $record.PrinterStatus
  183.         }
  184.     }Else{
  185.         If($Found)
  186.         {
  187.             #Validate variable is not null and add to list.
  188.             AddRecord -Column1 $Found.ShareName -Column2 $Found.ComputerName -Column3 $Found.PortName -Column4 $Found.Location -status $record.PrinterStatus                
  189.         }
  190.     }
  191.    
  192.     #Change the select mode for each row        
  193.     $lstVDetails.FullRowSelect = $True
  194.  
  195.     #Invoke right click menu only if there are items in the list.
  196.     If($lstVDetails.Items.Count -gt 0)
  197.     {
  198.         #Construct contextmenu for selection
  199.         $contextMenuStripService.Items.Add('Printer Configuration Site')
  200.     }
  201.    
  202.     #Inform operator that the search is now complete and return result count.              
  203.     $statusBar1.text = "Search Completed - $($lstVDetails.Items.Count) printers found.."
  204.    
  205.     #Set variables to null
  206.     $Found = $null
  207.  
  208. }
  209.  
  210. $handler_rightclickmenu=[System.Windows.Forms.ToolStripItemClickedEventHandler]{
  211.     #Handy right click option to connect to a printer's web portal if available;
  212.     Switch($_.clickeditem.text){
  213.         "Printer Configuration Site"{Start-Process -FilePath "C:\Program Files\Internet Explorer\iexplore.exe" -ArgumentList "http://$($lstVDetails.SelectedItems[0].SubItems[2].Text)"}
  214.     }
  215. }
  216.  
  217. $OnLoadForm_StateCorrection=
  218. {#Correct the initial state of the form to prevent the .Net maximized form issue
  219.     $frmPrinterQuery.WindowState = $InitialFormWindowState
  220. }
  221. $OnLoadForm_StoreVars={
  222.    
  223.     #printservers.csv contains a list of print servers on your network
  224.     If(test-path "c:\temp\printservers.csv")
  225.     {
  226.         $cmbPrintServer.BeginUpdate()
  227.         $PrinterList = Import-Csv "c:\temp\printservers.csv"
  228.      
  229.         #Assume csv file contains column labelled servers
  230.         $Global:PrintServers = $PrinterList.Servers | Sort-Object | Select -Unique
  231.    
  232.         ForEach($Server in $PrintServers){$cmbPrintServer.Items.Add($Server)}
  233.         $cmbPrintServer.Items.Add("----------")
  234.         $cmbPrintServer.Items.Add("All Print Servers")
  235.         $cmbPrintServer.EndUpdate()
  236.     }else{
  237.         write-host "Printservers.csv doesn't exist; Please ensure there is a csv file in the following location with a column labelled 'Servers'"
  238.         write-host -ForegroundColor Yellow "File Path - c:\temp\printservers.csv"
  239.         $frmPrinterQuery.Close()
  240.         #break
  241.     }
  242. }
  243.  
  244. #----------------------------------------------
  245. #region Generated Form Code
  246. $System_Drawing_Size = New-Object System.Drawing.Size
  247. $System_Drawing_Size.Height = 415
  248. $System_Drawing_Size.Width = 614
  249. $frmPrinterQuery.ClientSize = $System_Drawing_Size
  250. $frmPrinterQuery.DataBindings.DefaultDataSourceUpdateMode = 0
  251. $frmPrinterQuery.FormBorderStyle = 5
  252. $frmPrinterQuery.Name = "frmPrinterQuery"
  253. $frmPrinterQuery.StartPosition = 1
  254. $frmPrinterQuery.Text = "Find Printer Query (Windows 10 ONLY)               [PowerShell cmdlet: Get-Printer]"
  255.  
  256. $rdoLocation.DataBindings.DefaultDataSourceUpdateMode = 0
  257.  
  258. $System_Drawing_Point = New-Object System.Drawing.Point
  259. $System_Drawing_Point.X = 280
  260. $System_Drawing_Point.Y = 43
  261. $rdoLocation.Location = $System_Drawing_Point
  262. $rdoLocation.Name = "rdoLocation"
  263. $System_Drawing_Size = New-Object System.Drawing.Size
  264. $System_Drawing_Size.Height = 24
  265. $System_Drawing_Size.Width = 104
  266. $rdoLocation.Size = $System_Drawing_Size
  267. $rdoLocation.TabIndex = 12
  268. $rdoLocation.TabStop = $True
  269. $rdoLocation.Text = "Location"
  270. $rdoLocation.UseVisualStyleBackColor = $True
  271.  
  272. $frmPrinterQuery.Controls.Add($rdoLocation)
  273.  
  274. $btnClose.DataBindings.DefaultDataSourceUpdateMode = 0
  275.  
  276. $System_Drawing_Point = New-Object System.Drawing.Point
  277. $System_Drawing_Point.X = 516
  278. $System_Drawing_Point.Y = 360
  279. $btnClose.Location = $System_Drawing_Point
  280. $btnClose.Name = "btnClose"
  281. $System_Drawing_Size = New-Object System.Drawing.Size
  282. $System_Drawing_Size.Height = 27
  283. $System_Drawing_Size.Width = 86
  284. $btnClose.Size = $System_Drawing_Size
  285. $btnClose.TabIndex = 10
  286. $btnClose.Text = "Close"
  287. $btnClose.UseVisualStyleBackColor = $True
  288. $btnClose.add_Click($btnClose_OnClick)
  289.  
  290. $frmPrinterQuery.Controls.Add($btnClose)
  291.  
  292. $lblSAPPrinter.DataBindings.DefaultDataSourceUpdateMode = 0
  293. $lblSAPPrinter.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",8.25,0,3,0)
  294. $lblSAPPrinter.ForeColor = [System.Drawing.Color]::FromArgb(255,0,128,0)
  295.  
  296. $System_Drawing_Point = New-Object System.Drawing.Point
  297. $System_Drawing_Point.X = 133
  298. $System_Drawing_Point.Y = 368
  299. $lblSAPPrinter.Location = $System_Drawing_Point
  300. $lblSAPPrinter.Name = "lblSAPPrinter"
  301. $System_Drawing_Size = New-Object System.Drawing.Size
  302. $System_Drawing_Size.Height = 18
  303. $System_Drawing_Size.Width = 370
  304. $lblSAPPrinter.Size = $System_Drawing_Size
  305. $lblSAPPrinter.TabIndex = 12
  306. $lblSAPPrinter.Visible = $False
  307.  
  308. $frmPrinterQuery.Controls.Add($lblSAPPrinter)
  309.  
  310. $label2.DataBindings.DefaultDataSourceUpdateMode = 0
  311. $label2.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",9.75,0,3,0)
  312.  
  313. $System_Drawing_Point = New-Object System.Drawing.Point
  314. $System_Drawing_Point.X = 52
  315. $System_Drawing_Point.Y = 75
  316. $label2.Location = $System_Drawing_Point
  317. $label2.Name = "label2"
  318. $System_Drawing_Size = New-Object System.Drawing.Size
  319. $System_Drawing_Size.Height = 21
  320. $System_Drawing_Size.Width = 62
  321. $label2.Size = $System_Drawing_Size
  322. $label2.TabIndex = 11
  323. $label2.Text = "Server:"
  324. $label2.TextAlign = 64
  325. $frmPrinterQuery.Controls.Add($label2)
  326.  
  327. $lstVDetails.BackColor = [System.Drawing.Color]::FromArgb(255,255,255,192)
  328. $lstVDetails.Font = New-Object System.Drawing.Font("Arial",10,0,3,0)
  329. $lstVDetails.ForeColor = [System.Drawing.Color]::FromArgb(255,244,164,96)
  330. $lstVDetails.DataBindings.DefaultDataSourceUpdateMode = 0
  331. $System_Drawing_Point = New-Object System.Drawing.Point
  332. $System_Drawing_Point.X = 16
  333. $System_Drawing_Point.Y = 111
  334. $lstVDetails.Location = $System_Drawing_Point
  335. $lstVDetails.Name = "lstVDetails"
  336. $System_Drawing_Size = New-Object System.Drawing.Size
  337. $System_Drawing_Size.Height = 243
  338. $System_Drawing_Size.Width = 586
  339. $lstVDetails.Size = $System_Drawing_Size
  340. $lstVDetails.TabIndex = 9
  341. $lstVDetails.UseCompatibleStateImageBehavior = $False
  342. $lstVDetails.View = 1
  343. $lstVDetails.Columns.Add($PrinterHeader)
  344. $PrinterHeader.Text = "Printer"
  345. $PrinterHeader.Width = -2
  346. $lstVDetails.Columns.Add($ServerHeader)
  347. $ServerHeader.Text = "Server"
  348. $ServerHeader.Width = -2
  349. $lstVDetails.Columns.Add($PortHeader)
  350. $PortHeader.Text = "Port"
  351. $PortHeader.Width = -2
  352. $lstVDetails.Columns.Add($LocationHeader)
  353. $LocationHeader.Text = "Location"
  354. $LocationHeader.Width = -2
  355. $contextMenuStripService = New-Object System.Windows.Forms.ContextMenuStrip
  356. $contextMenuStripService.add_ItemClicked($handler_rightclickmenu)
  357. $lstVDetails.add_Click($lstVDetails_ItemActivate)
  358.  
  359. $lstVDetails.ContextMenuStrip = $contextMenuStripService
  360.  
  361.  
  362. $frmPrinterQuery.Controls.Add($lstVDetails)
  363.  
  364. $cmbPrintServer.DataBindings.DefaultDataSourceUpdateMode = 0
  365. $cmbPrintServer.FormattingEnabled = $True
  366. $System_Drawing_Point = New-Object System.Drawing.Point
  367. $System_Drawing_Point.X = 123
  368. $System_Drawing_Point.Y = 75
  369. $cmbPrintServer.Location = $System_Drawing_Point
  370. $cmbPrintServer.Name = "cmbPrintServer"
  371. $System_Drawing_Size = New-Object System.Drawing.Size
  372. $System_Drawing_Size.Height = 21
  373. $System_Drawing_Size.Width = 199
  374. $cmbPrintServer.Size = $System_Drawing_Size
  375. $cmbPrintServer.TabIndex = 8
  376.  
  377. $frmPrinterQuery.Controls.Add($cmbPrintServer)
  378.  
  379.  
  380. $btnCopyPath.DataBindings.DefaultDataSourceUpdateMode = 0
  381.  
  382. $System_Drawing_Point = New-Object System.Drawing.Point
  383. $System_Drawing_Point.X = 16
  384. $System_Drawing_Point.Y = 363
  385. $btnCopyPath.Location = $System_Drawing_Point
  386. $btnCopyPath.Name = "btnCopyPath"
  387. $System_Drawing_Size = New-Object System.Drawing.Size
  388. $System_Drawing_Size.Height = 24
  389. $System_Drawing_Size.Width = 86
  390. $btnCopyPath.Size = $System_Drawing_Size
  391. $btnCopyPath.TabIndex = 7
  392. $btnCopyPath.Text = "Copy Path"
  393. $btnCopyPath.UseVisualStyleBackColor = $True
  394. $btnCopyPath.add_Click($btnCopyPath_OnClick)
  395.  
  396. $frmPrinterQuery.Controls.Add($btnCopyPath)
  397.  
  398. $statusBar1.DataBindings.DefaultDataSourceUpdateMode = 0
  399. $statusBar1.Font = New-Object System.Drawing.Font("Arial Narrow",12,0,3,0)
  400. $System_Drawing_Point = New-Object System.Drawing.Point
  401. $System_Drawing_Point.X = 0
  402. $System_Drawing_Point.Y = 293
  403. $statusBar1.Location = $System_Drawing_Point
  404. $statusBar1.Name = "statusBar1"
  405. $System_Drawing_Size = New-Object System.Drawing.Size
  406. $System_Drawing_Size.Height = 22
  407. $System_Drawing_Size.Width = 419
  408. $statusBar1.Size = $System_Drawing_Size
  409. $statusBar1.TabIndex = 6
  410. $statusBar1.Text = "Search Printer, IP Address, Location or leave blank to find all printers per site.."
  411.  
  412. $frmPrinterQuery.Controls.Add($statusBar1)
  413.  
  414.  
  415. $btnSearch.DataBindings.DefaultDataSourceUpdateMode = 0
  416.  
  417. $System_Drawing_Point = New-Object System.Drawing.Point
  418. $System_Drawing_Point.X = 338
  419. $System_Drawing_Point.Y = 66
  420. $btnSearch.Location = $System_Drawing_Point
  421. $btnSearch.Name = "btnSearch"
  422. $System_Drawing_Size = New-Object System.Drawing.Size
  423. $System_Drawing_Size.Height = 30
  424. $System_Drawing_Size.Width = 75
  425. $btnSearch.Size = $System_Drawing_Size
  426. $btnSearch.TabIndex = 5
  427. $btnSearch.Text = "Search.."
  428. $btnSearch.UseVisualStyleBackColor = $True
  429. $btnSearch.add_Click($btnSearch_OnClick)
  430.  
  431. $frmPrinterQuery.Controls.Add($btnSearch)
  432.  
  433.  
  434. $rdoIPAddress.DataBindings.DefaultDataSourceUpdateMode = 0
  435.  
  436. $System_Drawing_Point = New-Object System.Drawing.Point
  437. $System_Drawing_Point.X = 194
  438. $System_Drawing_Point.Y = 46
  439. $rdoIPAddress.Location = $System_Drawing_Point
  440. $rdoIPAddress.Name = "rdoIPAddress"
  441. $System_Drawing_Size = New-Object System.Drawing.Size
  442. $System_Drawing_Size.Height = 22
  443. $System_Drawing_Size.Width = 91
  444. $rdoIPAddress.Size = $System_Drawing_Size
  445. $rdoIPAddress.TabIndex = 3
  446. $rdoIPAddress.TabStop = $True
  447. $rdoIPAddress.Text = "IP Address"
  448. $rdoIPAddress.UseVisualStyleBackColor = $True
  449.  
  450. $frmPrinterQuery.Controls.Add($rdoIPAddress)
  451.  
  452.  
  453. $rdoBarcode.DataBindings.DefaultDataSourceUpdateMode = 0
  454.  
  455. $System_Drawing_Point = New-Object System.Drawing.Point
  456. $System_Drawing_Point.X = 120
  457. $System_Drawing_Point.Y = 46
  458. $rdoBarcode.Location = $System_Drawing_Point
  459. $rdoBarcode.Name = "rdoBarcode"
  460. $System_Drawing_Size = New-Object System.Drawing.Size
  461. $System_Drawing_Size.Height = 24
  462. $System_Drawing_Size.Width = 98
  463. $rdoBarcode.Size = $System_Drawing_Size
  464. $rdoBarcode.TabIndex = 2
  465. $rdoBarcode.TabStop = $True
  466. $rdoBarcode.Text = "Barcode"
  467. $rdoBarcode.UseVisualStyleBackColor = $True
  468.  
  469. $frmPrinterQuery.Controls.Add($rdoBarcode)
  470.  
  471. $label1.DataBindings.DefaultDataSourceUpdateMode = 0
  472. $label1.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",9.75,0,3,0)
  473.  
  474. $System_Drawing_Point = New-Object System.Drawing.Point
  475. $System_Drawing_Point.X = 12
  476. $System_Drawing_Point.Y = 9
  477. $label1.Location = $System_Drawing_Point
  478. $label1.Name = "label1"
  479. $System_Drawing_Size = New-Object System.Drawing.Size
  480. $System_Drawing_Size.Height = 40
  481. $System_Drawing_Size.Width = 102
  482. $label1.Size = $System_Drawing_Size
  483. $label1.TabIndex = 1
  484. $label1.Text = "Printer Name:"
  485. $label1.TextAlign = 64
  486.  
  487. $frmPrinterQuery.Controls.Add($label1)
  488.  
  489. $txtPrinterName.DataBindings.DefaultDataSourceUpdateMode = 0
  490. $txtPrinterName.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",9.75,0,3,0)
  491. $System_Drawing_Point = New-Object System.Drawing.Point
  492. $System_Drawing_Point.X = 120
  493. $System_Drawing_Point.Y = 18
  494. $txtPrinterName.Location = $System_Drawing_Point
  495. $txtPrinterName.Name = "txtPrinterName"
  496. $System_Drawing_Size = New-Object System.Drawing.Size
  497. $System_Drawing_Size.Height = 22
  498. $System_Drawing_Size.Width = 293
  499. $txtPrinterName.Size = $System_Drawing_Size
  500. $txtPrinterName.TabIndex = 0
  501.  
  502. $frmPrinterQuery.Controls.Add($txtPrinterName)
  503.  
  504. #endregion Generated Form Code
  505.  
  506. #Save the initial state of the form
  507. $InitialFormWindowState = $frmPrinterQuery.WindowState
  508. #Init the OnLoad event to correct the initial state of the form
  509. $frmPrinterQuery.add_Load($OnLoadForm_StateCorrection)
  510. $frmPrinterQuery.add_Load($OnLoadForm_StoreVars)
  511. #Show the Form
  512. $frmPrinterQuery.ShowDialog()| Out-Null
  513.  
  514. } #End Function
  515.  
  516. #Call the Function
  517. Load-PrinterQueryGUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement