Is it possible to map the disk of a Azure file share located in an Azure storageaccount using Intune?

Allan Stark 541 Reputation points
2024-02-08T21:52:35.14+00:00

Hello. We have Intune enrolled laptops for users who need to automatically mount Azure file share as a disk via a PS script.
We don't have any on-prem infrastructure or hybrid or AD DS implemented in Entra ID. This script, of course, works without problems if the user runs it himself, but how can this process be automated by Intune? We tried to run this PS script using the logged on credentials and system (the setting in Devices | Scripts in Intune) with no positive result. The PS script is standard (copied from the storeaccount connection): $connectTestResult = Test-NetConnection -ComputerName xxx.file.core.windows.net -Port 445
if ($connectTestResult.TcpTestSucceeded) {
# Save the password so the drive will persist on reboot
cmd.exe /C "cmdkey /add:"xxx.file.core.windows.net" /user:"localhost\xxx" /pass:"xxx""
# Mount the drive
New-PSDrive -Name Z -PSProvider FileSystem -Root "\xxx.file.core.windows.net\xxx" -Persist
} else {
Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
}

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Intune | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Crystal-MSFT 53,991 Reputation points Microsoft External Staff
    2024-02-09T05:39:20.29+00:00

    @Allan Stark, Thanks for posting in Q&A. From your description, I know the user can run the script manually successfully. For the user in the script, could you let us know if this is a local user or an Azure AD user?

    For the map, it will map on current logging user. So I think we need to choose log on credential and assign it to the user group when deploy it via Intune.

    As it seems not working, please check the following information:

    1. Please check what is the status of the device in the PowerShell script deployment. And see what is the user shows in the portal?
    2. Please look into Agentexecution log to see if there's any error.
    3. Follow the steps in the following link to do troubleshooting to see if there's more finding.

    https://oliverkieselbach.com/2017/11/29/deep-dive-microsoft-intune-management-extension-powershell-scripts/

    Note: Non-Microsoft link, just for the reference.

    Hope the above information can help.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.