コード例 #1
0
        private void ImportAzureModule(string name, string path)
        {
            WriteVerbose(string.Format("Importing {0} module...", name));
            this.ImportModule(Path.Combine(path, name + ".psd1"));

            WriteVerbose(string.Format("Adding {0} module path to PSModulePath...", path));
            PowerShellUtilities.AddModuleToPSModulePath(path);

            if (Global)
            {
                PowerShellUtilities.AddModuleToPSModulePath(path, EnvironmentVariableTarget.Machine);
            }
        }
コード例 #2
0
        public void AddsModulePathToUserPSModulePath()
        {
            string originalPSModulePath = Environment.GetEnvironmentVariable(PowerShellUtilities.PSModulePathName);

            try
            {
                string modulePath = "C:\\ExampleTest\\MyModule.psd1";
                string expected   = originalPSModulePath + ";" + modulePath;
                PowerShellUtilities.AddModuleToPSModulePath(modulePath);
                string actual = Environment.GetEnvironmentVariable(PowerShellUtilities.PSModulePathName);
                Assert.Equal(expected, actual);
            }
            finally
            {
                Environment.SetEnvironmentVariable(PowerShellUtilities.PSModulePathName, originalPSModulePath);
            }
        }