New DirSync Module

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

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.

It’s always the little things you forget about while troubleshooting. Thanks for the “verbose” reminder. Here is where the script is getting stuck:

PS C:\Users\username> Invoke-Command -ComputerName SERVER -ScriptBlock { import-module dirsync -verbose; Start-OnlineCoexistenceSync }

VERBOSE: Loading module from path ‘C:\Windows\system32\WindowsPowerShell\v1.0\Modules\dirsync\dirsync.psd1’.
VERBOSE: Loading module from path ‘C:\Windows\system32\WindowsPowerShell\v1.0\Modules\dirsync.\ImportModules.ps1’.
VERBOSE: Dot-sourcing the script file ‘C:\Windows\system32\WindowsPowerShell\v1.0\Modules\dirsync.\ImportModules.ps1’. <-- Script hangs here

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.

Your the man!!! I got it. Here is what I found:

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:
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 }

reg delete hklm\software\microsoft.netframework /v OnlyUseLatestCLR /f
reg delete hklm\software\wow6432node\microsoft.netframework /v OnlyUseLatestCLR /f

Thanks again for your guidance. Life saver!!!