Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

How can I change the servername and pathname in the home folder path in AD?

$
0
0

Is there a script that can change the servername and the pathname in the home
folder path in AD? User accounts are located in a single OU. We
migrated to a new file server. The domain controllers are Windows
2008.

Old home folder path:
\\old-server\share\username

New home folder path:
\\new-server\share$\username

We followed the below procedure,

Import-Module ActiveDirectory

$oldServerName = "twenty"
$newServerName = "thirty"


[array]$AllUsers = Get-ADUser * -Properties HomeDirectory

foreach($user in $AllUsers){

if(($user.HomeDirectory.ToString()).contains($oldServerName)){
$homeDirectory = ($user.HomeDirectory.ToString()) -replace $oldServerName, $newServerName
Set-ADUser $user.DistinguishedName -HomeDirectory $homeDirectory
}

}

It is not working since we need to change both the servername and sharename. We DONT want to change the user name. Any help will be appriciated

give any solution without any software.


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>