Jump to content

Using a UNC path to map a drive in Windows Server

Hello, I'm trying to map a network drive in my Windows Server using a UNC path for a user using the following script.

$uncServer = "\\192.168.xx.xx"
$uncFullPath = "$uncServer\Daily" // Daily is the folder name 
$username = "domain\user"
$password = "passwd"

net use * $uncFullPath /u:$username $password

When i try this script I receive the following error

System error 53 has occurred.

The network path was not found.

03/10/2020 - INFO: ----------------------
03/10/2020 - INFO: Start the Script
03/10/2020 - Error: \\192.168.xx.xx\Daily does not exist

I have confirmed that this network path is available even though the error states that it doesn't exist. It can also be pinged.

 

I have been looking around to resolve this for a few hours now and had no luck. It would be helpful if you could suggest a point to troubleshoot and check. Thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

Does the user account mounting the share have both share permissions and NTFS permissions to do so?

 

Check by mapping it manually and specify the username password you're trying to use.

image.png.294467f2e96b3da32ebfb2c7f3daec29.png

 

Also generally (almost always) it's not a good idea to map drives using scripts anymore and putting passwords in clear text in scripts. Ideally you'd have a AD Domain and use Group Policy but that's a bit much if you have a single server and never intended to run a AD Domain.

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, leadeater said:

Does the user account mounting the share have both share permissions and NTFS permissions to do so?

 

Check by mapping it manually and specify the username password you're trying to use.

image.png.294467f2e96b3da32ebfb2c7f3daec29.png

 

Also generally (almost always) it's not a good idea to map drives using scripts anymore and putting passwords in clear text in scripts. Ideally you'd have a AD Domain and use Group Policy but that's a bit much if you have a single server and never intended to run a AD Domain.

Yes I can confirmed that it is possible to map it manually and I have given full permission to the user that I'm trying to map it to.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Shammikit said:

Yes I can confirmed that it is possible to map it manually and I have given full permission to the user that I'm trying to map it to.

 

 

 

Does the share server have NetBIOS? Have you tried by the NetBIOS name/hostname? 

 

Check the Group Policies on the server and ensure that "Network Security: Restrict NTLM: NTLM authentication in this domain" isn't enabled.

It's in Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options

I imagine you can just do a gpresult /h C:\report.html on the server. 

Spoiler

Desktop: Ryzen9 5950X | ASUS ROG Crosshair VIII Hero (Wifi) | EVGA RTX 3080Ti FTW3 | 32GB (2x16GB) Corsair Dominator Platinum RGB Pro 3600Mhz | EKWB EK-AIO 360D-RGB | EKWB EK-Vardar RGB Fans | 1TB Samsung 980 Pro, 4TB Samsung 980 Pro | Corsair 5000D Airflow | Corsair HX850 Platinum PSU | Asus ROG 42" OLED PG42UQ + LG 32" 32GK850G Monitor | Roccat Vulcan TKL Pro Keyboard | Logitech G Pro X Superlight  | MicroLab Solo 7C Speakers | Audio-Technica ATH-M50xBT2 LE Headphones | TC-Helicon GoXLR | Audio-Technica AT2035 | LTT Desk Mat | XBOX-X Controller | Windows 11 Pro

 

Spoiler

Server: Fractal Design Define R6 | Ryzen 3950x | ASRock X570 Taichi | EVGA GTX1070 FTW | 64GB (4x16GB) Corsair Vengeance LPX 3000Mhz | Corsair RM850v2 PSU | Fractal S36 Triple AIO + 4 Additional Venturi 120mm Fans | 14 x 20TB Seagate Exos X22 20TB | 500GB Aorus Gen4 NVMe | 2 x 2TB Samsung 970 Evo Plus NVMe | LSI 9211-8i HBA

 

Link to comment
Share on other sites

Link to post
Share on other sites

Is there a reason you don't use the GUI to map the network share to the user as Leadeater suggested?

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×