public void RemovesModulePathFromUserPSModulePath() { string originalPSModulePath = Environment.GetEnvironmentVariable(PowerShellUtilities.PSModulePathName); string[] modulePaths = originalPSModulePath.Split(';'); string modulePath = modulePaths[modulePaths.Length - 1]; string expected = null; string actual; try { if (modulePaths.Length > 1) { expected = string.Join(";", modulePaths, 0, modulePaths.Length - 1); } PowerShellUtilities.RemoveModuleFromPSModulePath(modulePath); actual = Environment.GetEnvironmentVariable(PowerShellUtilities.PSModulePathName); Assert.Equal(expected, actual); } finally { Environment.SetEnvironmentVariable(PowerShellUtilities.PSModulePathName, originalPSModulePath); } Assert.Equal(expected, actual); }
private void RemoveAzureModule(string name, string path) { WriteVerbose(string.Format("Removing {0} module...", name)); this.RemoveModule(name); WriteVerbose(string.Format("Removing {0} module path from PSModulePath...", path)); PowerShellUtilities.RemoveModuleFromPSModulePath(path); if (Global) { PowerShellUtilities.RemoveModuleFromPSModulePath(path, EnvironmentVariableTarget.Machine); } }
private void RemoveAzureModule(string name, string path) { if (IsLoaded(name)) { WriteVerbose(string.Format("Removing {0} module...", name)); this.RemoveModule(name); if (name.Equals(FileUtilities.GetModuleName(AzureModule.AzureServiceManagement))) { this.RemoveAzureAliases(); } WriteVerbose(string.Format("Removing {0} module path from PSModulePath...", path)); PowerShellUtilities.RemoveModuleFromPSModulePath(path); if (Global) { PowerShellUtilities.RemoveModuleFromPSModulePath(path, EnvironmentVariableTarget.Machine); } } }