Windows
View all Worklets
WindowsWindows

Windows - Configuration - Map Network Drive via Scheduled Task

Creates a scheduled task to map network drives for users at logon without requiring Group Policy infrastructure

Worklet Details

What the Network Drive Mapper does

This Automox Worklet™ creates a Windows scheduled task that maps a network drive when users log on. Because the Automox agent runs as SYSTEM and network drives exist in the user context, the Worklet uses a scheduled task approach to execute drive mapping with user credentials at logon time.

The Worklet creates a scheduled task named "Map Network Drive" that triggers on user logon. The task runs a PowerShell script that uses New-PSDrive to map the specified UNC path to the configured drive letter with the Persist flag for permanent mapping.

Results are logged to C:\ProgramData\amagent\WorkletCache\WSE-339\MapNetworkDrive.log for troubleshooting. The Worklet stores the scheduled task script at C:\Windows\temp\MapNetworkDrive.ps1 and removes any existing scheduled task with the same name before creating a new one.

Why use scheduled tasks for drive mapping

Traditional network drive mapping relies on Group Policy Preferences, logon scripts, or manual configuration. These approaches require Active Directory infrastructure or user intervention. The scheduled task approach works on both domain-joined and standalone endpoints, providing consistent drive access regardless of domain membership.

Organizations transitioning away from traditional Active Directory or managing mixed environments benefit from this approach. The Worklet provides centralized management of drive mappings through Automox without requiring Group Policy infrastructure or VPN connections during initial configuration.

The scheduled task executes in the user context, respecting NTFS and share permissions on the network resource. Users access the mapped drive with their own credentials, maintaining appropriate access controls and audit trails.

How network drive mapping works

  1. Evaluation phase: The Worklet checks the HKEY_USERS registry hive for each user SID, looking under Network\{DriveLetter} for existing drive mappings. If the specified drive letter exists and points to the correct UNC path, the endpoint is compliant. If the drive does not exist or points to a different path, remediation is triggered.

  2. Remediation phase: The Worklet validates the drive letter parameter format (single uppercase letter A-Z), creates the cache directory for logging, removes any existing "Map Network Drive" scheduled task, generates a PowerShell script for drive mapping, and registers a new scheduled task with a logon trigger that runs for all users in the Users group. The actual drive mapping occurs when users next log on.

Network drive mapping requirements

  • Windows 10 or later, Windows Server 2019 or later

  • PowerShell 5.0 or later

  • Network connectivity to the file server hosting the share

  • Appropriate share and NTFS permissions configured for target users

  • Configure $driveLetter (single letter A-Z) and $uncPath (full UNC path) variables

Expected drive mapping behavior after remediation

After remediation, the scheduled task exists but the drive does not map until the next user logon. When users log on, the scheduled task executes, verifies the UNC path is accessible, and maps the drive using New-PSDrive. The mapped drive appears in File Explorer and persists across logon sessions.

You can verify the scheduled task by opening Task Scheduler and locating "Map Network Drive" in the root task folder. Check C:\ProgramData\amagent\WorkletCache\WSE-339\MapNetworkDrive.log for execution results and troubleshooting information. If the UNC path is not accessible at logon time, the log records the failure for investigation.

How to validate map network drive via scheduled task changes

  1. Run this Worklet on a pilot Windows endpoint and review evaluation output for map network drive via scheduled task.

  2. Confirm Automox activity logs show successful completion and exit code 0.

  3. Verify endpoint state using checks aligned to evaluation script logic, such as New-PSDrive, Get-UsernameFromSID, New-Object.

  4. Validate remediation effects from script operations such as New-PSDrive, Write-Error, Test-Path, then rerun evaluation for compliance.

View in app
evalutation image
remediation image

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