Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 正在客户端计算机上查找POG_Powershell - Fatal编程技术网

Powershell 正在客户端计算机上查找POG

Powershell 正在客户端计算机上查找POG,powershell,Powershell,我有一个客户希望找到公司所有安装的程序我写了一个脚本,但我不希望脚本每次都为每个计算机显示相同的程序,我希望看到整个安装 $computers = get-adcomputers -filter * foreach($computer in $computers){ Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object

我有一个客户希望找到公司所有安装的程序我写了一个脚本,但我不希望脚本每次都为每个计算机显示相同的程序,我希望看到整个安装

  $computers = get-adcomputers -filter *
  foreach($computer in $computers){
  Get-ItemProperty 
  HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | 
  Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format- 
  Table –AutoSize}

我没有测试这个,但是你可以试试

$computers = (Get-ADComputer -Filter *).DNSHostName   # or use .Name or .CN

$software = Invoke-Command -ComputerName $computers {
                Get-ItemProperty -Path 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
            }
$software | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate -Unique |
            Format-Table -AutoSize
p.S.1要执行此操作,您需要在所有计算机上具有管理员权限

p.S.2别忘了还有
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall


显然,您在计算机离线时遇到了问题。
为了克服这个问题,您需要添加一个循环,以便测试机器是否可以访问

$computers = (Get-ADComputer -Filter *).Name   # or use .CN

# loop through the collection and (if reachable) get the software list
$result = foreach ($computer in $computers) {
    # test if the computer is online
    if (Test-Connection -ComputerName $computer -Count 1 -Quiet) {
        # output the properties you need to get collected in variable $result
        Invoke-Command -ComputerName $computer {
            Get-ItemProperty -Path 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
        } | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate
    }
    else {
        Write-Warning "Computer $computer is off-line"
    }
}

$software = $result | Select-Object * -Unique

# output to console
$software | Format-Table -AutoSize

# output to CSV file
$software | Export-Csv -Path 'D:\Software.csv' -NoTypeInformation

那会是什么问题呢?请完整地说明错误消息,它表示“无法验证参数‘computername’上的参数。参数为空”我使用了您的脚本版本我将第一行从dnshostname更改为name,并得到一个不同的错误,该错误表示Winrm客户端无法处理该请求,因为无法解析服务器名称。我尝试了另一个类似这样的脚本:Get-CimInstance-ComputerName(Get-Content C:\Temp\Computer.txt)-ClassName win32_product-ErrorAction SilentlyContinue |选择对象PSComputerName、名称、PackageName、,InstallDate | Out GridView,但对于脱机的服务器,我发现一个错误,我不确定脚本是否在继续查找更多内容servers@Lyoxa_grimm在尝试获取软件列表之前,我添加了新的代码,以检查计算机是否可以访问。我们没有收到您的消息。。我的回答解决了你的问题吗?如果是,请点击✓ 左边的图标。这将帮助其他有类似问题的人更容易地找到它。