Skip to content

Instantly share code, notes, and snippets.

@dmoruzzi
Created June 16, 2022 00:36
Show Gist options
  • Save dmoruzzi/31a6e50a96cabe118198381960fa6346 to your computer and use it in GitHub Desktop.
Save dmoruzzi/31a6e50a96cabe118198381960fa6346 to your computer and use it in GitHub Desktop.
This is a sample script to show how to unpin a shortcut from the taskbar via Powershell without modules
# This is a sample script to show how to unpin a shortcut from the taskbar via Powershell without modules.
# The path of the shortcut .lnk file to be unpinned.
$Application = "$Home\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\App.lnk"
if (Test-Path -path "$Application"){
(New-Object -ComObject shell.application).NameSpace($Application.Substring(0, $Application.LastIndexOf("\"))).ParseName($Application.Substring($Application.LastIndexOf("\") + 1)).Verbs() | Where-Object {
$_.Name.replace('&', '') -match 'Unpin from taskbar'
}
| ForEach-Object {
$_.DoIt()
}
}
else {
Write-Host "The shortcut $Application does not exist."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment