我是 PowerShell 的新手,我正在寻找一种卸载多个应用程序的方法。我在一个文本文件中有一个要卸载的应用程序列表。这是我到目前为止的代码:
# Retrieve names of all softwares to un-install and places in variable $app
$App = Get-Content "C:\temp\un-installApps.txt"
# Cycle through each of the softwares to un-install and store in the WMI variable
Foreach ($AppName in $App)
{
$AppTmp = Get-WmiObject -query "Select * from win32_product WHERE Name like" + $AppName
$AppNames = $AppNames + $AppTmp
}
foreach ($Application in $AppNames )
{
msiexec /uninstall $Application.IdentifyingNumber
}
以下几行导致问题
$AppTmp = Get-WmiObject -query "Select * from win32_product WHERE Name like" + $AppName
$AppNames = $AppNames + $AppTmp"
有什么想法可以让这个工作吗?