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 \\10.40.1.1\export\isos
Then it will mount the NFS server to the Z drive, but I can't access this drive in, say, File Explorer.
You need to use the Persist flag.
See https://technet.microsoft.com/en-us/library/hh849829.aspx
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:
Hope this helps,
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.
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.)The
mount
command from the command line.