나는 기계의 숫자에 대해 실행할 수있는 foreach 문 블록을 사용하고이 기능이있다 :기능
PS C:\windows\system32> Get-InstalledApps ibm | ft
Computer AppName Publisher DisplayVersion InstallDate UninstallString
-------- ------- --------- -------------- ----------- ---------------
Computer.domain.COM IBM Tivoli Storage Manager Client IBM 06.04.0001 20140807 MsiExec.exe /I{FF99015E-71B4-41AB-8985-67D99383A72A}
: 로컬
function Get-InstalledApps ($appStr) {
$appWC = "*$appStr*"
if ([IntPtr]::Size -eq 4) {
$regpath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
}
else {
$regpath = @(
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
}
$getapps = Get-ItemProperty $regpath | .{process{if($_.DisplayName -and $_.UninstallString) { $_ } }}
Foreach ($app in $getapps | where {$_.DisplayName -like $appWC}) {
[pscustomobject]@{Computer = ($env:COMPUTERNAME + "." + $env:USERDNSDOMAIN)
AppName = ($app.displayname)
Publisher = ($app.Publisher)
DisplayVersion = ($app.DisplayVersion)
InstallDate = ($app.InstallDate)
UninstallString = ($App.UninstallString)}
}
}
, 그것은 다음과 같습니다
그러나 일부 컴퓨터에서 원격으로 실행할 때
(즉 :
은 Invoke-Command -ComputerName $ 컴퓨터 -scriptblock $ {기능 : 가져 오기-을 InstalledApps} -ArgumentList $ appStr
나는, 그러나 다른 사람에 나는 위 얻을 얻을이 :
Name Value
---- -----
UninstallString MsiExec.exe /I{68C09095-AC00-4541-B46B-0835F2BDB0CE}
Computer comp1.domain.com
Publisher IBM
InstallDate 20150122
DisplayVersion 07.01.0000
AppName IBM Tivoli Storage Manager Client
UninstallString MsiExec.exe /X{1316AC9A-7A5D-4866-B41F-4B3CF03CE52A}
Computer comp2.domain.com
Publisher IBM Corp.
InstallDate 20170226
DisplayVersion 9.2.7.53
AppName IBM BigFix Client
없이 아직 일부 컴퓨터의 PowerShell 버전을 확인할 수있는 기회를 얻었으므로 < 버전 3.0을 실행하는 컴퓨터에 대해 실행 한 결과로 두 번째 결과 집합이있을 것으로 예상됩니다.
모든 컴퓨터에서 출력을 테이블 (첫 번째 출력 예)로 표시하도록하는 방법은 무엇입니까?