I want to access a remote SMB network share \\SHARE-HOST\
without mapping a drive letter. I can manually do it in windows by typing \\SHARE-HOST\Share_folder\
in explorer. If I want to do it programatically I have to use the net use
command. This requires me to specify a letter.
Windows – Access network share without mapping drive letter (PowerShell)
drivenetwork-sharepowershellwindows
Related Topic
- Windows – Permanently mount network share without the need for log on? (Windows)
- Windows – Why do “net use” and windows “map network drive” share have a drastic speed difference
- Powershell – Map Network Drive to a WebDAV Server via PowerShell
- Windows – Correct way to access a network share in a Windows service
Best Answer
PowerShell fully supports UNC paths; you can use them everywhere a directory or file name would be expected:
Set-Location \\servername\sharename
Get-ChildItem \\servername\sharename
Copy-Item \\servername1\sharename1\filename.ext \\servername2\sharename2
Remove-Item \\servername\sharename\foldername\filename.ext
However, you need proper access rights to actually connect to the remote share; this means either your user account must already have the required permissions, or you must manually establish a network connection to the remote server before accessing folders and files on it.
See also here: https://stackoverflow.com/questions/303045/connecting-to-a-network-folder-with-username-password-in-powershell.