View all Worklets
Windows

Disconnect Mapped Drives

Unlinks all user-associated mapped drives on a endpoints.

Worklet Details

Introduction to the PowerShell Based Disconnect Mapped Drives Worklet

The Disconnect Mapped Drives Worklet is a PowerShell-based script designed for Windows operating systems. It provides a seamless and efficient way to disconnect specified mapped drives for all users on a device. A mapped drive is an active network connection that appears as a drive letter in File Explorer, allowing users to access files and folders on remote data storage devices like web servers or FTP servers over a local area network.

Why would you use the Disconnect Mapped Drives Worklet?

There are several reasons why one might need to use the Disconnect Mapped Drives Worklet. For instance, when network locations become outdated or obsolete, it's essential to remove these connections to maintain system security and performance, and reduce clutter in File Explorer.

Components of the Disconnect Mapped Drives Worklet

The main components of this Worklet include an evaluation code section and a remediation code section. The evaluation code checks if there are any matching mapped drives specified by "$removeDrives" variable for all user accounts on the device. If it finds any, it returns an exit code of '1' to trigger remediation.

The remediation code actively performs the disconnection of specified mapped drives from all user accounts on the device. To customize this Worklet for your needs, simply add desired parameters to "$removeDrives" line at the top of both evaluation and remediation codes.

How does the Disconnect Mapped Drives Worklet work?

This Worklet retrieves user details including SIDs (Security Identifiers) from Windows systems running version 8 or higher and loads them into HKEY_USERS registry keys for easy access later in the script execution process.

It then loops through each user account's registry key searching for specified mapped drives to disconnect. If a matching drive is found, the Worklet removes it by deleting the associated registry key. The final step is to clean up and remove the temporary files created by the Worklet.

What is the expected outcome when you use the Disconnect Mapped Drives Worklet?

When this Worklet is executed successfully, specified mapped drives will be disconnected from all user accounts on the target device. However, it's important to note that these drives may not appear disconnected until after a system reboot.

The Disconnect Mapped Drives Worklet offers an efficient, customizable and secure method for managing network location mappings on Windows systems. It can help administrators maintain optimal system performance and security while saving time and effort in disconnecting outdated or unused mapped network drives.

View in app

Consider Worklets your easy button

What's a Worklet?

A Worklet is an automation script, written in Bash or PowerShell, designed for seamless execution on endpoints – at scale – within the Automox platform. Worklet automation scripts perform configuration, remediation, and the installation or removal of applications and settings across Windows, macOS, and Linux.

do more with worklets