使用 get-appxpackage 卸载所有没有我安装的应用程序的用户

Uninstall all apps without those installed by me the user with get-appxpackage

我想卸载 windows 上预装的所有应用程序,而不卸载我安装的那些应用程序。我知道我可以按名称指定应用程序,但我想 运行 在安装应用程序时无需手动更新此脚本。

我的脚本是这样的

Get-AppxPackage -allusers | where-object {$_.name –notlike "*store*"} | where-object {$_.name –notlike "*calculator*"} | where-object {$_.name –notlike "*terminal*"} | where-object {$_.name –notlike "*winget*"} | where-object {$_.name –notlike "*DesktopAppInstaller*"} | where-object {$_.name –notlike "*Microsoft.VCLibs.140.00.UWPDesktop*"} | where-object {$_.name –notlike "*DesktopAppInstaller*"} | Remove-AppxPackage

我可以将其更改为始终卸载我不想保留在 windows 安装中的应用程序,如下所示:

get-appxpackage -allusers *3dbuilder* | remove-appxpackage
get-appxpackage -allusers *alarms* | remove-appxpackage
get-appxpackage -allusers *appconnector* | remove-appxpackage

然而,这也是相当手动的,只要 windows 继续添加其他糟糕的应用程序,我仍然需要找到并将其添加到我的列表中。

我可以通过某种方式找到用户手动安装的应用程序吗?通过安装文件或使用 winget。 或者我是否需要制作一个程序来安装我的应用程序槽以保存已安装应用程序的 ID(如果它们是使用 winget 安装的)?

Windows 包管理器(截至今天 10/7/2021)不记录它在系统上安装的内容。将来有工作添加这个,但在当前状态下无法知道应用程序安装的来源。