SOLVED

Mapping legacy server shares in Intune on Windows 10 MDM

Contributor
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.
 
https://www.lieben.nu/liebensraum/2018/06/mapping-legacy-server-shares-in-your-windows-10-mdm-intune...
 
9 Replies
best response confirmed by Jos Lieben (Contributor)
Solution

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: https://tech.nicolonsky.ch/intune-execute-powershell-script-on-each-user-logon/. 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: http://127.0.0.1 /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 https://tech.nicolonsky.ch/next-level-network-drive-mapping-with-intune/ 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?
Hi

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

https://call4cloud.nl/2021/03/deliver-us-from-hybrid/

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