Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

Script to change home directory

$
0
0

I need to substitute a server address with a DFS one in each user's home directory. Unfortunately only a portion of the string is constant. Bellow is an attempt in Powershell that works but is clumsy. Is there a better way?

$hdir = (Get-ADUser bguest -Properties *).HomeDirectory
$hdir = $hdir -replace "\\\\.*\\", "\\\\ad.company.com\\lfl\\"
$hdir = $hdir -replace "\\", "-"
$hdir = $hdir -replace "--", "-"
$hdir = $hdir -replace "-", "`\"
Set-ADUser bguest -HomeDirectory $hdir

Any pointers are greatly appreciated



Viewing all articles
Browse latest Browse all 31638

Trending Articles



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