【发布时间】: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