Struggling to Map Network Drive with GPO – Any Tips?

0
7
Asked By TechWanderer85 On

I'm having trouble mapping a company drive at one of our new offices. The issue is that while it seems like the mapping works, the drive doesn't show up in my File Explorer. Both of our offices are connected through a site-to-site VPN, and I can connect to the file server just fine. I've managed to run some .bat and .ps1 scripts manually while logged in, but when I try to automate the mapping through GPO or an AD Logon script, it just doesn't show up in File Explorer.

I've added a -NoExit switch in my PowerShell script, and I can see the correct drive letter and root location when I run it, but still no luck. I even tried copying the script locally via GPO and executing it, but that didn't work either. I've looked everywhere online and tried following various advice, but nothing has helped so far. I've experimented with suggestions that involved using %LogonDomain%\%LogonUser% with scheduled tasks, but that yielded no results.

I've checked both Computer and User configuration via GPO, and running `gpupdate /force` alongside `gpresult /r` confirms that the GPO is applied to my account. Event Viewer shows no errors, but if I run the script multiple times in one session, it throws an error about the drive being in use, even though it doesn't appear in the list when I run `net use`. Despite the registry showing the mapping under HKCU\Network\, it still doesn't show in File Explorer.

Here's the PowerShell script I've been using:

```powershell
$User = "*******"
$PWord = ConvertTo-SecureString -String "***********" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
New-PSDrive -Name "W" -Root "\192.168.100.11Company Shared Folders" -Persist -PSProvider "FileSystem" -Credential $Credential
```

Any suggestions on how I might resolve this would be greatly appreciated!

4 Answers

Answered By CuriousDev77 On

Why are you using a script for this? Have you tried the Group Policy Preference drive map feature instead? It’s usually a lot simpler.

Answered By ScriptingSage45 On

It looks like you might be using the wrong command. `New-PSDrive` can create a mapping but it might not always show up as you expect. A better option is to use `New-SmbMapping`. Also, you probably shouldn't need to pass credentials from a domain-joined machine. If you use the server's DNS name instead of the IP address, it should utilize Kerberos authentication, which makes it easier if the user has permission. You may want to fix that authentication issue instead of going around it with a script.

TechWanderer85 -

Thanks for that suggestion! Since the drive is on a different domain, we're trying to avoid needing a VPN client every time we want to connect. I will definitely check out the `New-SmbMapping` command. Appreciate the help!

Answered By NetworkingNinja23 On

Just a heads up, if you're trying to map a drive to a network share on a different domain that requires credentials, using the built-in GPO drive map feature might not work. That’s why your script is necessary for external shares that require logins. Just make sure you're accounting for authentication issues when automating through GPO for external networks.

Answered By HelpfulTechie92 On

It sounds like you're facing some GPO or permission issues. A lot of times with GPO, it's just a matter of not deploying it correctly. I recommend using the built-in functionality for drive maps via User/Computer Preferences in GPO instead of scripting it. Run the GP Modeling Wizard to confirm that the GPO is applying to the intended machines/users, and then use `gpresult` to check if it's actually being applied properly. It might also help to get your script to log its output to a text file so you can catch any errors when mapping the drive.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.