PKHeX is open source, and is split up into separate projects to produce .dll files with non-visual logic residing in PKHeX.Core
https://github.com/kwsch/PKHeX
PKHeX.Core is available on NuGet. https://www.nuget.org/packages/PKHeX.Core/
You can reference the dll/nuget in whatever script, and call whatever functions you want. LINQPad is pretty useful for this, if the scripts are small in scope. PKHeX also supports custom plugins, so you can write your own code to be triggered via the main GUI, which is easier if you want to share your custom scripts with less capable users.