src/System.Management.Automation/engine/hostifaces/HostUtilities.cs
/// <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>
/// <param name="useTestProfile">Used from test not to overwrite the profile file names from development boxes.</param>
/// <returns></returns>
Gets an array of commands that can be run sequentially to set $profile and run the profile commands.
Gets an array of commands that can be run sequentially to set $profile and run the profile commands .
internal static PSCommand[] GetProfileCommands(string shellId, bool useTestProfile)
        {
            List<PSCommand> commands = new List<PSCommand>();
            string allUsersAllHosts, allUsersCurrentHost, currentUserAllHosts, currentUserCurrentHost;
            PSObject dollarProfile;
            HostUtilities.GetProfileObjectData(shellId, useTestProfile, out allUsersAllHosts, out allUsersCurrentHost, out currentUserAllHosts, out currentUserCurrentHost, out dollarProfile);
            PSCommand command = new PSCommand();
            command.AddCommand("set-variable");
            command.AddParameter("Name", "profile");
            command.AddParameter("Value", dollarProfile);
            command.AddParameter("Option", ScopedItemOptions.None);
            commands.Add(command);
            string[] profilePaths = new string[] { allUsersAllHosts, allUsersCurrentHost, currentUserAllHosts, currentUserCurrentHost };
            foreach (string profilePath in profilePaths)
            {
                if (!System.IO.File.Exists(profilePath))
                {
                    continue;
                }
                command = new PSCommand();
                command.AddCommand(profilePath, false);
                commands.Add(command);
            }
            return commands.ToArray();
        }
internal static PSCommand [ ] GetProfileCommands ( string shellId , bool useTestProfile ) { List < PSCommand > commands = new List < PSCommand > ( ) ; string allUsersAllHosts , allUsersCurrentHost , currentUserAllHosts , currentUserCurrentHost ; PSObject dollarProfile ; HostUtilities . GetProfileObjectData ( shellId , useTestProfile , out allUsersAllHosts , out allUsersCurrentHost , out currentUserAllHosts , out currentUserCurrentHost , out dollarProfile ) ; PSCommand command = new PSCommand ( ) ; command . AddCommand ( " " ) ; command . AddParameter ( " " , " " ) ; command . AddParameter ( " " , dollarProfile ) ; command . AddParameter ( " " , ScopedItemOptions . None ) ; commands . Add ( command ) ; string [ ] profilePaths = new string [ ] { allUsersAllHosts , allUsersCurrentHost , currentUserAllHosts , currentUserCurrentHost } ; foreach ( string profilePath in profilePaths ) { if ( ! System . IO . File . Exists ( profilePath ) ) { continue ; } command = new PSCommand ( ) ; command . AddCommand ( profilePath , false ) ; commands . Add ( command ) ; } return commands . ToArray ( ) ; }
Gets an array of commands that can be run sequentially to set $profile and run the profile commands.
Gets an array of commands that can be run sequentially to set $profile and run the profile commands .
None
shellId
string
The id identifying the host or shell used in profile file names.
The id identifying the host or shell used in profile file names .
useTestProfile
bool
Used from test not to overwrite the profile file names from development boxes.
Used from test not to overwrite the profile file names from development boxes .