• Comments 2

The other day I showed you how you can use ENUMs.  I showed an example of how you can find all the SPECIALFOLDERs on a system.  Here is a script that I call Mount-SpecialFolders.ps1 which mounts all your special folders as PowerShell drives.


# Mount-SpecialFolders.ps1
param($Folder="*", [SWITCH]$Verbose, [SWITCH]$PassThru)
foreach ($f in [Enum]::GetValues([System.Environment+SpecialFolder]) |where {$_ -like $Folder}) {
    $drive = New-PSDrive -Name $f -PSProvider FileSystem -Root ([Environment]::GetFolderPath($f)) -Scope Global -ErrorAction SilentlyContinue -Verbose:$verbose
    if ($PassThru)
        Write-Output $drive


Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:
Visit the Windows PowerShell ScriptCenter at:

Leave a Comment
  • Please add 4 and 7 and type the answer here:
  • Post
  • This is a very useful little script. Thank you!

  • Very nice, THX!

    Too bad Environment.SpecialFolder enumeration does not contain all special folders.

    So I had to do a little extra work - slightly modified the function and run:

    $a = New-Object –com Shell.Application

    MountFolder "AllUsersDesktop" ($a.namespace(0x19)).Self.Path

    MountFolder "AllUsersStartMenu" ($a.namespace(0x16)).Self.Path


    Btw, hex values can be taken from VBScripts

Page 1 of 1 (2 items)