Powershell to see if the software was installed successfully

Source: Internet
Author: User

Sometimes beans use GPOs to install the software and want to see if the client is installed successfully, the Windows client may have hundreds of thousand, so the beans write a simple program to view.


Ideas are as follows:


Pass parameter software name and operating system name, search for corresponding computer object, create remote session for each object, if fail (such as shutdown or other case), output failed computer name; For successfully connected objects, query the registry according to 32bit or 64bit, and output the result.


Function get-software{[cmdletbinding ()]param ([Parameter (mandatory= $true, position=1)][string] $software, [ Validateset (", ",  "2003", "7", "8", "ten")][string] $OS) write-verbose  "scanning  Computers. " $a =get-adcomputer -filter  "operatingsystem -like " * $OS *   " -Properties  operatingsystem,ipv4address | where-object{$_.ipv4address -ne  $null} | select  -expandproperty name# $a =get-adcomputer -filter  "operatingsystem -like  ' * $OS * '   " -properties operatingsystem,ipv4address | where-object{test-connection - computername $_.name -count 1-quiet} | select -expandproperty  namewrite-verbose  "Initialising new sessions ..." $session =new-pssession -computername  $a  -erroraction silentlycontinue -errorvariable  errif ($err  -ne  $null) {write-warning  "Following mahcines cannot setup a session "$err. TargetObject} $scriptblock ={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}} write-verbose  "Generating reports" $s =invoke-command -session  $session   $scriptblock  -ArgumentList  $software $s | out-gridview}get-software -software   "Silverlight"  -os 7 -verbose 


The results are as follows


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/61/wKiom1X7mwaRkRwOAARaxRXGKLw009.jpg "style=" float: none; "title=" A.png "alt=" Wkiom1x7mwarkrwoaaraxrxgklw009.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/5F/wKioL1X7nUDiRzUMAASKrpSjbcs322.jpg "style=" float: none; "title=" B.png "alt=" Wkiol1x7nudirzumaaskrpsjbcs322.jpg "/>


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

Powershell to see if the software was installed successfully

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.