We upgraded to the latest and greatest DirSync version. As I soon found out, the old way of scripting and executing the replication via “DirSyncConfigShell.psc1” has been replaced with:
import-module dirsync
Start-OnlineCoexistenceSync
However, any chance I try to put this in a remote session (via invoke-command / new-pssession / enter-pssession / import-pssession / etc…) they all hang once I attempt to import the module. Has anyone had a chance to review how to write a script to make replication happen at will as oppose to waiting for the next interval?
I think the real problem is that the module import is hanging - you might try importing it with -verbose and see if you get any details about what it’s doing. Otherwise, tearing into the module and seeing what-all it’s doing on load would be the next step.
So, something in ImportModules.ps1 is breaking it. You’re going to need to open that script and see what it’s doing that might be problematic in a remote session.
Step 1 - turned on “-verbose” and found that it was hanging at dot-sourcing the file
Step 2 - ran each command on the dot-source’d file and found this error which lead me to believe it was .net framework issue:
“This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded powershell”
Step 3 - When in doubt, Google. I found registry entries I could put in that would allow me to run this module.
Here is my final script. Basically putting reg entries in, run commands, then take them back out:
[hr]
reg add hklm\software\microsoft.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1
reg add hklm\software\wow6432node\microsoft.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1
Invoke-Command -ComputerName SERVER -ScriptBlock { import-module dirsync -verbose; Start-OnlineCoexistenceSync }