windows - 获取与添加/删除程序列表匹配的已安装应用程序列表

标签 windows powershell

我正在开发一个应用程序,该应用程序列出了客户计算机上所有已安装的程序。我已经能够获得基于注册表项的列表,但它不包括通过 Microsoft Store 安装的内容。看起来像使用 PowerShell(基于本页上的指导: https://mhelp.pro/how-to-uninstall-windows-apps/ )我可以获取已安装应用程序的列表,但我得到的似乎包括许多“添加/删除程序”中没有的项目,我不确定如何协调这两个来源(添加/删除程序和通过 PowerShell 的程序列表)。我应该有更好的方法来执行此操作,或者是否应该使用一个标志或标准来确定“添加/删除程序”中是否存在列出的应用程序?

最佳答案

也许您的意思是类似的?

引用How to Create a List of Your Installed Programs on 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

关于windows - 获取与添加/删除程序列表匹配的已安装应用程序列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63529209/

相关文章:

Azure powershell 函数停止工作(未发现任何更改),并出现错误 "Could not load file or assembly ' Azure.Core,版本=1.5.1.0“

C 编程写入注册表不起作用? RegSetValueEX 错误

java - 开发 Java Swing 应用程序,该应用程序将使用数据库存储数据并将其显示在 JFrame 上

css - 当滚动条可见时停止浏览器调整网站大小

windows - LoadLibrary 引用计数

azure - 使用 Azure Functions 连接到 AzureAD 时出现 TLS 版本问题

json - powershell xml 到 json 空白文件

windows - 安装/卸载 Windows 服务

php - 无法查看 Apache "It Works!"以外的 XAMPP 本地主机页面

powershell - 在属性中使用哈希表键