powershellactive-directorygroup-policy

I need to replace the path to a mapped network drive at a scheduled time. How do I do it?


I need to replace a mapped network drive for a handful of users at the same time.

I need to make the switch because of a migration to a new server.

Old: \\server1\path New: \\server2\path

The drive letter and anything else will remain the same.

I need to have this occur at or around a specific time this Friday. Any suggestions that would rely on the user's stored credentials and not me knowing their password?

I wanted to use Group Policy, but this is not guaranteed to be accurate in timing. I can't have users using the new server before it's up or using the old server when it's been shut down.

A Scheduled task would work and then pushing it through Group Policy would be great, but then how do I replace the mapped drive for each user on their profile without needing their login info.

This should work:

New-PSDrive -Name $Name -PSProvider FileSystem -Root $NetworkPath -Description $Description -Persist

But I need to run it as the user or at least against the user's profile, but I don't want to use their passwords to accomplish this.

There has to be a way for an Admin to do this.

Edit: I created a GP to add the drive using the old server and added a second one to add the drive using the new server and disabled it. I'm the only one in the group for testing. I've also adjusted the Default Domain Policy to refresh policy instantly. I am getting it to work when I force policy. But only when I force policy. This just seems too slow.


Solution

  • Not strictly a code question, no, but I would suggest the following:

    That's all off the top of my head, so the detail may be the fun part, but hopefully the outline helps. You were on the right track, essentially.