Forum Discussion
AAD joined laptops - mapped drive script not working
All our company laptops (Win10/11) are currently AD Hybrid joined and each users has an AOVPN to allow remote working. User document folders are redirected to a central file share. Via GPO, we also push out some mapped drives. We are looking to move away from the AD Hybrid Joined workstation model and want to use Azure AD joined laptops (ie: slowly moving to full cloud).
We have deployed a bunch of new Windows 11 laptops (AAD joined) using Autopilot. All the necessary apps, config profiles, scripts, etc have been pushed out to these new laptops via Intune. Everything appears to be working well, with exception to one of the drive mappings (T:\ drive which points to the users redirect documents folder). All other mapped drives, ie: S:\ > Company Shared, M:\ > Marketing, etc are allow working via a Intune ps script.
The user powershell script we're using (in Intune) to map the T:\ drive is as follows, however, its not working.
New-PSDrive -Name "T" -Root "\\server1.domain.local\User Redir\$Env:UserName\Documents" -Persist -PSProvider FileSystem
If we manually run this on the laptop, via powershell and while logged in as the user, the command complete successfully. The Intune ps script is set to 'user' and 'script signature checking' is disabled.
For reference purposes, the older AD hybrid joined workstations use a GPO (ie: net use T: \\server1.domain.local\User Redir\%username%\Documents ).
Can anyone see where we have gone wrong or suggest how we can map the T: drive, to the users redirected folder, via Intune?
PS - Eventually, we will be moving user document folders to OneDrive but the company isn't ready for this yet.
- Mmmm as mentioned in the blog post.... when you are using the admx ...
To make sure you can use the %username% you will need to add this expandable=”true” to each element in the ADMX you ingested!
The last time i used it, it worked?
- You could switch to importing an admx to mount those driveletters?
https://call4cloud.nl/2021/03/willy-wonka-and-the-drive-letter-factory/
To get back to the question and The error you are referring, i have seen some weird stuff in which the local user is a local admin on the device... so... is the user a local admin?- PhilPreece1010Copper ContributorThanks for the reply.
We have tried importing the admx template and pushed out the drive mappings via a Config Policy. It works for the standard drive mappings, ie:
M:\ > \\server1\marketing (works)
S:\ > \\server1\CompanyData (works)
T:\ > \\server1\User Redir\%username%\Documents (does not work)
It seems Intune has trouble with the %username% and/or $Env:UserName variable.- Mmmm as mentioned in the blog post.... when you are using the admx ...
To make sure you can use the %username% you will need to add this expandable=”true” to each element in the ADMX you ingested!
The last time i used it, it worked?