I’m changing my pc due to BSOD issues, and wanted a quick way to capture my Quick Access pins at Windows 11.

The result is a simple PowerShell function Set-QuickAccessItem available at this gist

Below is the try/catch blocks, see the gist for the functions code.

Inspired by A Dr. Scripto Blog


    try {
        $shell = New-Object -ComObject shell.application
        $quickAccessGUID = 'shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}'
        $quickAccessItems = $shell.Namespace($quickAccessGUID).Items()
        $resolvedPath = (Get-Item $Path).FullName

        $isPinned = $quickAccessItems | Where-Object { $_.Path -eq $resolvedPath }

        if ($PSBoundParameters.ContainsKey('Unpin') ) {
            if ($isPinned) {
                # unpin
                $shell.Namespace($Path).Self.InvokeVerb("pintohome")
                Write-Verbose "Unpinned from Quick Access"
            }
        } else {
            if (-not $isPinned) {
                # pin
                $shell.Namespace($Path).Self.InvokeVerb("pintohome")
                Write-Verbose "Pinned to Quick Access"
            }
        }
    } catch {
        Write-Verbose "Error while modifying Quick Access: $_"
    }

<
Previous Post
A better and faster CIDR to subnet mask in PowerShell
>
Blog Archive
Archive of all previous blog posts