windowspowershell

Unpin the Microsoft Edge and store taskbar shortcuts programmatically


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?


Solution

  • You can unpin taskbar items by running the following PowerShell commands.

    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: