Writing a long, quality script can be both a tiresome and interesting task in terms of its look and feel. It’s been quite a while since I last wrote a substantial script, as I’ve mostly been occupied with small utility scripts in my work. Today, I completed a very useful script that joins local users to domain users with automatic profile migration for the current user. This ensures the retention of current local user settings, such as wallpaper, Internet Explorer settings, Power Option Settings, and desktop items, in their new domain environment. Optionally, you can choose not to migrate.For bulk deployment, you can compile the script to .exe with PowerGUI to bypass Powershell Execution Policy.
What this script will do:
1) It will check connection to 2 DNS servers listed in script header section.
2) If DNS Check is OK, it will check DNS settings of your machine network adatpers against the IP addresses listed in script header section. If not match, it will prompt the user & try to change the DNS settings. If you have multiple network adapters it will ask for each adapter.
3) If the DNS settings is not changed, the script will show errors for Administrator permission and exits.
4) It will ask for user approval and then it will join to domain.
5) If domain join is succeed, it will ask the user to migrate current user’s profile to new domain user’s profile.
6) If the user choose to migrate current profile, the current user’s SID and new domain user’s SID are backup to txt file in user’s
7) After that it will prompt the user to restart the computer.
Supported from powershell v2.0. Tested on Windows7, Server2008R2. Not supported in Windows 10 because it ends up with a flickering screen after login. So, for windows 10, you can use USMT tools instead.
If running script is disabled on this system..” error occurrs, you need to change the execution policy in powershell as below.
Open the elevated powershell console and type Set-ExecutionPolicy Unrestricted
You can download my script from github.