私はマシンの数に対して実行する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 $
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
なし::私は上記を得る{機能は、Get-のinstalledApps} -ArgumentList $ appStr
は、しかし、他の人に私はこれを取得しますまだいくつかのコンピュータのPowerShellバージョンを確認する機会がありますが、私は<バージョン3.0を実行しているコンピュータに対して実行された結果として2番目の結果が出ていると推測しています。
出力をすべてのコンピュータで表(最初の出力例)として表示する方法はありますか?