Windows 10: Windows PowerShell - Pin and Unpin Programmatically

Discus and support Windows PowerShell - Pin and Unpin Programmatically in Windows 10 Customization to solve the problem; Hey MS Community, I'm looking for a method to programmatically unpin Microsoft Edge and pin Internet Explorer. Currently, our vendors have sites that... Discussion in 'Windows 10 Customization' started by ddacnayr, Oct 31, 2019.

  1. ddacnayr Win User

    Windows PowerShell - Pin and Unpin Programmatically


    Hey MS Community,


    I'm looking for a method to programmatically unpin Microsoft Edge and pin Internet Explorer. Currently, our vendors have sites that are only supported in Internet Explorer, and will result in an error if opened with Microsoft Edge. Since the two icons are so similar, many new users end up calling IT simply due to using the wrong browser. This is because Edge is pinned by default whenever a user first signs in.


    I was able to find a program online that unpin's programs, however I can't seem to get the pin portion functioning.


    Thanks in advance for taking a look.



    Here is the script that I have:



    function Pin-App ([string]$appname, [switch]$unpin, [switch]$start, [switch]$taskbar, [string]$path) {

    if ($unpin.IsPresent) {

    $action = "Unpin"

    } else {

    $action = "Pin"

    }



    if (-not $taskbar.IsPresent -and -not $start.IsPresent) {

    Write-Error "Specify -taskbar and/or -start!"

    }



    if ($taskbar.IsPresent) {

    try {

    $exec = $false

    if ($action -eq "Unpin") {

    ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from taskbar'} | %{$_.DoIt(); $exec = $true}

    if ($exec) {

    Write "App '$appname' unpinned from Taskbar"

    } else {

    if (-not $path -eq "") {

    Pin-App-by-Path $path -Action $action

    } else {

    Write "'$appname' not found or 'Unpin from taskbar' not found on item!"

    }

    }

    } else {

    ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Pin to taskbar'} | %{$_.DoIt(); $exec = $true}



    if ($exec) {

    Write "App '$appname' pinned to Taskbar"

    } else {

    if (-not $path -eq "") {

    Pin-App-by-Path $path -Action $action

    } else {

    Write "'$appname' not found or 'Pin to taskbar' not found on item!"

    }

    }

    }

    } catch {

    Write-Error "Error Pinning/Unpinning $appname to/from taskbar!"

    }

    }



    if ($start.IsPresent) {

    try {

    $exec = $false

    if ($action -eq "Unpin") {

    ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from Start'} | %{$_.DoIt(); $exec = $true}



    if ($exec) {

    Write "App '$appname' unpinned from Start"

    } else {

    if (-not $path -eq "") {

    Pin-App-by-Path $path -Action $action -start

    } else {

    Write "'$appname' not found or 'Unpin from Start' not found on item!"

    }

    }

    } else {

    ((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq $appname}).Verbs() | ?{$_.Name.replace('&','') -match 'Pin to Start'} | %{$_.DoIt(); $exec = $true}



    if ($exec) {

    Write "App '$appname' pinned to Start"

    } else {

    if (-not $path -eq "") {

    Pin-App-by-Path $path -Action $action -start

    } else {

    Write "'$appname' not found or 'Pin to Start' not found on item!"

    }

    }

    }

    } catch {

    Write-Error "Error Pinning/Unpinning $appname to/from Start!"

    }

    }

    }



    function Pin-App-by-Path([string]$Path, [string]$Action, [switch]$start) {

    if ($Path -eq "") {

    Write-Error -Message "You need to specify a Path" -ErrorAction Stop

    }

    if ($Action -eq "") {

    Write-Error -Message "You need to specify an action: Pin or Unpin" -ErrorAction Stop

    }

    if ((Get-Item -Path $Path -ErrorAction SilentlyContinue) -eq $null){

    Write-Error -Message "$Path not found" -ErrorAction Stop

    }

    $Shell = New-Object -ComObject "Shell.Application"

    $ItemParent = Split-Path -Path $Path -Parent

    $ItemLeaf = Split-Path -Path $Path -Leaf

    $Folder = $Shell.NameSpace($ItemParent)

    $ItemObject = $Folder.ParseName($ItemLeaf)

    $Verbs = $ItemObject.Verbs()



    if ($start.IsPresent) {

    switch($Action){

    "Pin" {$Verb = $Verbs | Where-Object -Property Name -EQ "&Pin to Start"}

    "Unpin" {$Verb = $Verbs | Where-Object -Property Name -EQ "Un&pin from Start"}

    default {Write-Error -Message "Invalid action, should be Pin or Unpin" -ErrorAction Stop}

    }

    } else {

    switch($Action){

    "Pin" {$Verb = $Verbs | Where-Object -Property Name -EQ "Pin to Tas&kbar"}

    "Unpin" {$Verb = $Verbs | Where-Object -Property Name -EQ "Unpin from Tas&kbar"}

    default {Write-Error -Message "Invalid action, should be Pin or Unpin" -ErrorAction Stop}

    }

    }



    if($Verb -eq $null){

    Write-Error -Message "That action is not currently available on this Path" -ErrorAction Stop

    } else {

    $Result = $Verb.DoIt()

    }

    }


    Pin-App "Microsoft Edge" -unpin -taskbar

    Pin-App-by-Path "C:\Program Files\internet explorer\iexplore.exe" -pin -taskbar

    :)
     
    ddacnayr, Oct 31, 2019
    #1
  2. JayPhi Win User

    Clear "Pin suggested" list in People Bar


    Does anybody know how to clear the "Pin suggested" list on the "People bar"?

    Contacts are added to the "Pin suggested" list once you've pinned and unpinned them. But there seems to be no obvious way to remove them from that list.

    After playing around with this feature and pinning and unpinning many dummy contacts, it's rather annoying to see them in the "Pin suggested" list when you click on the "My People" icon in the taskbar.
     
    JayPhi, Oct 31, 2019
    #2
  3. ArtP Win User
    'Pin to Start' and 'Unpin from Start" items in Windows 10


    Thanks Cliff. The first suggestion didn't work because the shortcut icon is not listed. The second easier suggestion didn't work because right-clicking does not include "Open File Location" as an option, only "Unpin from Start" and "Resize". Screenshots are included. "xmltobgl" is the culprit icon.


    Windows PowerShell - Pin and Unpin Programmatically [​IMG]

    Windows PowerShell - Pin and Unpin Programmatically [​IMG]
     
  4. Mike T Win User

    Windows PowerShell - Pin and Unpin Programmatically

    Can't unpin dead link to D:\ from File Explorer - Taskbar & Start Menu

    Mouse buttons haven't been reversed, and they work fine in all other contexts (including other items on this very same pinned list in File Explorer).

    - - - Updated - - -

    Also want to add:

    I've attempted all the methods of unpinning that are listed in this tutorial:
    Pin or Unpin Items on Jump Lists in Windows 10
     
    Mike T, Oct 31, 2019
    #4
Thema:

Windows PowerShell - Pin and Unpin Programmatically

Loading...
  1. Windows PowerShell - Pin and Unpin Programmatically - Similar Threads - PowerShell Pin Unpin

  2. Can't pin or unpin apps to the taskbar!

    in Windows 10 Customization
    Can't pin or unpin apps to the taskbar!: My laptop is a Dell Inspiron 13 7000, updated to Windows 10 Home version 1083. I am having trouble pinning and unpinning apps to my taskbar. The issue is a bit hard to explain, but I will try my best to describe it. I've also attached screenshots to help clarify. When I...
  3. Problem with pinning and unpinning to start.

    in Windows 10 Support
    Problem with pinning and unpinning to start.: Hey. When I try to pin something to the start using the right click on application/folder nothing happens. It looks like it should be pinned in to the start, but nothing changes in there. The things appear in the start after the restart of OS. The same problem is with the...
  4. Pin or Unpin Items in Clipboard History in Windows 10

    in Windows 10 Tutorials
    Pin or Unpin Items in Clipboard History in Windows 10: How to: Pin or Unpin Items in Clipboard History in Windows 10 How to Pin or Unpin Items in Clipboard History in Windows 10 Copy paste its something we all do, probably multiple times a day. But what do you do if you need to copy the same few things again and again? How...
  5. Enable or Disable Pin and Unpin Apps on Taskbar in Windows

    in Windows 10 Tutorials
    Enable or Disable Pin and Unpin Apps on Taskbar in Windows: How to: Enable or Disable Pin and Unpin Apps on Taskbar in Windows How to Enable or Disable "Pin to taskbar" and "Unpin from taskbar" for Apps in Windows Windows includes a special application desktop toolbar called the taskbar that shows on the bottom of a display...
  6. Pin and Unpin People Contacts on Taskbar in Windows 10

    in Windows 10 Tutorials
    Pin and Unpin People Contacts on Taskbar in Windows 10: How to: Pin and Unpin People Contacts on Taskbar in Windows 10 How to Pin and Unpin People Contacts on Taskbar in Windows 10 Starting with Windows 10 build 16184, there is a new People Bar icon on the taskbar notification area. Whether you want to share a photo, make...
  7. Pin or Unpin Items on Jump Lists in Windows 10

    in Windows 10 Tutorials
    Pin or Unpin Items on Jump Lists in Windows 10: How to: Pin or Unpin Items on Jump Lists in Windows 10 How to Pin or Unpin Items on Jump Lists in Windows 10 [img] Information When you right click or press and hold on an app on the taskbar or Start menu, it will open the app's jump list. Jump Lists is a feature...
  8. Pinning/Unpinning Apps

    in Windows 10 Support
    Pinning/Unpinning Apps: On the Start Screen UI you can hold Ctrl + left click to select numerous items to pin or unpin at once but, it seems that's not possible on the Start Menu UI. Anyone else experience this? 3184
  9. Pin and Unpin Tabs in Microsoft Edge in Windows 10

    in Windows 10 Tutorials
    Pin and Unpin Tabs in Microsoft Edge in Windows 10: How to: Pin and Unpin Tabs in Microsoft Edge in Windows 10 How to Pin and Unpin Tabs in Microsoft Edge in Windows 10 [img] Information Microsoft Edge is a new web browser that is available across the Windows 10 device family. It is designed for Windows 10 to be...
  10. Can't Pin or Unpin to Taskbar

    in Windows 10 Support
    Can't Pin or Unpin to Taskbar: I just noticed today that I am unable to right click on an item on the taskbar making it not possible to pin or unpin. Is this happening to anyone else or is it just me? 21007

Users found this page by searching for:

  1. where do I get the powershell pin