mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Update files from Source Depot changeset [SD:700586]
Corresponds to 84837459913bb00660964d19ea07f5e0c7b4b442 in psl-monad.
This commit is contained in:
1 parent
a7ba3395b9
commit
3998ce06ba
40 files changed
+1631
-484
No files matched your search
@@ -63,6 +63,15 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
}
|
||||
|
||||
internal bool ShowBanner
|
||||
{
|
||||
get
|
||||
{
|
||||
Dbg.Assert(dirty, "Parse has not been called yet");
|
||||
return showBanner;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool NoExit
|
||||
{
|
||||
get
|
||||
@@ -229,7 +238,7 @@ namespace Microsoft.PowerShell
|
||||
ui.WriteLine("");
|
||||
}
|
||||
|
||||
private void ShowBanner()
|
||||
private void DisplayBanner()
|
||||
{
|
||||
// We need to show the banner only if it has not been already shown in native layer
|
||||
if (!showInitialPrompt)
|
||||
@@ -699,7 +708,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
if (showBanner && !showHelp)
|
||||
{
|
||||
ShowBanner();
|
||||
DisplayBanner();
|
||||
}
|
||||
|
||||
Dbg.Assert(
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
@@ -36,7 +37,7 @@ using ConsoleHandle = Microsoft.Win32.SafeHandles.SafeFileHandle;
|
||||
using NakedWin32Handle = System.IntPtr;
|
||||
using System.Management.Automation.Tracing;
|
||||
using Microsoft.PowerShell.Telemetry.Internal;
|
||||
|
||||
using Debugger = System.Management.Automation.Debugger;
|
||||
|
||||
namespace Microsoft.PowerShell
|
||||
{
|
||||
@@ -51,7 +52,8 @@ namespace Microsoft.PowerShell
|
||||
:
|
||||
PSHost,
|
||||
IDisposable,
|
||||
IHostSupportsInteractiveSession
|
||||
IHostSupportsInteractiveSession,
|
||||
IHostProvidesTelemetryData
|
||||
{
|
||||
|
||||
#region static methods
|
||||
@@ -202,17 +204,8 @@ namespace Microsoft.PowerShell
|
||||
theConsoleHost.UI.WriteWarningLine(preStartWarning);
|
||||
}
|
||||
|
||||
using (theConsoleHost)
|
||||
try
|
||||
{
|
||||
#region Telemetry
|
||||
|
||||
// Data Point to Collect: PowerShell Version on this device
|
||||
// If null Version is supplied, the Telemetry infrastucture will log an empty value for null
|
||||
string version = theConsoleHost.ver.ToString();
|
||||
Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI.TraceMessage("PSCONSOLEHOST_START", new { PSVersion = version });
|
||||
|
||||
#endregion
|
||||
|
||||
cpp = new CommandLineParameterParser(theConsoleHost, theConsoleHost.ver, bannerText, helpText);
|
||||
string[] tempArgs = new string[args.GetLength(0)];
|
||||
args.CopyTo(tempArgs, 0);
|
||||
@@ -239,15 +232,17 @@ namespace Microsoft.PowerShell
|
||||
else if (cpp.NamedPipeServerMode)
|
||||
{
|
||||
ClrFacade.StartProfileOptimization("StartupProfileData-NamedPipeServerMode");
|
||||
System.Management.Automation.Remoting.RemoteSessionNamedPipeServer.RunServerMode(cpp.ConfigurationName);
|
||||
System.Management.Automation.Remoting.RemoteSessionNamedPipeServer.RunServerMode(
|
||||
cpp.ConfigurationName);
|
||||
exitCode = 0;
|
||||
}
|
||||
else if (cpp.SocketServerMode)
|
||||
{
|
||||
ClrFacade.StartProfileOptimization("StartupProfileData-SocketServerMode");
|
||||
System.Management.Automation.Remoting.Server.HyperVSocketMediator.Run(cpp.InitialCommand, cpp.ConfigurationName);
|
||||
System.Management.Automation.Remoting.Server.HyperVSocketMediator.Run(cpp.InitialCommand,
|
||||
cpp.ConfigurationName);
|
||||
exitCode = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ClrFacade.StartProfileOptimization(
|
||||
@@ -256,7 +251,14 @@ namespace Microsoft.PowerShell
|
||||
: "StartupProfileData-NonInteractive");
|
||||
exitCode = theConsoleHost.Run(cpp, !string.IsNullOrEmpty(preStartWarning));
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
TelemetryAPI.ReportExitTelemetry(theConsoleHost);
|
||||
theConsoleHost.Dispose();
|
||||
}
|
||||
|
||||
unchecked
|
||||
{
|
||||
return (int)exitCode;
|
||||
@@ -970,6 +972,22 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
}
|
||||
|
||||
bool IHostProvidesTelemetryData.HostIsInteractive
|
||||
{
|
||||
get
|
||||
{
|
||||
return !cpp.NonInteractive && !cpp.AbortStartup &&
|
||||
((cpp.InitialCommand == null && cpp.File == null) || cpp.NoExit);
|
||||
}
|
||||
}
|
||||
double IHostProvidesTelemetryData.ProfileLoadTimeInMS { get { return _profileLoadTimeInMS; } }
|
||||
double IHostProvidesTelemetryData.ReadyForInputTimeInMS { get { return _readyForInputTimeInMS; } }
|
||||
int IHostProvidesTelemetryData.InteractiveCommandCount { get { return _interactiveCommandCount; } }
|
||||
|
||||
private double _profileLoadTimeInMS;
|
||||
private double _readyForInputTimeInMS;
|
||||
private int _interactiveCommandCount;
|
||||
|
||||
#endregion overrides
|
||||
|
||||
#region non-overrides
|
||||
@@ -1370,6 +1388,7 @@ namespace Microsoft.PowerShell
|
||||
|
||||
RunspaceCreationEventArgs args = new RunspaceCreationEventArgs(initialCommand, skipProfiles, staMode, importSystemModules, configurationName, initialCommandArgs);
|
||||
CreateRunspace(args);
|
||||
|
||||
if (ExitCode == ExitCodeInitFailure) { break; }
|
||||
|
||||
if (!noExit && !ui.ReadFromStdin)
|
||||
@@ -1564,6 +1583,9 @@ namespace Microsoft.PowerShell
|
||||
PSTask.PowershellConsoleStartup, PSKeyword.UseAlwaysOperational);
|
||||
}
|
||||
|
||||
// Record how long it took from process start to runspace open for telemetry.
|
||||
_readyForInputTimeInMS = (DateTime.Now - Process.GetCurrentProcess().StartTime).TotalMilliseconds;
|
||||
|
||||
DoRunspaceInitialization(importSystemModules, skipProfiles, initialCommand, configurationName, initialCommandArgs);
|
||||
}
|
||||
|
||||
@@ -1697,10 +1719,21 @@ namespace Microsoft.PowerShell
|
||||
// 3. host independent profile of the current user
|
||||
// 4. host specific profile of the current user
|
||||
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
RunProfile(allUsersProfile, exec);
|
||||
RunProfile(allUsersHostSpecificProfile, exec);
|
||||
RunProfile(currentUserProfile, exec);
|
||||
RunProfile(currentUserHostSpecificProfile, exec);
|
||||
sw.Stop();
|
||||
|
||||
var profileLoadTimeInMs = sw.ElapsedMilliseconds;
|
||||
if (profileLoadTimeInMs > 500 && cpp.ShowBanner)
|
||||
{
|
||||
Console.Error.WriteLine(ConsoleHostStrings.SlowProfileLoadingMessage, profileLoadTimeInMs);
|
||||
}
|
||||
|
||||
_profileLoadTimeInMS = profileLoadTimeInMs;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1708,6 +1741,10 @@ namespace Microsoft.PowerShell
|
||||
}
|
||||
}
|
||||
|
||||
// Startup is reported after possibly running the profile, but before running the initial command (or file)
|
||||
// if one is specified.
|
||||
TelemetryAPI.ReportStartupTelemetry(this);
|
||||
|
||||
// If a file was specified as the argument to run, then run it...
|
||||
if (cpp != null && cpp.File != null)
|
||||
{
|
||||
@@ -2714,6 +2751,9 @@ namespace Microsoft.PowerShell
|
||||
parent.PopRunspace();
|
||||
}
|
||||
}
|
||||
|
||||
if (!inBlockMode)
|
||||
theConsoleHost._interactiveCommandCount += 1;
|
||||
}
|
||||
}
|
||||
// NTRAID#Windows Out Of Band Releases-915506-2005/09/09
|
||||
|
||||
+9
-2
@@ -133,13 +133,13 @@
|
||||
<value>PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
|
||||
[-NoLogo] [-NoExit] [-NoProfile] [-NonInteractive] [-STA]
|
||||
[-OutputFormat {Text | XML}] [-InputFormat {Text | XML}]
|
||||
[-ConfigurationName <string>]
|
||||
[-File fileName [arguments...]] [-ExecutionPolicy <ExecutionPolicy>]
|
||||
[-Command { - | <script-block> [-args <arg-array>]
|
||||
| <string> [<CommandParameters>] } ]
|
||||
[-File fileName [arguments...]] [-ExecutionPolicy <ExecutionPolicy>]
|
||||
|
||||
PowerShell[.exe] -Help | -? | /?
|
||||
|
||||
|
||||
-PSConsoleFile
|
||||
Loads the specified Windows PowerShell console file. To create a console
|
||||
file, use Export-Console in Windows PowerShell.
|
||||
@@ -170,6 +170,12 @@ PowerShell[.exe] -Help | -? | /?
|
||||
Describes the format of data sent to Windows PowerShell. Valid values are
|
||||
"Text" (text strings) or "XML" (serialized CLIXML format).
|
||||
|
||||
-ConfigurationName
|
||||
Specifies a configuration endpoint in which Windows PowerShell is run.
|
||||
This can be any endpoint registered on the local machine including the
|
||||
default Windows PowerShell remoting endpoints or a custom endpoint having
|
||||
specific user role capabilities.
|
||||
|
||||
-Command
|
||||
Executes the specified commands (and any parameters) as though they were
|
||||
typed at the Windows PowerShell command prompt, and then exits, unless
|
||||
@@ -201,6 +207,7 @@ PowerShell[.exe] -Help | -? | /?
|
||||
EXAMPLES
|
||||
PowerShell -PSConsoleFile SqlSnapin.Psc1
|
||||
PowerShell -version 1.0 -NoLogo -InputFormat text -OutputFormat XML
|
||||
PowerShell -ConfigurationName AdminRoles
|
||||
PowerShell -Command {Get-EventLog -LogName security}
|
||||
PowerShell -Command "& {Get-EventLog -LogName security}"
|
||||
</value>
|
||||
|
||||
@@ -185,4 +185,7 @@ The current session does not support debugging; execution will continue.
|
||||
<data name="ConflictingServerModeParameters" xml:space="preserve">
|
||||
<value>More than one server mode parameter was specified. Server mode parameters must be used exclusively.</value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="SlowProfileLoadingMessage" xml:space="preserve">
|
||||
<value>Loading personal and system profiles took {0}ms.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -124,8 +124,9 @@ Copyright (C) 2016 Microsoft Corporation. All rights reserved.</value>
|
||||
<data name="ShellHelp" xml:space="preserve">
|
||||
<value>PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
|
||||
[-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive]
|
||||
[-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
|
||||
[-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>]
|
||||
[-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
|
||||
[-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>]
|
||||
[-ConfigurationName <string>]
|
||||
[-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>]
|
||||
[-Command { - | <script-block> [-args <arg-array>]
|
||||
| <string> [<CommandParameters>] } ]
|
||||
@@ -174,6 +175,12 @@ PowerShell[.exe] -Help | -? | /?
|
||||
Accepts a base-64-encoded string version of a command. Use this parameter
|
||||
to submit commands to Windows PowerShell that require complex quotation
|
||||
marks or curly braces.
|
||||
|
||||
-ConfigurationName
|
||||
Specifies a configuration endpoint in which Windows PowerShell is run.
|
||||
This can be any endpoint registered on the local machine including the
|
||||
default Windows PowerShell remoting endpoints or a custom endpoint having
|
||||
specific user role capabilities.
|
||||
|
||||
-File
|
||||
Runs the specified script in the local scope ("dot-sourced"), so that the
|
||||
@@ -220,6 +227,7 @@ PowerShell[.exe] -Help | -? | /?
|
||||
EXAMPLES
|
||||
PowerShell -PSConsoleFile SqlSnapIn.Psc1
|
||||
PowerShell -version 2.0 -NoLogo -InputFormat text -OutputFormat XML
|
||||
PowerShell -ConfigurationName AdminRoles
|
||||
PowerShell -Command {Get-EventLog -LogName security}
|
||||
PowerShell -Command "& {Get-EventLog -LogName security}"
|
||||
|
||||
|
||||
Reference in new issue
Block a user