Microsoft Technical Takeoff: Windows and Microsoft Intune
Oct 24 2022 07:00 AM - Oct 27 2022 12:00 PM (PDT)

Mapping legacy server shares in Intune on Windows 10 MDM

In a Windows 10 full MDM (AzureAD+Intune) scenario, you’ll move your email, app and file workloads to Office 365 (or alternatives).
In your pilot or hybrid phase, you may still need access to certain file shares on your servers, so here’s a simple PowerShell script you can deploy using Intune Device Configuration that maps your desired share. Deploy multiple times for multiple shares (or groups of users).
It will create a shortcut in a location you define, so the mapping is always user-driven, it will automatically suggest your user’s AzureAD login as username. You can of course customize the script to your liking if you did not change your local AD upn yet.
9 Replies
best response confirmed by Jos Lieben (Contributor)

I wish I saw this earlier because I ended up making my own. Looks like this one has some more feature rich than what I wrote. Great job!

Hi guys, I've had the same challenge and came up with this solution: Hope it helps you. @Kevin Kaminski

@Jos Lieben Is there a configuration that can map drives to network shared folders for SYSTEM context?


e.g. Lenovo Vantage runs as a service in SYSTEM context, and can be configured to access a custom UNC path instead of Lenovo's regular support center web site. However that means it does not use any user's credentials or Windows session, and none of their mapped drives.

@Thijs Lecomte I've learnt how to deal with it using the Scheduled Tasks avenue to map on OS startup. :) After fiddling with schtasks a while, eventually went the Powershell route because it's got more granular control over power/battery conditions.


$taskName = "MapDrive_ForSYSTEM"
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction Ignore


$stAction = New-ScheduledTaskAction -Execute "net" -Argument "use S: /persistent:yes /user:.\username password"

$stTrigger = New-ScheduledTaskTrigger -AtStartup

$stPrincipal = New-ScheduledTaskPrincipal -UserId "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount

$stSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries

$st = New-ScheduledTask -Action $stAction -Trigger $stTrigger -Principal $stPrincipal -Settings $stSettings

Register-ScheduledTask -TaskName $taskName -InputObject $st

@Jos Lieben Hi,

i try to get this drive map script to work. on that log i see error message:

PS>TerminatingError(New-PSDrive): "The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Verkkoresurssin laji ei ole oikea (with is in english something like The type of network resource is incorrect. Does someone know what that means?

Probably a DNS issue, can you ping the server you're trying to map? Can you map it manually?

You could also use a CSP to map a network drive instead of PowerShell
I posted how to do this in this blog

@Rudy_Ooms_MVP thank you! This is exactly what I've been looking for, the best solution for our environment.