private void LoadPowerShellProfile() { BuildShell(); try { shell.Runspace = host.Runspace; PSCommand[] profileCommands = HostUtilities.GetProfileCommands("TexoUI"); foreach (PSCommand command in profileCommands) { shell.Commands = command; shell.Invoke(); } } catch (Exception e) { // Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser logger.Error("Error during of profile loading in PowerShell.", e); } finally { ReleaseShell(); } }
/// <summary> /// Gets an array of commands that can be run sequentially to set $profile and run the profile commands. /// </summary> /// <param name="shellId">The id identifying the host or shell used in profile file names.</param> /// <returns>An array of commands.</returns> public static PSCommand[] GetProfileCommands(string shellId) { return(HostUtilities.GetProfileCommands(shellId, false)); }