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();
            }
        }
Exemple #2
0
 /// <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));
 }
Exemple #3
0
 /// <summary>
 /// Used to get all profile file names for the current or all hosts and for the current or all users.
 /// </summary>
 /// <param name="shellId">null for all hosts, not null for the specified host</param>
 /// <param name="forCurrentUser">false for all users, true for the current user.</param>
 /// <returns>The profile file name matching the parameters.</returns>
 internal static string GetFullProfileFileName(string shellId, bool forCurrentUser)
 {
     return(HostUtilities.GetFullProfileFileName(shellId, forCurrentUser, false));
 }