プログラムの追加/削除リストに一致するインストール済みアプリケーションのリストの取得

Aug 21 2020

私は、顧客のコンピューターにインストールされているすべてのプログラムを一覧表示するアプリケーションに取り組んでいます。レジストリキーに基づいてリストを取得できましたが、Microsoftストア経由でインストールされたものは含まれていません。PowerShellを使用しているようです(このページのガイダンスに基づく:https://mhelp.pro/how-to-uninstall-windows-apps/)インストールされているアプリケーションのリストを取得できますが、そこに表示されるものには、[プログラムの追加と削除]にない項目が多数含まれているようで、2つのソース(プログラムの追加と削除)を調整する方法がわかりません。およびPowerShellを介したプログラムのリスト)。これを行うためのより良い方法はありますか、またはリストされたアプリケーションがプログラムの追加と削除に存在するかどうかを判断するために使用する必要があるフラグまたは基準はありますか?

回答

1 Hackoo Aug 22 2020 at 08:59

おそらくそのようなことを意味しましたか?

Windowsにインストールされているプログラムのリストを作成する方法を参照してください


$outputFile = "$env:APPDATA\Installed_Applications.txt"
$OS_Architecture = $env:PROCESSOR_ARCHITECTURE
if($OS_Architecture -eq 'x86') { #write-host '32-bit' $key = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
}
else
{
    #write-host '64-bit'
    $key = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" } Get-ItemProperty $Key |
        Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
            Format-Table –AutoSize |
                Out-File $outputFile -Encoding UTF8 -Force Start-Process $outputFile

編集:25/08/2020 @ 18:20

管理者権限ですべてを取得するための自己昇格スクリプトは次のとおりです。

cls
# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
  if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
      #$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments $CommandLine = $MyInvocation.InvocationName Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
      Exit
     }
    }

$outputFile = "$env:APPDATA\Installed_Applications.txt"
$OS_Architecture = $env:PROCESSOR_ARCHITECTURE
if($OS_Architecture -eq 'x86') { #write-host '32-bit' $key = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
}
else
{
    #write-host '64-bit'
    $key = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" } Get-ItemProperty $Key |
        Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
            Format-Table –AutoSize | Out-String -Width 300 |
                Out-File $outputFile -Encoding UTF8 -Force Get-AppxPackage -AllUsers | Out-File -Append $outputFile -Encoding UTF8 -Force 
                            Start $outputFile
js2010 Aug 22 2020 at 19:29

PowerShell 5では、PowerShell 7ではありません:

get-package