Drive mapping created using New-SmbGlobalMapping is lost when the system is rebooted. In addition, the drive mapping is not visible within file explorer

stephengau 1 Reputation point
2021-10-13T12:17:02.66+00:00

There is a VM running in Azure and the applications running on that VM need be able to access an Azure file share, as do users who logon to the server. The definition of the drive needs to be set and then continue to be defined even if the server is restarted.

We used the powershell New-SMBGlobalMapping cmdlet to define a drive that maps to the Azure file share. Powershell is started as administrator and the variable for url, cred are defined and the following command is executed

New-SmbGlobalMapping -RemotePath $url -Credential $cred -LocalPath R: -FullAccess @( "NT AUTHORITY\SYSTEM", "NT AUTHORITY\NetworkService", "Administrators" ) -Persistent $true -RequirePrivacy $true

The drive is successfully created within the powershell window

Status Local Path Remote Path


OK R: \****************.file.core.windows.net\test

There are two problems when using this command:-

  • Whilst the drive can be seen within a powershell window or within a regular windows command prompt the drive is not visible within windows explorer
  • the drive mapping is lost when the VM server is restarted

Can you please advise what needs to be done to meet our needs and overcome the two problems that have been outlined

Thanks
Stephen

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,363 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. deherman-MSFT 37,851 Reputation points Microsoft Employee
    2021-10-13T20:11:51.797+00:00

    @stephengau
    I tested using the script provided from the portal which uses New-PSDrive. The mount was persistent when rebooted and visible in File Explorer. Please try mounting the share with this method and see if it resolves your issue. Instruction for obtaining the script can be found here. Alternative you can try mounting the share via File Explorer.

    Hope this helps! Let us know if you are still facing issues or need further assistance.

    -------------------------------

    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

  2. stephengau 1 Reputation point
    2021-10-14T02:13:52.563+00:00

    @deherman-MSFT Thanks for your response.

    I tried the New-PSDrive script which did make the drive visible in file explorer, but it did not persist the mapping across server restarts.

    This is the command that has the Persistence and Global flags set

    "New-PSDrive -Name K -PSProvider FileSystem -Root $url -Persist -Credential $cred -Scope Global"

    My understanding of the persistence flag may be wrong as I assumes it means it continues even when the server is restarted. Please let me know if persistence means something else

    0 comments No comments

  3. stephengau 1 Reputation point
    2021-10-14T07:28:04.017+00:00

    Spoke with the team and their concern was that the New_PSdrive cannot be used for the non-interactive accounts. The user that sets the mapping can use the mapping but other accounts cannot. This prevents system services and other accounts from using the New_PSdrive command to define the mapping.

    On the other hand, the SMBGlobalMapping command allows drives to be mapped and then used by other accounts.


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.