Using Powershell to bulk change the Home folder path of AD objects - %username"?
I did just this very thing on Monday. Below is the script I used, modified for the purposes of posting here, obviously. What you're looking for, instead of %username%
is $_.SamAccountName
Get-ADUser -SearchBase "OU=Users,OU=[site],DC=[company],DC=[tld]" | % { Set-ADUser $_ -HomeDrive "H:" -HomeDirectory ('\\[dfs root]\[remote site name]\Users\' + $_.SamAccountName) }
(And yes, this does prompt for a filter value, because we don't have only users in our Users OUs. If you want to eliminate that, you'd add -Filter *
in there.)