blue windows wallpaper
Azure DevOps PowerShell Scripts Windows

Script to add to Windows Explorer Quick Access

There are times when building machines that I need to add to the Quick Access menu in Windows Explorer as it’s convenient. You can use this script as part of your build process to save you from adding them every time a new server is built.

Below is the script, add to the list of paths and then add the variable name to the array.

# Define the Folders to pin to Quick Access in the list below
$FredsFolder = "C:\FredsFolder"
$DebbiesFolder = "C:\DebbiesFolder"
$ToolsFolder = "C:\Tools"

#Add these to an Array
$quickaccessmenu = @($FredsFolder, $DebbiesFolder, ToolsFolder)

$quickaccessmenu | ForEach-Object {
    $folder = $_
    $obj = new-object -com shell.application
    $quickaccessitem = $obj.Namespace("shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}").Items()      | Where-Object {$_.Path -eq "$folder"}
    $quickaccessitemsexists = $null -ne $qaitem
    if (!($quickaccessitemsexists)) {
        $obj = new-object -com shell.application
        $obj.Namespace("$folder").Self.InvokeVerb("pintohome")
}

And that’s about all there is to it. Enjoy!