Create Folder on Windows devices
  • 02 Feb 2024
  • 1 Minute to read
  • PDF

Create Folder on Windows devices

  • PDF

Article summary

The following PowerShell script helps the IT Admins to create folder shortcuts on the deskop for easy access on their managed Windows devices.

  1. Create a file on your desktop, for example, folder_shortcut.ps1 and open it in a text editor like notepad++

  2. Copy the contents below to the file or click here to download the file.

    1. $path = "C:\": This line assigns the value "C:" to the variable $path, representing the root of the C drive.

    2. New-Item .\SupportFolder -ItemType Directory -Force: This line creates a new folder named "SupportFolder" in the current working directory (which is assumed to be the C drive in this case). The -Force parameter ensures the folder is created even if it already exists.

    3. $wshshell = New-Object -ComObject WScript.Shell: This creates a Windows Script Host object to interact with Windows features like shortcuts.

    4. $desktop = [System.Environment]::GetFolderPath('Desktop'): This gets the path to the user's desktop.

    5. $lnk = $wshshell.CreateShortcut($desktop+"\ShortcutName.lnk"): This creates a new shortcut object named "ShortcutName.lnk" on the desktop.

    6. $lnk.TargetPath = "c:\SupportFolder": This sets the target path of the shortcut to the "SupportFolder" that was created earlier.

    7. $lnk.Save(): This saves the shortcut to the desktop.

      $path = "C:\" 
      New-Item .\SupportFolder -ItemType Directory -Force 
      $wshshell = New-Object -ComObject WScript.Shell 
      $desktop = [System.Environment]::GetFolderPath('Desktop')   
      $lnk = $wshshell.CreateShortcut($desktop+"\ShortcutName.lnk") 
        $lnk.TargetPath = "c:\SupportFolder" 
        $lnk.Save()  
      Write-Host "Folders and Shortcut created!" 

Your You can change the name of the folder in the line as below in the script.

New-Item .\SupportFolder -ItemType Directory -Force

Follow our guide to upload & publish the PowerShell script using Scalefusion Dashboard.

Please note that to use the PowerShell scripts, the Scalefusion MDM Agent Application must be installed on the device(s). Please follow our guide to publish and install the Scalefusion MDM Agent Application.

Notes:

  1. The scripts and their contents are sourced from various albeit authenticated Microsoft sources and forums.

  2. Please validate the scripts on a test machine before deploying them on all your managed devices.

  3. Scalefusion has tested these scripts, however, Scalefusion will not be responsible for any loss of data or system malfunction that may arise due to the incorrect usage of these scripts.


Was this article helpful?