I am a fan of Ryan Newington’s MIM PowerShell modules, I think they are like the missing tools that Microsoft should have provided in the box from day one. Sometimes though, for various reasons, we may not have approval or access to use 3rd party or open source code, or other tools may expect exports to be in a specific format.
Using the FIMAutomation PSSnapin is easy … on servers with the MIM Service installed. There are several documented methods for copying the FIMAutomation PSSnapin files to another machine and registering them, but they all require local admin access and access to the required files on the server.
For example, I’m working in a locked-down development environment with no file copy in/out, no internet access, just work with what is currently there. I have limited access on the servers and management VM, with only access to 7-Zip (thankfully!) and a recent hotfix roll-up for MIM (4.4.1459.0)
Handily, PowerShell has already addressed this problem. Working from Learn how to load and use PowerShell snap-ins it seems simple enough to create a module to wrap around the snap-in.
Opening the hotfix roll-up FIMService_x64_KB4012498.msp in 7-Zip reveals a CAB with the files we need.
We’re looking for:
- Microsoft.IdentityManagement.Logging.dll
- Microsoft.ResourceManagement.Automation.dll
- Microsoft.ResourceManagement.dll
But there are no exact matches, so I guessed a little, extracted these files and renamed them:
- Common.Microsoft.IdentityManagement.Logging.dll
- Common.Microsoft.RM.Automation.dll
- Common.Microsoft.RM.dll
Now to bundle them as a module and get on with the real work, which PowerShell makes ridiculously easy. Make a new directory $HOME\Documents\WindowsPowerShell\Modules\FIMAutomation, drop in the DLLs, then run the following few commands:
Push-Location -Path $HOME\Documents\WindowsPowerShell\Modules\FIMAutomation New-ModuleManifest -Path .\FIMAutomation.psd1 -RootModule Microsoft.ResourceManagement.Automation.dll -RequiredAssemblies (dir *.dll) Import-Module .\FIMAutomation.psd1 Pop-Location Export-FIMConfig -Uri http://mimservice:5725 -PortalConfig
Awesome, success!
If you’re not working from such a constrained environment, I’ve made a version of the wrapper module available below; you’ll have to source the MIM DLLs yourself though, as I don’t have any special distribution rights 🙂
This is a pretty niche problem, not something you’ll see everyday, but is also a useful approach to other legacy PSSnapin problems.