远程检查是否安装了某些程序?

问题描述

因此,在这里的一些帮助下,我设法使一些事情起作用,但是我确实需要弄清楚这一点。我一生都无法解决这个问题。我如何获得输出真或假?现在,由于第一台计算机没有安装该软件,而其他五台都安装了该软件,因此它一直在说错误。我试图在一个整洁的CSV文件中编译一个简单的清单来执行此操作,因为我必须尽快在1400多台计算机上安装缺少的软件!

# Source Text File For List of Computers
$servers = Get-Content "listofcomputers.txt"

# Create Report for CSV Export
$report = @()
ForEach ($server in $servers) {
  Try {
    $tempreport = New-Object PSObject
    
# Grab Curent IP Address
    $ip_address = ((Test-Connection -ea stop -Count 1 -comp $server).IPV4Address).IPAddresstoString
    
# Grab Curent Logged On User
    $user = Get-WmiObject –ComputerName $server –Class Win32_ComputerSystem | Select -ExpandProperty UserName
    
# Grab OS Name
    $os_name = (Get-WmiObject Win32_OperatingSystem -ComputerName $server ).Caption
    
# Grab OS Version
    $os_version = (Get-WmiObject Win32_OperatingSystem -ComputerName $server ).Version
    
# Checklist
    $adobe = Test-Path 'filesystem::\\$server\C$\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe'

# Create Object Table
    $tempreport | Add-Member NoteProperty Server $server
    $tempreport | Add-Member NoteProperty Status "Up"
    $tempreport | Add-Member NoteProperty IP $ip_address
    $tempreport | Add-Member NoteProperty User $user
    $tempreport | Add-Member NoteProperty OSName $os_name
    $tempreport | Add-Member NoteProperty Osversion $os_version
    $tempreport | Add-Member NoteProperty Adobe $adobe
    $report += $tempreport
    } 
  Catch {
    $tempreport = New-Object PSObject   
    $tempreport | Add-Member NoteProperty Server $server
    $tempreport | Add-Member NoteProperty Status "Down"
    $tempreport | Add-Member NoteProperty IP "N/A"
    $tempreport | Add-Member NoteProperty User "N/A"
    $tempreport | Add-Member NoteProperty OSName "N/A"
    $tempreport | Add-Member NoteProperty Osversion "N/A"
    $tempreport | Add-Member NoteProperty Adobe $adobe
    $report += $tempreport 
    }
  }

# Export Results to CSV
    $report | Export-Csv -NoTypeinformation "z_queryresults.csv"
    
# Correct Any Empty Fields


# display Results Witin PS Window
    $P = Import-Csv -Path .\z_queryresults.csv
    $P | Format-Table

# Pause Script & Exit
    Read-Host -Prompt "Press Enter to continue"

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)