Close Menu
Peter Klapwijk – In The Cloud 24-7Peter Klapwijk – In The Cloud 24-7
    Facebook X (Twitter) Instagram
    Peter Klapwijk – In The Cloud 24-7Peter Klapwijk – In The Cloud 24-7
    • Home
    • Intune
    • Windows
      • Modern Workplace
    • macOS
    • Android
    • iOS
    • Automation
      • Logic Apps
      • Intune Monitoring
      • GitHub
    • Security
      • Passwordless
      • Security
    • Speaking
    • About me
    Peter Klapwijk – In The Cloud 24-7Peter Klapwijk – In The Cloud 24-7
    Home»Intune»Map network drives on cloud-managed Windows devices
    Intune

    Map network drives on cloud-managed Windows devices

    Peter KlapwijkBy Peter KlapwijkNovember 2, 2023Updated:January 30, 2024104 Mins Read

    A few weeks ago I wrote an article on managing printer mappings on cloud-managed Windows devices. It’s one of the frequently heard challenges when companies move from a traditionally managed Windows device (controlled with GPOs and Configuration Managed) to a Microsoft Entra joined (Azure AD joined) Intune-managed Windows device (Modern Windows workplace).

    Another challenge in this journey is how we need to manage network drive mappings on these cloud-managed devices. Because while we are moving more and more things to the cloud, a lot of companies still have a lot of files stored on on-premises file servers. The file shares can be reached from Entra joined devices without any issue (as long as they are connected to the same network), but how do we automatically connect the network drives? And make sure these are connected when a domain connection is available?

    Like with managing printers mappings, we also need to be creative when we manage network mappings. There are multiple options to manage printers, I’ll share an example which is using scripting and Microsoft Intune.

    The Solution

    The solution I use is a PowerShell script which is triggered via a scheduled task. Every time a network change happens, several events are written under Microsoft-Windows-NetworkProfile (under operational). On event id 10000, the task is triggered.

    The scheduled starts a VBS script. The only thing the VBS script does is start another (PowerShell) script. This is to avoid any user-facing pop-ups because the scheduled task runs under Users.

    The PowerShell script that is eventually triggered, checks if the domain connection is available, and if that is the case, it connects the network drive mappings.

    A third script is involved in the solution. This script copies the other two scripts to a local folder on the device and creates the scheduled task.
    To deploy this solution, I wrapped these as WIN32 package and deployed the package with Microsoft Intune.

    The scripts can be found un my GitHub repo.

    The scripts

    Let’s have a closer look at the three scripts.

    The script whose name ends on CreateScheduledTask, creates the scheduled task as the name already shows.

    In the functions region, we define a CleanUpAndExit function, which is also used for Intune detection when wrapped as a win32 package.

    Next, we handle copying the other two scripts to a local folder. The location is defined in the variables. In my case, the location is C:\Program Files\Common Files\CompanyName\DriveMappings.

    In the last part, the script creates the Scheduled task.
    The trigger is configured to run when event id 10000 is detected under Microsoft-Windows-NetworkProfile\Operational.
    It executes wscript.exe with an argument of the vbs script.
    I used the SID S-1-5-32-545 instead of a group name, to make sure the script not only runs correct on a device running an English OS.

    This article provides some more information on configuring a scheduled task trigger using an event id.

    Then we have the vbs script whose name ends on ScriptRunFromTaskScheduler.vbs.

    As said, it only triggers the initial PowerShell script that does the actual drive mapping.

    And last we have the script whose name ends with ScriptRunFromTaskScheduler.ps1.

    First, the CleanUpAndExit function is defined. Second, a function to check the connection to the domain is defined, followed by two functions to check if the drive mapping already exists.

    In the second part, the Test-DCConnection function is used to test domain connectivity. If the connection is not available, it stops and the status is written to a log file.
    If there is a domain connection, the script tries to connect the network drive mappings, if these are not already connected.

    In the last part, a final check is done to check the end state network drive mappings.

    And that’s all to make the drive mappings available to your end users on Entra joined devices.

    In case something goes wrong in connecting the drive mapping(s), the log file can be found in %programdata%\Microsoft\IntuneManagementExtension\Logs. I chose this location so it is part of the Device Diagnostics zip folder you can retrieve remotely from your Intune managed devices. Makes troubleshooting a little easier.

    This is just an example of how we can make the drive mappings available. I hope it is useful to get you started in connecting the drive mappings.

    Below is a short video to show that on-premises resources are available, although some people still think this is not possible.

    Automation PowerShell Modern Workplace Windows Windows 10 Windows 11
    Share. Facebook Twitter LinkedIn Email WhatsApp
    Peter Klapwijk
    • Website
    • X (Twitter)
    • LinkedIn

    Peter is a Security (Intune) MVP since 2020 and is working as Modern Workplace Engineer at Wortell in The Netherlands. He has more than 15 years of experience in IT, with a strong focus on Microsoft technologies like Microsoft Intune, Windows, and (low-code) automation.

    Related Posts

    Connect to Azure file shares with Microsoft Entra Private Access

    May 24, 2024

    Logic Apps; Replace deprecated When a file is created in a folder trigger

    October 6, 2023

    Configure Windows Update for Business reporting

    June 8, 2023
    View 10 Comments

    10 Comments

    1. Khiro on November 14, 2023 11:14

      Hi,
      are you sure you haven’t made a mistake? You probably mean this applies to HybridJoin devices! EntraID Join devices are not authorized to access local resources because their UPN is not Domain\User but AzureAD\User, unless you use Entra DS or connect the local domain via gateway to Azure.
      Kind regards
      Khiro

      Reply
      • Peter Klapwijk on November 14, 2023 12:29

        Hi Khiro,

        This definitely isn’t a mistake. It is a misconception local resources are not available using Entra joined devices. When your user identities are synced from the local AD to Entra ID, resources like file shares are available as long as the device is able to reach the resources. When the device and file shares are on the same network, or for example using VPN the file shares are reachable and network drive mappings can be connected.

        Regards,

        Peter

        Reply
    2. Michael Piet on December 6, 2023 22:59

      Hi,
      Is your technique better than those offered in the below two links?

      https://github.com/nicolonsky/IntuneDriveMapping/wiki#adding-network-drive-mapping-entries

      https://call4cloud.nl/2021/03/willy-wonka-and-the-drive-letter-factory/

      Reply
      • Peter Klapwijk on December 7, 2023 20:17

        Hi Michael,

        I’m not saying one solution is better than the other. It depends on your own needs.
        The benefit of this solution is that it (re-) connects the drives at every network change to avoid ending up with disconnected network drives. In our environment, we found this more stable than deploying (and running) a script once or deploying it via ADMX.

        Regards,

        Peter

        Reply
    3. LearningIntune on December 20, 2023 04:51

      Could you please share details with how you packaged it as an Intune app? Specifically, what to enter in the install command fields, etc.

      Thank you

      Reply
      • Peter Klapwijk on December 22, 2023 19:13

        You need to wrap the 3 scripts with the WIN32 prep tool found on GitHub https://github.com/Microsoft/Microsoft-Win32-Content-Prep-Tool

        And than use an install command like PowerShell.exe -ExecutionPolicy Bypass -file .\DriveMappingsv1.0_CreateScheduledTask.ps1

        Good luck with it!

        Reply
    4. Brendan on February 9, 2024 12:12

      Hi Peter,

      Thank you for sharing these scripts. Would you recommend against creating separate tasks for each drive mapping. E.g. instead of one task with all available drive mappings, a separate task for each drive-letter? So users only get a drive-mapping if they have access to the files?

      Kind regards,

      Brendan

      Reply
      • Peter Klapwijk on February 9, 2024 13:32

        Hi Brendan,

        It doesn’t take much resources to run multiple scheduled tasks, so I don’t see a reason to not do it. Depending on your PowerShell skills you could also add some logic in one script to map a drive mapping only when the user has access. But that’s what I leave to the real PS guru’s 🙂

        Reply
        • Brendan on February 13, 2024 13:18

          Hi Peter,

          Thank you for your response, I’ll take that in mind.

          Kind regards,

          Brendan

          Reply
    5. Roger on September 5, 2024 15:33

      Spent quite many hours looking for solutions to this issue. This one is easy to setup and robust, worked right away. Thank you!

      Reply
    Leave A Reply Cancel Reply

    Peter Klapwijk

    Hi! Welcome to my blog post.
    I hope you enjoy reading my articles.

    Hit the About Me button to get in contact with me or leave a comment.

    Awards
    Sponsor
    Latest Posts

    Update Windows Defender during Windows Autopilot enrollments

    May 16, 2025

    Hide the “Turn on an ad privacy feature” pop-up in Chrome with Microsoft Intune

    April 19, 2025

    How to set Google as default search provider with Microsoft Intune

    April 18, 2025

    Using Windows Autopilot device preparation with Windows 365 Frontline shared cloud PCs

    April 13, 2025
    follow me
    • Twitter 4.8K
    • LinkedIn 6.1K
    • YouTube
    • Bluesky 1.5K
    Tags
    Administrative Templates Android Automation Autopilot Azure Azure AD Browser Conditional Access Edge EMS Exchange Online Feitian FIDO2 Flow Google Chrome Graph Graph API Identity Management Intune Intune Monitoring iOS KIOSK Logic Apps macOS MEM MEMMonitoring Microsoft 365 Microsoft Edge Microsoft Endpoint Manager Modern Workplace Office 365 OneDrive for Business Outlook Passwordless PowerApps Power Automate Security SharePoint Online Teams Windows Windows 10 Windows10 Windows 11 Windows Autopilot Windows Update
    Copy right

    This information is provided “AS IS” with no warranties, confers no rights and is not supported by the authors, or In The Cloud 24-7.

     

    Copyright © 2025 by In The Cloud 24-7/ Peter Klapwijk. All rights reserved, No part of the information on this web site may be reproduced or posted in any form or by any means without the prior written permission of the publisher.

    Shorthand; Don’t pass off my work as yours, it’s not nice.

    Recent Comments
    • Adam on Get notified on expiring Azure App Registration client secrets
    • Peter Klapwijk on Update Windows Defender during Windows Autopilot enrollments
    • Rob van de Ven on Add a certificate to the Trusted Publishers with Intune without reporting errors
    • Carl on Update Windows Defender during Windows Autopilot enrollments
    • Peter Klapwijk on The next step in a passwordless Windows experience
    most popular

    Application installation issues; Download pending

    October 1, 2024

    Restrict which users can logon into a Windows 10 device with Microsoft Intune

    April 11, 2020

    How to change the Windows 11 language with Intune

    November 11, 2022

    Update Microsoft Edge during Windows Autopilot enrollments

    July 9, 2024
    Peter Klapwijk – In The Cloud 24-7
    X (Twitter) LinkedIn YouTube RSS Bluesky
    © 2025 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.

    Manage Cookie Consent
    To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
    Functional Always active
    The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
    Preferences
    The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
    Statistics
    The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
    Marketing
    The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
    Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
    View preferences
    {title} {title} {title}