Question:
I setup computers daily and I need to remove the Microsoft Edge and Store taskbar shortcuts.
I am having trouble creating a script and I have searched for other stackoverflow posts but they were not helpful to me.
Does anyone have a script that can unpin the MS Edge and Store taskbar shortcuts?
Answer:
You can unpin taskbar items by running the following PowerShell commands.
1 2 3 4 5 6 7 8 |
function Unpin-App([string]$appname) { ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from taskbar'} | %{$_.DoIt()} } Unpin-App("Microsoft Edge") Unpin-App("Microsoft Store") |
This should work for any application on the taskbar. If the application isn’t found, the error InvokeMethodOnNull
will be thrown.
What this does:
- Enumerates the Shell/taskbar COM object namespace
- Matches the item with the name
$appname
(in this case, Edge and Store) - Gets the verb
Unpin from taskbar
of that com object - Executes the verb to remove it from the taskbar (without having to kill explorer.exe)