We’ve written a powershell script which processes images from an internal system and sends them off to another system. Now another part of the business would like to hook into this and do their own processing of the indata and push it to yet another system. Asking around, there are several intrested parties around the company, so I’d like to make it simple to add these new systems.
A first prototype simple opens all .ps1 files in a folder and runs a specially named function in there and hopes for the best, basically. However, this seems like it could be improved. Is there some established powershell best practice to do some plugin-like system? If not, given that this executes in a quite secured environment, and new modules will be checked in by administrators, are there any problems with my above approach?
Why wouldn’t you use a config file for your main script, explicitly telling what script and what function to call? Something like this (warning: this is copy/pasted and adapted code from something I wrote. Might contain a few glitches, but this gives you the general idea):
In your main script: