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