The last few days I’ve been working with Powershell. Primarily to simplify and verifying the procedure for creating new file servers in a customers environment.

Metadata is stored in desktop.ini (you might have noticed these files on your Desktop or in Windows folders).
The idea behind this function is to customize folders. In my case I needed to make sure that the file path does not contain spaces, yet show user friendly folder names to the end user.

I solved this with adding metadata to the folders.

As you can see on the screenshot below the Path is C:\DATA\MyProject, but the end-user is shown My Awesome Project when they browse via Explorer. You can also change icons and much more…


(these are set during the function)

  • The target folder needs to have System attribute set. (attrib +s)
  • Desktop.ini needs to have System and Hidden attributes. (attrib +s +h)

I created the function below to write metadata and set the desktop.ini attributes.

## Function to create metadata ##
# R = Location to Root folder (D:\DATA\MyProject).
# F = Name of the folder. (My Awesome Project)

Function Metadata ($R,$F) {
    $MetaFile = $R + '\desktop.ini'
    $M1 = "[.ShellClassInfo]"
    $M2 = "LocalizedResourceName=" + $F
    $M3 = "FolderType=Documents"
    $M1 | Out-File $MetaFile
    $M2 | Out-File $MetaFile -Append
    $M3 | Out-File $MetaFile -Append
    attrib +s +h $MetaFile
    attrib +s $R
# Metadata C:\DATA\MyProject "My Awesome Project"

If this worked for you if you need help implementing the function or metadata send us a message below.