Recently, I had been asked by the colleague to help them troubleshoot the issue where User Profile Synchronization service would hang during the attempt start.
There were no error logs except that it would return to Stopped state. We found out that if the account that you login is the same account that you run the User Profile Synchornization Service and that account has a powershell profile, then it causes the issue. It appears that during the start process of the UPS Synch service, it runs the PowerShell runspace with the default shell as opposed to creating its custom shell, so default profiles in your documents folder would be loaded. Thus, the issue.
Best way to resolve is to ensure that even in your dev environment, you must make sure that you’re not running your interactive shell with the account that’s running SharePoint services processes.