How do I modify HomeDirectory paths to include domain names?

0
4
Asked By TechieGamer92 On

Hey everyone! I'm trying to update the HomeDirectory property in our setup, which currently looks something like this: \[servername][username]$. I'd like to change the [servername] to [servername.domain.com]. What's the best way to go about this? I was thinking of searching for the [servername] part between the two backslashes and replacing it with the domain format. Would it be easier to export all the AD users with their home directories to a CSV, modify them there, and then re-import the updated values? I'd appreciate any guidance on this!

4 Answers

Answered By RegexNinja On

To clarify, could you provide some current path names and what you want them to look like? Using `-replace` with a well-structured regex seems like the best approach.

Answered By ScriptWizard99 On

That sounds like a solid plan! I actually created a function that helped me extract the server name and then added the domain name before setting it. Here's how I approached it: I used a regex pattern to find the server name between two backslashes and then appended '.domain.com' to it. Just remember to add a check to prevent adding multiple domain suffixes—that's a headache waiting to happen!

Answered By CuriousCoder On

Just a heads up, I’m not sure if that naming convention is officially supported for home directories. I’ve not seen anyone using it like that.

Answered By PowerShellDynamo On

If your server name is unique, you could do something like this: `$HomeDirectory -replace "File01","File01.contoso.com"` where `$HomeDirectory` holds the current value. Make sure to output all new values to verify before you make any changes—better safe than sorry!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.