powershell 发布/取消发布AppV快捷方式
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 发布/取消发布AppV快捷方式相关的知识,希望对你有一定的参考价值。
function Publish-AppVEShortcut {
Get-AppvClientPackage | % {
$Path = "$($env:USERPROFILE)\Desktop\[AppVEnvironment] $($_.Name) $($_.Version).lnk"
$TargetPath = "$($env:SystemRoot)\system32\WindowsPowerShell\v1.0\powershell.exe"
$Arguments = "/appvve:$($_.PackageId)_$($_.VersionId)"
$Description = "Windows PowerShell for AppV environment"
try {
$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($Path)
$Shortcut.TargetPath = $TargetPath
$Shortcut.Arguments = $Arguments
$Shortcut.Description = $Description
$Shortcut.Save()
"Shortcut created successfully. $($Path)"
} catch {
Throw $_
}
}
}
function Unpublish-AppVEShortcut {
Get-AppvClientPackage | % {
$Path = "$($env:USERPROFILE)\Desktop\[AppVEnvironment] $($_.Name) $($_.Version).lnk"
try {
if ((Test-Path -LiteralPath $Path) -eq $true) {
Remove-Item -LiteralPath $Path
"Shortcut removed successfully. $($Path)"
} else {
"Path not found. $($Path)"
}
} catch {
Throw $_
}
}
}
以上是关于powershell 发布/取消发布AppV快捷方式的主要内容,如果未能解决你的问题,请参考以下文章