I'd like to mount an NFS share from Windows 2012 using PowerShell and have this mount be visible in contexts other than the PowerShell session that invoked it. If I use the New-PSDrive command (cmdlet?), e.g.:

New-PSDrive Z -PsProvider FileSystem -Root \\\export\isos

Then it will mount the NFS server to the Z drive, but I can't access this drive in, say, File Explorer.


Kernel Panic is correct about the PSDrive cmdlet being usable only within the PowerShell environment. The TechNet article ‘Using the New –PSDrive Cmdlet’ states ‘Mapped drives last only as long as your current Windows PowerShell session.’ However, you can create a configuration file that will re-map the drives every time you start PowerShell.

Further, the TechNet Article ‘Converting the Windows Script Host MapNetworkDrive Method’ also states that any drive created with the –PSDrive cmdlet ‘can be used exactly like any other mapped network drive as long as you are working in Windows PowerShell.’ This is a PowerShell Drive and not a true mapped drive. This article goes on to show that you can map drives in PowerShell using the Net Use command:

net use z: \\server\folder

Hope this helps,

| improve this answer | |
  • 2
    "‘Mapped drives last only as long as your current Windows PowerShell session." No, with the Persist flag it isn't bound to the session. – hdev Jul 14 '15 at 8:55

You need to use the Persist flag.

New-PSDrive Z -PsProvider FileSystem -Root \\\export\isos -Persist


Creates a Windows mapped network drive. Mapped network drives are saved in Windows on the local computer. They are persistent, not session-specific, and can be viewed and managed in File Explorer and other tools. The name of the drive must be a letter, such as D or E. The value of the Root parameter must be a UNC path to a different computer. The value of the PSProvider parameter must be FileSystem. To disconnect a Windows mapped network drive, use the Remove-PSDrive cmdlet. When you disconnect a Windows mapped network drive, the mapping is permanently deleted from the computer, not just deleted from the current session. NOTE: Mapped network drives are specific to a user account. Mapped network drives that you create in sessions that are started with the "Run as administrator" option or with the credential of another user are not visible in session that started without explicit credentials or with the credentials of the current user.

See https://technet.microsoft.com/en-us/library/hh849829.aspx

| improve this answer | |

My understanding is the PSDrive cmdlet, prior to Powershell 3, is a mapping between the shell and some data store. This will not carry outside of the 'shell'. Powershell 3.0 has the Persistent parameter which can do what you want.

| improve this answer | |
  • I'm running PowerShell Version 3.0 on the server. If I add the '-persist' flag, I don't see a change in behavior. – Lorin Hochstein May 20 '13 at 18:16
  • Are you running it with elevated credentials? Are they different creds than the user for whom you are mapping the share? – Kernel Panic May 20 '13 at 18:21

FWIW, the CMD mount command used to work for me until I realized that, contrary to its' documented options, it only maps credentials (be it domain, LDS or system) of the logged in user, i.e., the user that started the command.

Given the UAC control is in place, this effectively means the command only works for one's user session, in other words, if you want to use alternate credentials, you need to use runas, which itself only lasts for the CMD session.

This is despite the fact it itself supports these options: -u:username -p:*.

There was a hotfix KB2684578, but it is "no longer available".

(According to the same KB article, the net command suffers from the same fallacy.)

| improve this answer | |

The mount command from the command line.

mount <NFS_Server_IP>:<Share_Path> <Mount_Point>
| improve this answer | |
  • 1
    I believe New-NfsShare is for exporting an NFS drive, not mounting one. And, according to PowerShell, "mount" is an alias for "New-PSDrive", so I suspect the behavior is similar. – Lorin Hochstein May 20 '13 at 18:12
  • @LorinHochstein have you checked the NFS permissions on the server? – colealtdelete May 20 '13 at 18:16
  • The permissions seem to be OK, as far as I can tell. The mount does work, it just only works within the PowerShell session that it was invoked in. – Lorin Hochstein May 20 '13 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.