mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Bulk update format for files in Management folder with codeformatter (#7346)
This commit is contained in:
+1
-1
@@ -74,7 +74,7 @@ namespace Microsoft.PowerShell.Cmdletization
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
protected TSession[] Session
|
||||
{
|
||||
get { return _session ?? (_session = new TSession[] {this.DefaultSession}); }
|
||||
get { return _session ?? (_session = new TSession[] { this.DefaultSession }); }
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
|
||||
+4
-2
@@ -58,9 +58,11 @@ namespace Microsoft.PowerShell.Cim
|
||||
}
|
||||
|
||||
fixed (char* target = _string)
|
||||
for (int i = 0; i < charsToCopy; i++)
|
||||
{
|
||||
target[offset + i] = source[i];
|
||||
for (int i = 0; i < charsToCopy; i++)
|
||||
{
|
||||
target[offset + i] = source[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
@@ -35,7 +35,7 @@ using Microsoft.PowerShell.CoreClr.Stubs;
|
||||
|
||||
namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
#region Restart-Computer
|
||||
#region Restart-Computer
|
||||
|
||||
/// <summary>
|
||||
/// This exception is thrown when the timeout expires before a computer finishes restarting
|
||||
@@ -96,7 +96,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </param>
|
||||
public RestartComputerTimeoutException(string message, Exception innerException) : base(message, innerException) { }
|
||||
|
||||
#region Serialization
|
||||
#region Serialization
|
||||
/// <summary>
|
||||
/// Serialization constructor for class RestartComputerTimeoutException
|
||||
/// </summary>
|
||||
@@ -143,7 +143,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
info.AddValue("ComputerName", ComputerName);
|
||||
info.AddValue("Timeout", Timeout);
|
||||
}
|
||||
#endregion Serialization
|
||||
#endregion Serialization
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -175,7 +175,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
HelpUri = "https://go.microsoft.com/fwlink/?LinkID=135253", RemotingCapability = RemotingCapability.OwnedByCommand)]
|
||||
public class RestartComputerCommand : PSCmdlet, IDisposable
|
||||
{
|
||||
#region "Parameters and PrivateData"
|
||||
#region "Parameters and PrivateData"
|
||||
|
||||
private const string DefaultParameterSet = "DefaultSet";
|
||||
private const int forcedReboot = 6; // see https://msdn.microsoft.com/library/aa394058(v=vs.85).aspx
|
||||
@@ -365,9 +365,9 @@ $result
|
||||
private const string WinrmConnectionTest = "WinRM";
|
||||
private const string PowerShellConnectionTest = "PowerShell";
|
||||
|
||||
#endregion "parameters and PrivateData"
|
||||
#endregion "parameters and PrivateData"
|
||||
|
||||
#region "IDisposable Members"
|
||||
#region "IDisposable Members"
|
||||
|
||||
/// <summary>
|
||||
/// Dispose Method
|
||||
@@ -402,9 +402,9 @@ $result
|
||||
}
|
||||
}
|
||||
|
||||
#endregion "IDisposable Members"
|
||||
#endregion "IDisposable Members"
|
||||
|
||||
#region "Private Methods"
|
||||
#region "Private Methods"
|
||||
|
||||
/// <summary>
|
||||
/// Validate parameters for 'DefaultSet'
|
||||
@@ -441,7 +441,7 @@ $result
|
||||
}
|
||||
|
||||
// Force wait with a test hook even if we're on the local computer
|
||||
if (! InternalTestHooks.TestWaitStopComputer && Wait && containLocalhost)
|
||||
if (!InternalTestHooks.TestWaitStopComputer && Wait && containLocalhost)
|
||||
{
|
||||
// The local machine will be ignored, and an error will be emitted.
|
||||
InvalidOperationException ex = new InvalidOperationException(ComputerResources.CannotWaitLocalComputer);
|
||||
@@ -650,15 +650,16 @@ $result
|
||||
string errorMsg = StringUtil.Format(ComputerResources.RestartcomputerFailed, computer, ComputerResources.TimeoutError);
|
||||
var exception = new RestartComputerTimeoutException(computer, Timeout, errorMsg, errorId);
|
||||
var error = new ErrorRecord(exception, errorId, ErrorCategory.OperationTimeout, computer);
|
||||
if (! InternalTestHooks.TestWaitStopComputer ) {
|
||||
WriteError(error);
|
||||
if (!InternalTestHooks.TestWaitStopComputer)
|
||||
{
|
||||
WriteError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion "Private Methods"
|
||||
#endregion "Private Methods"
|
||||
|
||||
#region "Internal Methods"
|
||||
#region "Internal Methods"
|
||||
|
||||
internal static List<string> TestWmiConnectionUsingWsman(List<string> computerNames, List<string> nextTestList, CancellationToken token, PSCredential credential, string wsmanAuthentication, PSCmdlet cmdlet)
|
||||
{
|
||||
@@ -771,9 +772,9 @@ $result
|
||||
return psList;
|
||||
}
|
||||
|
||||
#endregion "Internal Methods"
|
||||
#endregion "Internal Methods"
|
||||
|
||||
#region "Overrides"
|
||||
#region "Overrides"
|
||||
|
||||
/// <summary>
|
||||
/// BeginProcessing method.
|
||||
@@ -1089,12 +1090,12 @@ $result
|
||||
}
|
||||
}
|
||||
|
||||
#endregion "Overrides"
|
||||
#endregion "Overrides"
|
||||
}
|
||||
|
||||
#endregion Restart-Computer
|
||||
#endregion Restart-Computer
|
||||
|
||||
#region Stop-Computer
|
||||
#region Stop-Computer
|
||||
|
||||
/// <summary>
|
||||
/// cmdlet to stop computer
|
||||
@@ -1103,14 +1104,14 @@ $result
|
||||
HelpUri = "https://go.microsoft.com/fwlink/?LinkID=135263", RemotingCapability = RemotingCapability.SupportedByCommand)]
|
||||
public sealed class StopComputerCommand : PSCmdlet, IDisposable
|
||||
{
|
||||
#region Private Members
|
||||
#region Private Members
|
||||
|
||||
private readonly CancellationTokenSource _cancel = new CancellationTokenSource();
|
||||
private const int forcedShutdown = 5; // See https://msdn.microsoft.com/library/aa394058(v=vs.85).aspx
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region "Parameters"
|
||||
#region "Parameters"
|
||||
|
||||
/// <summary>
|
||||
/// The authentication options for CIM_WSMan connection
|
||||
@@ -1157,7 +1158,7 @@ $result
|
||||
|
||||
#endregion "parameters"
|
||||
|
||||
#region "IDisposable Members"
|
||||
#region "IDisposable Members"
|
||||
|
||||
/// <summary>
|
||||
/// Dispose Method
|
||||
@@ -1171,9 +1172,9 @@ $result
|
||||
catch (ObjectDisposedException) { }
|
||||
}
|
||||
|
||||
#endregion "IDisposable Members"
|
||||
#endregion "IDisposable Members"
|
||||
|
||||
#region "Overrides"
|
||||
#region "Overrides"
|
||||
|
||||
/// <summary>
|
||||
/// ProcessRecord
|
||||
@@ -1201,9 +1202,9 @@ $result
|
||||
catch (AggregateException) { }
|
||||
}
|
||||
|
||||
#endregion "Overrides"
|
||||
#endregion "Overrides"
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
private void ProcessWSManProtocol(object[] flags)
|
||||
{
|
||||
@@ -1246,12 +1247,12 @@ $result
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Rename-Computer
|
||||
#region Rename-Computer
|
||||
|
||||
/// <summary>
|
||||
/// Renames a domain computer and its corresponding domain account or a
|
||||
@@ -1263,7 +1264,7 @@ $result
|
||||
HelpUri = "https://go.microsoft.com/fwlink/?LinkID=219990", RemotingCapability = RemotingCapability.SupportedByCommand)]
|
||||
public class RenameComputerCommand : PSCmdlet
|
||||
{
|
||||
#region Private Members
|
||||
#region Private Members
|
||||
|
||||
private bool _containsLocalHost = false;
|
||||
private string _newNameForLocalHost = null;
|
||||
@@ -1271,9 +1272,9 @@ $result
|
||||
private readonly string _shortLocalMachineName = Dns.GetHostName();
|
||||
private readonly string _fullLocalMachineName = Dns.GetHostEntryAsync(string.Empty).Result.HostName;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Parameters
|
||||
#region Parameters
|
||||
|
||||
/// <summary>
|
||||
/// Target computers to rename
|
||||
@@ -1348,9 +1349,9 @@ $result
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
|
||||
public string WsmanAuthentication { get; set; } = "Default";
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region "Private Methods"
|
||||
#region "Private Methods"
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if the target computer is the local machine
|
||||
@@ -1479,7 +1480,7 @@ $result
|
||||
Microsoft.Management.Infrastructure.CimType.String,
|
||||
(dPassword == null) ? CimFlags.NullValue : CimFlags.None));
|
||||
|
||||
if ( ! InternalTestHooks.TestRenameComputer )
|
||||
if (!InternalTestHooks.TestRenameComputer)
|
||||
{
|
||||
CimMethodResult result = cimSession.InvokeMethod(
|
||||
ComputerWMIHelper.CimOperatingSystemNamespace,
|
||||
@@ -1553,9 +1554,9 @@ $result
|
||||
}
|
||||
}
|
||||
|
||||
#endregion "Private Methods"
|
||||
#endregion "Private Methods"
|
||||
|
||||
#region "Override Methods"
|
||||
#region "Override Methods"
|
||||
|
||||
/// <summary>
|
||||
/// ProcessRecord method.
|
||||
@@ -1588,12 +1589,12 @@ $result
|
||||
DoRenameComputerAction("localhost", _newNameForLocalHost, true);
|
||||
}
|
||||
|
||||
#endregion "Override Methods"
|
||||
#endregion "Override Methods"
|
||||
}
|
||||
|
||||
#endregion Rename-Computer
|
||||
#endregion Rename-Computer
|
||||
|
||||
#region "Public API"
|
||||
#region "Public API"
|
||||
/// <summary>
|
||||
/// The object returned by SAM Computer cmdlets representing the status of the target machine.
|
||||
/// </summary>
|
||||
@@ -1675,9 +1676,9 @@ $result
|
||||
return StringUtil.Format(MatchFormat, HasSucceeded, newcomputername, oldcomputername);
|
||||
}
|
||||
}
|
||||
#endregion "Public API"
|
||||
#endregion "Public API"
|
||||
|
||||
#region Helper
|
||||
#region Helper
|
||||
/// <summary>
|
||||
/// Helper Class used by Stop-Computer,Restart-Computer and Test-Connection
|
||||
/// Also Contain constants used by System Restore related Cmdlets.
|
||||
@@ -2103,7 +2104,7 @@ $result
|
||||
Microsoft.Management.Infrastructure.CimType.SInt32,
|
||||
CimFlags.None));
|
||||
|
||||
if ( ! InternalTestHooks.TestStopComputer )
|
||||
if (!InternalTestHooks.TestStopComputer)
|
||||
{
|
||||
CimMethodResult result = cimSession.InvokeMethod(
|
||||
ComputerWMIHelper.CimOperatingSystemNamespace,
|
||||
@@ -2226,8 +2227,7 @@ $result
|
||||
return validatedComputerName;
|
||||
}
|
||||
}
|
||||
#endregion Helper
|
||||
|
||||
#endregion Helper
|
||||
}//End namespace
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get { return Path; }
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get { return paths; }
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = literalChildrenSet,
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
+2
-1
@@ -435,7 +435,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
var wmiGuard = session.GetFirst<WmiDeviceGuard>(CIMHelper.DeviceGuardNamespace,
|
||||
CIMHelper.ClassNames.DeviceGuard);
|
||||
|
||||
if (wmiGuard != null) {
|
||||
if (wmiGuard != null)
|
||||
{
|
||||
var smartStatus = EnumConverter<DeviceGuardSmartStatus>.Convert((int?)wmiGuard.VirtualizationBasedSecurityStatus ?? 0);
|
||||
if (smartStatus != null)
|
||||
{
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
@@ -197,7 +197,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// Gets or sets the literal path parameter to the command
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath", Mandatory = true, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get { return paths; }
|
||||
|
||||
@@ -215,14 +215,12 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// the base class to simplify the creation of the CmdletProviderContext.
|
||||
/// </remarks>
|
||||
///
|
||||
public virtual string[] Include { get;
|
||||
// get
|
||||
public virtual string[] Include
|
||||
{
|
||||
get;
|
||||
set;
|
||||
// set
|
||||
} = new string[0];
|
||||
|
||||
// Include
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the exclude property
|
||||
/// </summary>
|
||||
@@ -233,14 +231,12 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// the base class to simplify the creation of the CmdletProviderContext.
|
||||
/// </remarks>
|
||||
///
|
||||
public virtual string[] Exclude { get;
|
||||
// get
|
||||
public virtual string[] Exclude
|
||||
{
|
||||
get;
|
||||
set;
|
||||
// set
|
||||
} = new string[0];
|
||||
|
||||
// Exclude
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the force property
|
||||
/// </summary>
|
||||
@@ -757,7 +753,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = literalPathSet,
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string LiteralPath
|
||||
{
|
||||
get
|
||||
@@ -937,7 +933,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string LiteralPath
|
||||
{
|
||||
get
|
||||
@@ -2059,7 +2055,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
@@ -2426,7 +2422,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get { return _paths; }
|
||||
@@ -2643,7 +2639,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
@@ -3117,7 +3113,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get { return _paths; }
|
||||
@@ -3507,7 +3503,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// Gets or sets the literal path property
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "ByLiteralPath")]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string LiteralPath
|
||||
{
|
||||
get { return _path; }
|
||||
@@ -3801,7 +3797,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get { return _paths; }
|
||||
@@ -4074,7 +4070,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
@@ -4305,7 +4301,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// Gets or sets the literal path parameter to the command
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPathSet", Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get { return _paths; }
|
||||
|
||||
@@ -642,7 +642,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
try
|
||||
{
|
||||
ProcessModule mainModule = PsUtils.GetMainModule(process);
|
||||
if (mainModule != null) {
|
||||
if (mainModule != null)
|
||||
{
|
||||
WriteObject(mainModule.FileVersionInfo, true);
|
||||
}
|
||||
}
|
||||
@@ -1269,7 +1270,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// <summary>
|
||||
/// Boolean variables to display the warning using ShouldContinue.
|
||||
/// </summary>
|
||||
private bool _yesToAll,_noToAll;
|
||||
private bool _yesToAll, _noToAll;
|
||||
|
||||
/// <summary>
|
||||
/// Current windows user name.
|
||||
@@ -1587,7 +1588,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(Mandatory = true, Position = 0)]
|
||||
[ValidateNotNullOrEmpty]
|
||||
[Alias("PSPath","Path")]
|
||||
[Alias("PSPath", "Path")]
|
||||
public string FilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
[Parameter(ParameterSetName = "LiteralPath",
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get
|
||||
|
||||
@@ -599,7 +599,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
/// <param name="service"></param>
|
||||
/// <returns>ServiceController as PSObject with UserName, Description and StartupType added</returns>
|
||||
private PSObject AddProperties(ServiceController service) {
|
||||
private PSObject AddProperties(ServiceController service)
|
||||
{
|
||||
NakedWin32Handle hScManager = IntPtr.Zero;
|
||||
NakedWin32Handle hService = IntPtr.Zero;
|
||||
int lastError = 0;
|
||||
@@ -611,7 +612,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
lpDatabaseName: null,
|
||||
dwDesiredAccess: NativeMethods.SC_MANAGER_CONNECT
|
||||
);
|
||||
if (IntPtr.Zero == hScManager) {
|
||||
if (IntPtr.Zero == hScManager)
|
||||
{
|
||||
lastError = Marshal.GetLastWin32Error();
|
||||
Win32Exception exception = new Win32Exception(lastError);
|
||||
WriteNonTerminatingError(
|
||||
@@ -626,7 +628,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
service.ServiceName,
|
||||
NativeMethods.SERVICE_QUERY_CONFIG
|
||||
);
|
||||
if (IntPtr.Zero == hService) {
|
||||
if (IntPtr.Zero == hService)
|
||||
{
|
||||
lastError = Marshal.GetLastWin32Error();
|
||||
Win32Exception exception = new Win32Exception(lastError);
|
||||
WriteNonTerminatingError(
|
||||
@@ -646,7 +649,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
NativeMethods.QUERY_SERVICE_CONFIG serviceInfo = new NativeMethods.QUERY_SERVICE_CONFIG();
|
||||
querySuccessful = querySuccessful && NativeMethods.QueryServiceConfig(hService, out serviceInfo);
|
||||
|
||||
if(!querySuccessful) {
|
||||
if (!querySuccessful)
|
||||
{
|
||||
WriteNonTerminatingError(
|
||||
service: service,
|
||||
innerException: null,
|
||||
@@ -678,16 +682,20 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (IntPtr.Zero != hService) {
|
||||
if (IntPtr.Zero != hService)
|
||||
{
|
||||
bool succeeded = NativeMethods.CloseServiceHandle(hService);
|
||||
if (!succeeded) {
|
||||
if (!succeeded)
|
||||
{
|
||||
Diagnostics.Assert(lastError != 0, "ErrorCode not success");
|
||||
}
|
||||
}
|
||||
|
||||
if (IntPtr.Zero != hScManager) {
|
||||
if (IntPtr.Zero != hScManager)
|
||||
{
|
||||
bool succeeded = NativeMethods.CloseServiceHandle(hScManager);
|
||||
if (!succeeded) {
|
||||
if (!succeeded)
|
||||
{
|
||||
Diagnostics.Assert(lastError != 0, "ErrorCode not success");
|
||||
}
|
||||
}
|
||||
@@ -2116,7 +2124,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
// Set the delayed auto start
|
||||
if(StartupType == ServiceStartupType.AutomaticDelayedStart) {
|
||||
if (StartupType == ServiceStartupType.AutomaticDelayedStart)
|
||||
{
|
||||
NativeMethods.SERVICE_DELAYED_AUTO_START_INFO ds = new NativeMethods.SERVICE_DELAYED_AUTO_START_INFO();
|
||||
ds.fDelayedAutostart = true;
|
||||
size = Marshal.SizeOf(ds);
|
||||
@@ -2675,7 +2684,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
cbBufSize: 0,
|
||||
pcbBytesNeeded: out bufferSizeNeeded);
|
||||
|
||||
if (status != true && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER) {
|
||||
if (status != true && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2711,7 +2721,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
cbBufSize: 0,
|
||||
pcbBytesNeeded: out bufferSizeNeeded);
|
||||
|
||||
if (status != true && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER) {
|
||||
if (status != true && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2776,7 +2787,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
internal static ServiceStartupType GetServiceStartupType(ServiceStartMode startMode, bool delayedAutoStart)
|
||||
{
|
||||
ServiceStartupType result = ServiceStartupType.Disabled;
|
||||
switch(startMode)
|
||||
switch (startMode)
|
||||
{
|
||||
case ServiceStartMode.Automatic:
|
||||
result = delayedAutoStart ? ServiceStartupType.AutomaticDelayedStart : ServiceStartupType.Automatic;
|
||||
@@ -2797,7 +2808,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
///<summary>
|
||||
///Enum for usage with StartupType. Automatic, Manual and Disabled index matched from System.ServiceProcess.ServiceStartMode
|
||||
///</summary>
|
||||
public enum ServiceStartupType {
|
||||
public enum ServiceStartupType
|
||||
{
|
||||
///<summary>Invalid service</summary>
|
||||
InvalidValue = -1,
|
||||
///<summary>Automatic service</summary>
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Parameter(ParameterSetName = propertyPSObjectLiteralPathSet,
|
||||
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
|
||||
[Alias("PSPath","LP")]
|
||||
[Alias("PSPath", "LP")]
|
||||
public string[] LiteralPath
|
||||
{
|
||||
get { return paths; }
|
||||
|
||||
+46
-48
@@ -17,10 +17,10 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// The implementation of the "Test-Connection" cmdlet.
|
||||
/// </summary>
|
||||
[Cmdlet(VerbsDiagnostic.Test, "Connection", DefaultParameterSetName = ParameterSetPingCount, HelpUri = "https://go.microsoft.com/fwlink/?LinkID=135266")]
|
||||
[OutputType(typeof(PingReport), ParameterSetName = new string[] { ParameterSetPingCount })]
|
||||
[OutputType(typeof(PingReply), ParameterSetName = new string[] { ParameterSetPingContinues, ParameterSetDetectionOfMTUSize })]
|
||||
[OutputType(typeof(Boolean), ParameterSetName = new string[] { ParameterSetPingCount, ParameterSetPingContinues, ParameterSetConnectionByTCPPort })]
|
||||
[OutputType(typeof(Int32), ParameterSetName = new string[] { ParameterSetDetectionOfMTUSize })]
|
||||
[OutputType(typeof(PingReport), ParameterSetName = new string[] { ParameterSetPingCount })]
|
||||
[OutputType(typeof(PingReply), ParameterSetName = new string[] { ParameterSetPingContinues, ParameterSetDetectionOfMTUSize })]
|
||||
[OutputType(typeof(Boolean), ParameterSetName = new string[] { ParameterSetPingCount, ParameterSetPingContinues, ParameterSetConnectionByTCPPort })]
|
||||
[OutputType(typeof(Int32), ParameterSetName = new string[] { ParameterSetDetectionOfMTUSize })]
|
||||
[OutputType(typeof(TraceRouteReply), ParameterSetName = new string[] { ParameterSetTraceRoute })]
|
||||
public class TestConnectionCommand : PSCmdlet
|
||||
{
|
||||
@@ -32,7 +32,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
//private const string ParameterSetDetectionOfBlackHole = "DetectionOfBlackHole";
|
||||
private const string ParameterSetDetectionOfMTUSize = "DetectionOfMTUSize";
|
||||
|
||||
#region Parameters
|
||||
#region Parameters
|
||||
|
||||
/// <summary>
|
||||
/// Do ping test.
|
||||
@@ -187,7 +187,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
[Parameter(Mandatory = true, ParameterSetName = ParameterSetConnectionByTCPPort)]
|
||||
public int TCPPort { get; set; }
|
||||
|
||||
#endregion Parameters
|
||||
#endregion Parameters
|
||||
|
||||
/// <summary>
|
||||
/// Init the cmdlet.
|
||||
@@ -230,7 +230,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
}
|
||||
|
||||
#region ConnectionTest
|
||||
#region ConnectionTest
|
||||
|
||||
private void ProcessConnectionByTCPPort(String targetNameOrAddress)
|
||||
{
|
||||
@@ -251,7 +251,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
Task connectionTask = client.ConnectAsync(targetAddress, TCPPort);
|
||||
String targetString = targetAddress.ToString();
|
||||
|
||||
for (var i=1; i <= TimeoutSeconds; i++)
|
||||
for (var i = 1; i <= TimeoutSeconds; i++)
|
||||
{
|
||||
WriteConnectionTestProgress(targetNameOrAddress, targetString, i);
|
||||
|
||||
@@ -287,8 +287,8 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
private void WriteConnectionTestHeader(string resolvedTargetName, string targetAddress)
|
||||
{
|
||||
TestConnectionProgressBarActivity = StringUtil.Format(TestConnectionResources.ConnectionTestStart, resolvedTargetName, targetAddress);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
_testConnectionProgressBarActivity = StringUtil.Format(TestConnectionResources.ConnectionTestStart, resolvedTargetName, targetAddress);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
WriteProgress(record);
|
||||
}
|
||||
|
||||
@@ -298,20 +298,20 @@ namespace Microsoft.PowerShell.Commands
|
||||
targetNameOrAddress,
|
||||
targetAddress,
|
||||
timeout);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, msg);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, msg);
|
||||
WriteProgress(record);
|
||||
}
|
||||
|
||||
private void WriteConnectionTestFooter()
|
||||
{
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
record.RecordType = ProgressRecordType.Completed;
|
||||
WriteProgress(record);
|
||||
}
|
||||
|
||||
#endregion ConnectionTest
|
||||
#endregion ConnectionTest
|
||||
|
||||
#region TracerouteTest
|
||||
#region TracerouteTest
|
||||
private void ProcessTraceroute(String targetNameOrAddress)
|
||||
{
|
||||
String resolvedTargetName = null;
|
||||
@@ -344,7 +344,6 @@ namespace Microsoft.PowerShell.Commands
|
||||
// If we change 'DefaultTraceRoutePingCount' we should change 'ConsoleTraceRouteReply' resource string.
|
||||
for (int i = 1; i <= DefaultTraceRoutePingCount; i++)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
reply = sender.Send(targetAddress, timeout, buffer, pingOptions);
|
||||
@@ -384,7 +383,6 @@ namespace Microsoft.PowerShell.Commands
|
||||
WriteTraceRouteProgress(traceRouteReply);
|
||||
|
||||
traceRouteResult.Replies.Add(traceRouteReply);
|
||||
|
||||
} while (reply != null && currentHop <= sMaxHops && (reply.Status == IPStatus.TtlExpired || reply.Status == IPStatus.TimedOut));
|
||||
|
||||
WriteTraceRouteFooter();
|
||||
@@ -401,16 +399,16 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
private void WriteConsoleTraceRouteHeader(string resolvedTargetName, string targetAddress)
|
||||
{
|
||||
TestConnectionProgressBarActivity = StringUtil.Format(TestConnectionResources.TraceRouteStart, resolvedTargetName, targetAddress, MaxHops);
|
||||
_testConnectionProgressBarActivity = StringUtil.Format(TestConnectionResources.TraceRouteStart, resolvedTargetName, targetAddress, MaxHops);
|
||||
|
||||
WriteInformation(TestConnectionProgressBarActivity, PSHostTag);
|
||||
WriteInformation(_testConnectionProgressBarActivity, s_PSHostTag);
|
||||
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
WriteProgress(record);
|
||||
}
|
||||
|
||||
private string TestConnectionProgressBarActivity;
|
||||
private static string[] PSHostTag = new string[] { "PSHOST" };
|
||||
private string _testConnectionProgressBarActivity;
|
||||
private static string[] s_PSHostTag = new string[] { "PSHOST" };
|
||||
|
||||
private void WriteTraceRouteProgress(TraceRouteReply traceRouteReply)
|
||||
{
|
||||
@@ -431,17 +429,17 @@ namespace Microsoft.PowerShell.Commands
|
||||
msg = StringUtil.Format(TestConnectionResources.TraceRouteTimeOut, traceRouteReply.Hop);
|
||||
}
|
||||
|
||||
WriteInformation(msg, PSHostTag);
|
||||
WriteInformation(msg, s_PSHostTag);
|
||||
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, msg);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, msg);
|
||||
WriteProgress(record);
|
||||
}
|
||||
|
||||
private void WriteTraceRouteFooter()
|
||||
{
|
||||
WriteInformation(TestConnectionResources.TraceRouteComplete, PSHostTag);
|
||||
WriteInformation(TestConnectionResources.TraceRouteComplete, s_PSHostTag);
|
||||
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
record.RecordType = ProgressRecordType.Completed;
|
||||
WriteProgress(record);
|
||||
}
|
||||
@@ -511,9 +509,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
public List<TraceRouteReply> Replies { get; }
|
||||
}
|
||||
|
||||
#endregion TracerouteTest
|
||||
#endregion TracerouteTest
|
||||
|
||||
#region MTUSizeTest
|
||||
#region MTUSizeTest
|
||||
private void ProcessMTUSize(String targetNameOrAddress)
|
||||
{
|
||||
PingReply reply, replyResult = null;
|
||||
@@ -540,7 +538,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
PingOptions pingOptions = new PingOptions(MaxHops, true);
|
||||
int retry = 1;
|
||||
|
||||
while (LowMTUSize < (HighMTUSize-1))
|
||||
while (LowMTUSize < (HighMTUSize - 1))
|
||||
{
|
||||
byte[] buffer = GetSendBuffer(CurrentMTUSize);
|
||||
|
||||
@@ -585,7 +583,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
}
|
||||
|
||||
CurrentMTUSize = (LowMTUSize + HighMTUSize) /2;
|
||||
CurrentMTUSize = (LowMTUSize + HighMTUSize) / 2;
|
||||
|
||||
// Prevent DoS attack.
|
||||
Thread.Sleep(100);
|
||||
@@ -627,12 +625,12 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
private void WriteMTUSizeHeader(string resolvedTargetName, string targetAddress)
|
||||
{
|
||||
TestConnectionProgressBarActivity = StringUtil.Format(TestConnectionResources.MTUSizeDetectStart,
|
||||
_testConnectionProgressBarActivity = StringUtil.Format(TestConnectionResources.MTUSizeDetectStart,
|
||||
resolvedTargetName,
|
||||
targetAddress,
|
||||
BufferSize);
|
||||
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
WriteProgress(record);
|
||||
}
|
||||
|
||||
@@ -640,20 +638,20 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
var msg = StringUtil.Format(TestConnectionResources.MTUSizeDetectDescription, currentMTUSize, retry);
|
||||
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, msg);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, msg);
|
||||
WriteProgress(record);
|
||||
}
|
||||
|
||||
private void WriteMTUSizeFooter()
|
||||
{
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
record.RecordType = ProgressRecordType.Completed;
|
||||
WriteProgress(record);
|
||||
}
|
||||
|
||||
#endregion MTUSizeTest
|
||||
#endregion MTUSizeTest
|
||||
|
||||
#region PingTest
|
||||
#region PingTest
|
||||
|
||||
private void ProcessPing(String targetNameOrAddress)
|
||||
{
|
||||
@@ -743,15 +741,15 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
private void WritePingHeader(string resolvedTargetName, string targetAddress)
|
||||
{
|
||||
TestConnectionProgressBarActivity = StringUtil.Format(TestConnectionResources.MTUSizeDetectStart,
|
||||
_testConnectionProgressBarActivity = StringUtil.Format(TestConnectionResources.MTUSizeDetectStart,
|
||||
resolvedTargetName,
|
||||
targetAddress,
|
||||
BufferSize);
|
||||
|
||||
WriteInformation(TestConnectionProgressBarActivity, PSHostTag);
|
||||
WriteInformation(_testConnectionProgressBarActivity, s_PSHostTag);
|
||||
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId,
|
||||
TestConnectionProgressBarActivity,
|
||||
_testConnectionProgressBarActivity,
|
||||
ProgressRecordSpace);
|
||||
WriteProgress(record);
|
||||
}
|
||||
@@ -772,17 +770,17 @@ namespace Microsoft.PowerShell.Commands
|
||||
reply.Options?.Ttl);
|
||||
}
|
||||
|
||||
WriteInformation(msg, PSHostTag);
|
||||
WriteInformation(msg, s_PSHostTag);
|
||||
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, msg);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, msg);
|
||||
WriteProgress(record);
|
||||
}
|
||||
|
||||
private void WritePingFooter()
|
||||
{
|
||||
WriteInformation(TestConnectionResources.PingComplete, PSHostTag);
|
||||
WriteInformation(TestConnectionResources.PingComplete, s_PSHostTag);
|
||||
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, TestConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
ProgressRecord record = new ProgressRecord(s_ProgressId, _testConnectionProgressBarActivity, ProgressRecordSpace);
|
||||
record.RecordType = ProgressRecordType.Completed;
|
||||
WriteProgress(record);
|
||||
}
|
||||
@@ -815,7 +813,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
public List<PingReply> Replies { get; }
|
||||
}
|
||||
|
||||
#endregion PingTest
|
||||
#endregion PingTest
|
||||
|
||||
private bool InitProcessPing(String targetNameOrAddress, out String resolvedTargetName, out IPAddress targetAddress)
|
||||
{
|
||||
@@ -859,9 +857,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
if (IPv6 || IPv4)
|
||||
{
|
||||
AddressFamily addressFamily = IPv6 ? AddressFamily.InterNetworkV6 :AddressFamily.InterNetwork;
|
||||
AddressFamily addressFamily = IPv6 ? AddressFamily.InterNetworkV6 : AddressFamily.InterNetwork;
|
||||
|
||||
foreach(var address in hostEntry.AddressList)
|
||||
foreach (var address in hostEntry.AddressList)
|
||||
{
|
||||
if (address.AddressFamily == addressFamily)
|
||||
{
|
||||
@@ -911,7 +909,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
if (bufferSize == DefaultSendBufferSize && s_DefaultSendBuffer == null)
|
||||
{
|
||||
s_DefaultSendBuffer= sendBuffer;
|
||||
s_DefaultSendBuffer = sendBuffer;
|
||||
}
|
||||
|
||||
return sendBuffer;
|
||||
@@ -924,7 +922,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
/// Create the default send buffer once and cache it.
|
||||
private const int DefaultSendBufferSize = 32;
|
||||
private static byte[] s_DefaultSendBuffer= null;
|
||||
private static byte[] s_DefaultSendBuffer = null;
|
||||
|
||||
// Random value for WriteProgress Activity Id.
|
||||
private static readonly int s_ProgressId = 174593053;
|
||||
@@ -933,5 +931,5 @@ namespace Microsoft.PowerShell.Commands
|
||||
private const string ProgressRecordSpace = " ";
|
||||
|
||||
private const string TestConnectionExceptionId = "TestConnectionException";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-20
@@ -20,7 +20,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
[Alias("gtz")]
|
||||
public class GetTimeZoneCommand : PSCmdlet
|
||||
{
|
||||
#region Parameters
|
||||
#region Parameters
|
||||
|
||||
/// <summary>
|
||||
/// A list of the local time zone ids that the cmdlet should look up.
|
||||
@@ -43,7 +43,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
||||
public string[] Name { get; set; }
|
||||
|
||||
#endregion Parameters
|
||||
#endregion Parameters
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the ProcessRecord method for Get-TimeZone
|
||||
@@ -124,13 +124,13 @@ namespace Microsoft.PowerShell.Commands
|
||||
[Alias("stz")]
|
||||
public class SetTimeZoneCommand : PSCmdlet
|
||||
{
|
||||
#region string constants
|
||||
#region string constants
|
||||
|
||||
private const string TimeZoneTarget = "Local System";
|
||||
|
||||
#endregion string constants
|
||||
#endregion string constants
|
||||
|
||||
#region Parameters
|
||||
#region Parameters
|
||||
|
||||
/// <summary>
|
||||
/// The name of the local time zone that the system should use.
|
||||
@@ -156,7 +156,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
[Parameter]
|
||||
public SwitchParameter PassThru { get; set; }
|
||||
|
||||
#endregion Parameters
|
||||
#endregion Parameters
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the ProcessRecord method for Get-TimeZone
|
||||
@@ -320,7 +320,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
}
|
||||
|
||||
#region Helper functions
|
||||
#region Helper functions
|
||||
|
||||
/// <summary>
|
||||
/// True if the current process has access to change the time zone setting.
|
||||
@@ -424,9 +424,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
throw new Win32Exception(error);
|
||||
}
|
||||
|
||||
#endregion Helper functions
|
||||
#endregion Helper functions
|
||||
|
||||
#region Win32 interop helper
|
||||
#region Win32 interop helper
|
||||
|
||||
internal class NativeMethods
|
||||
{
|
||||
@@ -437,7 +437,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
}
|
||||
|
||||
#region Native DLL locations
|
||||
#region Native DLL locations
|
||||
|
||||
private const string SetDynamicTimeZoneApiDllName = "api-ms-win-core-timezone-l1-1-0.dll";
|
||||
private const string GetTimeZoneInformationForYearApiDllName = "api-ms-win-core-timezone-l1-1-0.dll";
|
||||
@@ -449,9 +449,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
private const string CloseHandleApiDllName = "api-ms-win-downlevel-kernel32-l1-1-0.dll";
|
||||
private const string SendMessageTimeoutApiDllName = "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll";
|
||||
|
||||
#endregion Native DLL locations
|
||||
#endregion Native DLL locations
|
||||
|
||||
#region Win32 SetDynamicTimeZoneInformation imports
|
||||
#region Win32 SetDynamicTimeZoneInformation imports
|
||||
|
||||
/// <summary>
|
||||
/// Used to marshal win32 SystemTime structure to managed code layer
|
||||
@@ -604,9 +604,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
[DllImport(GetTimeZoneInformationForYearApiDllName, SetLastError = true)]
|
||||
public static extern bool GetTimeZoneInformationForYear([In] ushort wYear, [In] ref DYNAMIC_TIME_ZONE_INFORMATION pdtzi, ref TIME_ZONE_INFORMATION ptzi);
|
||||
|
||||
#endregion Win32 SetDynamicTimeZoneInformation imports
|
||||
#endregion Win32 SetDynamicTimeZoneInformation imports
|
||||
|
||||
#region Win32 AdjustTokenPrivilege imports
|
||||
#region Win32 AdjustTokenPrivilege imports
|
||||
|
||||
/// <summary>
|
||||
/// Definition of TOKEN_QUERY constant from Win32 API
|
||||
@@ -715,9 +715,9 @@ namespace Microsoft.PowerShell.Commands
|
||||
public int Attributes;
|
||||
}
|
||||
|
||||
#endregion Win32 AdjustTokenPrivilege imports
|
||||
#endregion Win32 AdjustTokenPrivilege imports
|
||||
|
||||
#region Win32 SendMessage imports
|
||||
#region Win32 SendMessage imports
|
||||
|
||||
/// <summary>
|
||||
/// Definition of WM_SETTINGCHANGE constant from Win32 API
|
||||
@@ -748,10 +748,10 @@ namespace Microsoft.PowerShell.Commands
|
||||
[DllImport(SendMessageTimeoutApiDllName, SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, ref int lpdwResult);
|
||||
|
||||
#endregion Win32 SendMessage imports
|
||||
#endregion Win32 SendMessage imports
|
||||
}
|
||||
|
||||
#endregion Win32 interop helper
|
||||
#endregion Win32 interop helper
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -760,14 +760,14 @@ namespace Microsoft.PowerShell.Commands
|
||||
/// </summary>
|
||||
internal static class TimeZoneHelper
|
||||
{
|
||||
#region Error Ids
|
||||
#region Error Ids
|
||||
|
||||
internal const string TimeZoneNotFoundError = "TimeZoneNotFound";
|
||||
internal const string MultipleMatchingTimeZonesError = "MultipleMatchingTimeZones";
|
||||
internal const string InsufficientPermissionsError = "InsufficientPermissions";
|
||||
internal const string SetTimeZoneFailedError = "SetTimeZoneFailed";
|
||||
|
||||
#endregion Error Ids
|
||||
#endregion Error Ids
|
||||
|
||||
/// <summary>
|
||||
/// Find the system time zone by checking first against StandardName and then,
|
||||
|
||||
Reference in New Issue
Block a user