PowerShell Studio Create Visualizer-Scan software 1.0

Source: Internet
Author: User

Recently PowerShell QQ Group is popular with GUI interface installed B, in order to keep up with the trend, beans have also made a small program, the small program can be based on the operating system and keywords, scan the domain of the computer installed the corresponding software.


The interface is as follows

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/82/04/wKioL1dH07bi2JG4AAAwKhaFkFM820.png "title=" 1.PNG " alt= "Wkiol1dh07bi2jg4aaawkhafkfm820.png"/>


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/82/04/wKioL1dH1BuSNWZmAABXRdxqZ9c645.png "title=" 2.PNG " alt= "Wkiol1dh1busnwzmaabxrdxqz9c645.png"/>


This interface is done through PowerShell Studio 2015, mainly using Label,combox, textbox, Datagridview,savafilediag, button several controls.


Several key points

1. Based on operating system and keyword query

Function get-software{[cmdletbinding ()]param  ([Parameter (mandatory =  $true,  position  = 1)][string] $software, [string] $computername  =  "*", [string] $OS) write-verbose  " Scanning computers "if  ($computername  -ne  ' * ') {$a  = get-adcomputer - filter  "operatingsystem -like " * $OS * '  -and name -like  ' * $computername * '   " -properties operatingsystem, ipv4address | where-object{ $_.ipv4address  -ne  $null  } | select -expandproperty name}else{$a  =  get-adcomputer -filter  "operatingsystem -like " * $OS *   " -Properties  operatingsystem, ipv4address | where-object{ $_.ipv4address -ne  $null  }  | select -expandproperty name} $progressbaroverlay 1. Maximum=100$progressbaroverlay1. value=20# $MainForm. Refresh () write-verbose  "scanning SOFTWARE&NBSP $s  = Invoke-Command -ComputerName  $a  -erroraction  silentlycontinue -errorvariable disconnect{param  ([string] $name) if  ([system.intptr]::size  -EQ 4) {get-itemproperty hklm:\software\microsoft\windows\currentversion\uninstall\* |  Where-Object{ $_.displayname -like  "* $name *"  } | Select-Object  Displayname, displayversion, publisher, installdate}else{get-itemproperty hklm:\software\ Microsoft\windows\currentversion\uninstall\*, hklm:\software\wow6432node\microsoft\windows\currentversion \uninstall\* | where-object{ $_.displayname -like  "* $name *"  } |  Select-object displayname, displayversion, publisher, installdate}} -argumentlist   $software $progressbaroverlay1. value=80# $MainForm. Refresh () #Write-verbose  "Disconnected computers" # $disconnect. targetobject$ ProgressbAroverlay1. Value | out-string| write-host$s }


2. Bind the generated object to DataGridView inside note convertto-datatable is generated by the snippet (drag snippet to your own script block)

$table = Convertto-datatable-inputobject $resultLoad-datagridview-datagridview $datagridview 1-item $table $ Progressbaroverlay1. Visible = $false


3. DataGridView Sorting


$datagridview 1_columnheadermouseclick = [system.windows.forms.datagridviewcellmouseeventhandler]{#Event Argument: $_ = [System.windows.forms.datagridviewcellmouseeventargs]if ($datagridview 1. Datasource-is [System.Data.DataTable]) {$column = $datagridview 1. Columns[$_. ColumnIndex] $direction = [System.componentmodel.listsortdirection]::ascendingif ($column. Headercell.sortglyphdirection-eq ' descending ') {$direction = [System.ComponentModel.ListSortDirection]::D escending } $datagridview 1. Sort ($datagridview 1. Columns[$_. ColumnIndex], $direction)}}


4. Save

Function Set-filename ($initialDirectory) {[System.reflection.assembly]::loadwithpartialname (" System.Windows.Forms ") | Out-null$savefiledialog1. InitialDirectory = $initialDirectory $savefiledialog1. Filter= "All Files (*. *) | *. * "$savefiledialog 1. ShowDialog () | Out-null$savefiledialog1. Filename#model:set-filename-initialdirectory "D:\Scripts\ Example"} $button Save _click = {#TODO: Place custom Script here$file = Set-filenamewrite-verbose "Print out" $datagridview 1. Rows |select-expand databounditem |export-csv $file-notype}


5. Progress bar

I am manually configuring the rate of progress in the corresponding place. Of course, you can also automatically increase the progress step according to the cycle.

Like the end, I set my schedule to 90%.

$progressbaroverlay 1. Value = 90


Attached to the entire project source code, interested can be downloaded to see.

This article is from the "Mapo Tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1783800

PowerShell Studio Create Visualizer-Scan software 1.0

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.