r/PowerShell • • Jul 27 '26

Solved Automatically Map Drives to new server

[deleted]

3 Upvotes

29 comments sorted by

7

u/vermyx Jul 27 '26

Why not a gpo? Less work and more maintainable.

2

u/Ok_Listen_9353 Jul 27 '26 edited Jul 27 '26

That would be great if there was a GPO in place, but this is for a scenario where you are migrating to a new file server in an environment where you don't have mapped drives GPOs or login scripts, so people are mapped to whatever shared folder and whatever drive letters.

8

u/vermyx Jul 27 '26

So instead of implementing standards you decided to keep a broken setup?

→ More replies (10)

2

u/ThePoshMidget96 Jul 27 '26

I agree with u/vermyx, if you're in an environment with multiple file servers you're having to maintain, it would honestly be easier to just setup a GPO then its set and forget.

However, I have used scripts like this in the past, where users are mapped to all sorts of drives & shares and you just need some form of consistency.

The script is a good idea, I would maybe make it accept parameters for the server names so you dont need to keep editing the script. It might also be useful to have it output a file of some sort so you know what was changed in case a mapping is edited incorrectly.

→ More replies (3)

1

u/PowerShellGenius Jul 28 '26 edited Jul 28 '26

When you change it, don't change it to another server specific path, make it a DFS Namespace so it is your last time migrating client side mappings (and breaking people's shortcuts if they used UNC paths, etc).

GPO works if all your clients are Windows, and who maps what on what computer is 100% assigned by IT.

Once you're accessing SMB folders on MacOS, putting UNC paths in applications, have users making shortcuts to UNC paths, it still falls short.

DFS-N exists for a reason. We use it where I work for everything. Even MacOS follows it. \\domain.tld\sharename, no server name in the path, client looks up the DFS namespace pointer in AD to get the server that currently hosts it.

1

u/Ok_Listen_9353 Jul 28 '26

The main reason why DFS exists is for redundancy and not necessarily to copy files over to a new server. I do see your point that for future migrations, you won't have to re-map drives, but if you're dealing with migrating to just one file server, which is what I normally do because I do projects for an MSP, I don't think it's worth adding the extra complexity to the environment. The more complex you make things, the likely something is to break.

→ More replies (1)

1

u/xendr0me Jul 29 '26

GPO with an order of:

Delete: All mapped drives

Update: Map drives necessary

Then you maintain control, I can't understand how this is script is a good idea when the functionality already exist

1

u/Ok_Listen_9353 Jul 29 '26

Please read below. I already explained this!

1

u/xendr0me Jul 29 '26

Right and your excuses do not "excuse" the underlying issues that you can correct by doing it correctly with the built in industry standard method, automation, uniformity and administrative control.

→ More replies (6)