For system administrators, creating a standardized desktop environment often involves customizing the Windows taskbar. While pinning items is easy for a user, automating the process of listing or unpinning applications can be surprisingly difficult. Windows intentionally does not provide a simple, built-in command to manage pinned items to prevent applications from pinning themselves without user consent.

However, with a bit of PowerShell scripting, you can gain control over the taskbar. This guide will walk you through the most effective methods to list, unpin, and manage taskbar items programmatically.

⚠️ Important Note: Most of these methods require PowerShell to be run as Administrator. After making changes, you will need to restart the Explorer process for them to take effect.

> # Run this after making changes to see them apply
> Stop-Process -Name explorer -Force; Start-Process explorer
> 


1. How to List Pinned Taskbar Items

The most reliable way to see which applications a user has pinned is to inspect the folder where Windows stores these shortcuts.

> # Path to the user-pinned taskbar items folder
> $pinnedPath = "$env:APPDATA\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
> 
> # Check if the path exists
> if (Test-Path $pinnedPath) {
>     # List all .lnk files and resolve their target paths
>     Get-ChildItem -Path $pinnedPath -Filter "*.lnk" |
>         Select-Object Name, @{Name='TargetPath'; Expression={
>             (New-Object -ComObject WScript.Shell).CreateShortcut($_.FullName).TargetPath
>         }} | Format-Table -AutoSize
> } else {
>     Write-Warning "Pinned items folder not found. No custom items are pinned."
> }

Example Output:

Name               TargetPath
----               ----------
File Explorer.lnk  C:\Windows\explorer.exe
Microsoft Edge.lnk C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
Notepad.lnk        C:\WINDOWS\system32\notepad.exe

This method lists only the items pinned by the current user. System-default pins (like the Microsoft Store on a fresh installation) are stored elsewhere and are best managed via the methods below.


2. How to Unpin Items from the Taskbar

Since there is no Unpin-TaskbarItem cmdlet, we have to use more creative methods.

This is the cleanest method as it programmatically invokes the same “Unpin from taskbar” action that a user would perform by right-clicking an icon.

Here is a reusable PowerShell function to do this:

> function Unpin-FromTaskbar {
>     param(
>         [Parameter(Mandatory = $true)]
>         [string]$AppName
>     )
> 
>     try {
>         # Get the Shell Application object
>         $shell = New-Object -ComObject Shell.Application
>         
>         # Find the application in the Start Menu namespace
>         # This is the most reliable way to find an application's verbs
>         $startMenu = $shell.Namespace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}')
>         $app = $startMenu.Items() | Where-Object { $_.Name -eq $AppName }
>
>         if ($app) {
>             # Find the "Unpin from taskbar" verb
>             $unpinVerb = $app.Verbs() | Where-Object { $_.Name.Replace('&', '') -match 'Unpin from taskbar' }
>             
>             if ($unpinVerb) {
>                 # Execute the verb
>                 $unpinVerb.DoIt()
>                 Write-Host "Successfully unpinned '$AppName' from the taskbar." -ForegroundColor Green
>             } else {
>                 Write-Warning "Could not find the 'Unpin from taskbar' verb for '$AppName'. It might be a system app or already unpinned."
>             }
>         } else {
>             Write-Error "Application '$AppName' not found in the Start Menu namespace."
>         }
>     } catch {
>         Write-Error "An error occurred: $($_.Exception.Message)"
>     }
> }
> 
> # --- Example Usage ---
> Unpin-FromTaskbar -AppName "Microsoft Edge"
> Unpin-FromTaskbar -AppName "File Explorer"
> 
> # Remember to restart Explorer to see the changes
> # Stop-Process -Name explorer -Force; Start-Process explorer

How It Works: This function uses the Shell.Application COM object to find an application by its name (as it appears in the Start Menu) and then programmatically “clicks” the “Unpin from taskbar” verb associated with it.

Method 2: The “Nuke Everything” Method (Resetting the Taskbar)

If you want to remove all user-pinned items and reset the taskbar to its default state, you can do so by deleting the registry key that stores the pinned item cache.

⚠️ Warning: This is a destructive action and will remove all custom pins. Back up your registry before proceeding.

> # Path to the registry key that stores the taskbar pin cache
> $regPath = "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Taskband"
> 
> # Check if the key exists before trying to remove properties
> if (Test-Path $regPath) {
>     Write-Host "Removing taskbar pin cache from the registry..."
>     # These two values store the list of pinned items
>     Remove-ItemProperty -Path $regPath -Name "Favorites" -ErrorAction SilentlyContinue
>     Remove-ItemProperty -Path $regPath -Name "FavoritesChanges" -ErrorAction SilentlyContinue
>     
>     Write-Host "Cache removed. Restarting Explorer to apply changes." -ForegroundColor Yellow
>     Stop-Process -Name explorer -Force; Start-Process explorer
> } else {
>     Write-Warning "Taskband registry key not found. No custom items to remove."
> }

This method is effective for resetting the taskbar to a clean state but offers no granular control.


Automation Example: Creating a Standard Taskbar

Here is how you could combine these techniques to enforce a standard taskbar layout by unpinning a specific list of applications.

> # (Paste the Unpin-FromTaskbar function from Method 1 here)
> 
> # --- Main Script ---
> $appsToUnpin = @(
>     "Microsoft Edge",
>     "File Explorer",
>     "Microsoft Store",
>     "Mail"
> )
> 
> Write-Host "Starting taskbar cleanup..."
> foreach ($app in $appsToUnpin) {
>     Unpin-FromTaskbar -AppName $app
> }
> 
> Write-Host "Cleanup complete. Restarting Explorer to apply all changes."
> Stop-Process -Name explorer -Force; Start-Process explorer

Conclusion

While Windows doesn’t offer a straightforward way to manage pinned taskbar items, PowerShell provides the necessary tools to automate the process.

  • For listing items, inspecting the User Pinned\TaskBar folder is the most direct method.
  • For unpinning specific items, using the Shell.Application COM object to invoke the “Unpin” verb is the most reliable and non-destructive approach.
  • For a complete reset, deleting the Taskband registry key is a quick but blunt solution.

By using these PowerShell techniques, system administrators can effectively script and enforce a standardized taskbar layout across multiple machines, ensuring a consistent user experience.