【问题标题】:How to get the full list of applications like in control panel如何在控制面板中获取完整的应用程序列表
【发布时间】:2022-09-23 22:18:29
【问题描述】:

我一直被困在我的小项目的这个阶段。 我尝试做的是列出已安装的应用程序并选择要卸载的应用程序之一,我遇到的问题是并非所有应用程序都出现,所以我无法选择它们。例如,当我现在使用它来写这个问题时,谷歌浏览器没有出现。

我使用此功能获取所有应用程序:

Get-WmiObject Win32_Product -ComputerName $ComputerName | Select-Object -Property Name | Out-GridView -Title \"All apps on destination Computer\"

这是整个脚本:

    $ComputerName = Read-Host -Prompt \'Input the computer name\' # the name of the computer to remove the app from

Get-WmiObject Win32_Product -ComputerName $ComputerName | Select-Object -Property Name | Out-GridView -Title \"All apps on destination Computer\"

$Name = Read-Host -Prompt \'Input name of the application (has to be exact name)\'  #name of the application
$Application = Get-WmiObject Win32_Product -ComputerName $ComputerName | Where-Object {$_.Name -eq $Name}  #choose the object, this will be the app that we will delete
if ($Application) {
  $Application.Uninstall()
  \"The removal was successful\"
}
else {
  $Name + \' is not installed on \' + $ComputerName
}
Start-Sleep -Seconds 10

我对 PowerShell 不太擅长,所以如果这是一个愚蠢的问题,请原谅

    标签: windows powershell shell


    【解决方案1】:

    或者get-package,应该更快。 Uninstall-package 仅适用于 msi 提供程序。仅限 Powershell 5.1。

    get-package
    

    【讨论】:

    • Get-Package 仅列出通过包管理安装的包。
    • @zett42 不在 Windows Powershell 5.1 中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-10
    • 1970-01-01
    • 2023-03-24
    • 2022-08-05
    • 1970-01-01
    相关资源
    最近更新 更多