First post here, hopefully many more to come..
So I'm writing a script for our Account team that will be called behind a Windows Forms GUI. The Script is supposed to do the following:
- Build AD User
- Build Home Folder
- Set Home Folder Permissions
- Add AD Groups
Everything works fine when I'm setting the permissions on a file server that's local. Where it breaks down is when I try to run it and the Home Folder is supposed to reside on a more remote file server.
We have somewhere around 10-15 servers for Home Folders and another 10 or so DCs. The replication on the more remote servers is set to 15 minutes I believe. The problem arises when I bulid the AD account on a local DC and the Home Folder on a remote file server, that's talking to a remote DC.
The way I see it, I have two options:
1. Build the AD account on the remote DC that the file server is talking to. The question then arises, how do I find out in PowerShell, what DC a giver server is talking to?
2. Force a broken SID onto the Home Folder. I can get the SID easily as I build the account, but I can't seem to find a way to force that onto the Permissions without it trying to resolve it first.
I'm also attaching a copy of my script for reference.. it errors out somewhere on or after the $accessrule line towards the bottom.
Any thoughts?