我正在尝试创建一个删除某个AppV包的脚本。我遇到的问题是AppV软件包安装在没有管理员权限的本地用户下,所以我收到了这条消息:
“许可被拒绝”
但是,当我以管理员身份运行脚本并提供我的凭据时,AppV包不会显示。这是我用来列出和删除包的代码部分。
# Remove AppV version of inProcess
$allAppV = Get-AppvClientPackage
If ($allAppV.Count -ge 0) {
$i = 1
#This part lists the packages
Write-Host "List AppV packages"
ForEach($Package in $allAppV) {
Write-Host `t $i - $Package.Name
$i +=
1
}
# Select which package to remove
$NumbertoRemove = Read-Host
"Which one would you like to remove? Type 0 if none"
If ($NumbertoRemove -eq 0) {
Write-Host "Not removing any App-V Client Package"
$Global:More = $False
}
else {
If ($NumbertoRemove -le $allAppV.Count) {
$NumbertoRemove -= 1
Write-Host "Removing package" $allAppV[$NumbertoRemove].Name
$PackageToRemove = $allAppV[$NumbertoRemove]
If ($PackageToRemove.IsPublishedGlobally)
{Unpublish-AppvClientPackage $allAppV[$NumbertoRemove]}
# I need to provide admin credentials for this step
Remove-AppvClientPackage $allAppV[$NumbertoRemove]
Write-Host "AppV Client Package has been removed"
这是我以本地用户身份运行脚本时的样子。如果我输入1,它将尝试卸载inProcess但获得权限被拒绝错误。
如果我以管理员身份运行,它看起来一样,只是它没有列出任何包。我想是因为脚本是以管理员身份运行的,所以它列出了在admin帐户下安装的软件包,它们都是无。
我需要以管理员身份运行脚本,但列出本地用户的Appv包或提供remove-AppvClientPackages步骤的凭据。最好提示凭据删除包。感谢