Exemplo n.º 1
0
        internal IEnumerable <string> ScanForModules(Request request)
        {
            // two places we search for modules
            // 1. in this assembly's folder, look for all psd1 and psm1 files.
            //
            // 2. modules in the PSMODULEPATH
            //
            // Import each one of those, and check to see if they have a OneGet.Providers section in their private data

            using (dynamic ps = new DynamicPowershell()) {
                // load the powershell functions into this runspace in case something needed it on module load.
                var psf = ps.ImportModule(Name: PowerShellProviderFunctions, PassThru: true);

#if DEBUG
                var testProviders = Directory.EnumerateFiles(BaseFolder, "*.psm1", SearchOption.AllDirectories);
                foreach (var provider in testProviders)
                {
                    yield return(provider);
                }
#endif
                // scan all the ps modules in the folders provided
                foreach (var each in AlternativeModuleScan(request))
                {
                    DynamicPowershellResult result;

                    result = ps.TestModuleManifest(each);
                    var values = result.ToArray();

                    foreach (var v in values)
                    {
                        var moduleData = v as PSModuleInfo;
                        if (moduleData == null)
                        {
                            continue;
                        }
                        foreach (var m in GetOneGetModules(moduleData))
                        {
                            yield return(m);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        internal IEnumerable <string> ScanForModules(PsRequest request)
        {
            // two places we search for modules
            // 1. in this assembly's folder, look for all psd1 and psm1 files.
            //
            // 2. modules in the PSMODULEPATH
            //
            // Import each one of those, and check to see if they have a OneGet.Providers section in their private data

            using (var ps = new DynamicPowershell()) {
                // load the powershell functions into this runspace in case something needed it on module load.
                var psf = ps.ImportModule(PowerShellProviderFunctions, true);

                // scan all the ps modules in the folders provided
                foreach (var each in AlternativeModuleScan(request))
                {
                    foreach (var ogModule in ps.TestModuleManifest(each).SelectMany(GetOneGetModules))
                    {
                        yield return(ogModule);
                    }
                }
            }
        }