Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected virtual void Dispose(bool disposing)
[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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ private unsafe void Copy(char* source, int offset, int charsToCopy)
}

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];
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public string[] Path
/// </summary>
[Parameter(ParameterSetName = "LiteralPath",
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
[Alias("PSPath","LP")]
[Alias("PSPath", "LP")]
public string[] LiteralPath
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

namespace Microsoft.PowerShell.Commands
{
#region Restart-Computer
#region Restart-Computer

/// <summary>
/// This exception is thrown when the timeout expires before a computer finishes restarting
Expand Down Expand Up @@ -96,7 +96,7 @@ public RestartComputerTimeoutException(string message) : base(message) { }
/// </param>
public RestartComputerTimeoutException(string message, Exception innerException) : base(message, innerException) { }

#region Serialization
#region Serialization
/// <summary>
/// Serialization constructor for class RestartComputerTimeoutException
/// </summary>
Expand Down Expand Up @@ -143,7 +143,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
info.AddValue("ComputerName", ComputerName);
info.AddValue("Timeout", Timeout);
}
#endregion Serialization
#endregion Serialization
}

/// <summary>
Expand Down Expand Up @@ -175,7 +175,7 @@ public enum WaitForServiceTypes
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
Expand Down Expand Up @@ -365,9 +365,9 @@ public Int16 Delay
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
Expand Down Expand Up @@ -402,9 +402,9 @@ public void Dispose(bool disposing)
}
}

#endregion "IDisposable Members"
#endregion "IDisposable Members"

#region "Private Methods"
#region "Private Methods"

/// <summary>
/// Validate parameters for 'DefaultSet'
Expand Down Expand Up @@ -441,7 +441,7 @@ private void ValidateComputerNames()
}

// 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);
Expand Down Expand Up @@ -650,15 +650,16 @@ private void WriteOutTimeoutError(IEnumerable<string> computerNames)
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)
{
Expand Down Expand Up @@ -771,9 +772,9 @@ internal static List<string> TestPowerShell(List<string> computerNames, List<str
return psList;
}

#endregion "Internal Methods"
#endregion "Internal Methods"

#region "Overrides"
#region "Overrides"

/// <summary>
/// BeginProcessing method.
Expand Down Expand Up @@ -1089,12 +1090,12 @@ protected override void StopProcessing()
}
}

#endregion "Overrides"
#endregion "Overrides"
}

#endregion Restart-Computer
#endregion Restart-Computer

#region Stop-Computer
#region Stop-Computer

/// <summary>
/// cmdlet to stop computer
Expand All @@ -1103,14 +1104,14 @@ protected override void StopProcessing()
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
Expand Down Expand Up @@ -1157,7 +1158,7 @@ public sealed class StopComputerCommand : PSCmdlet, IDisposable

#endregion "parameters"

#region "IDisposable Members"
#region "IDisposable Members"

/// <summary>
/// Dispose Method
Expand All @@ -1171,9 +1172,9 @@ public void Dispose()
catch (ObjectDisposedException) { }
}

#endregion "IDisposable Members"
#endregion "IDisposable Members"

#region "Overrides"
#region "Overrides"

/// <summary>
/// ProcessRecord
Expand Down Expand Up @@ -1201,9 +1202,9 @@ protected override void StopProcessing()
catch (AggregateException) { }
}

#endregion "Overrides"
#endregion "Overrides"

#region Private Methods
#region Private Methods

private void ProcessWSManProtocol(object[] flags)
{
Expand Down Expand Up @@ -1246,12 +1247,12 @@ private void ProcessWSManProtocol(object[] flags)
}
}

#endregion
#endregion
}

#endregion
#endregion

#region Rename-Computer
#region Rename-Computer

/// <summary>
/// Renames a domain computer and its corresponding domain account or a
Expand All @@ -1263,17 +1264,17 @@ private void ProcessWSManProtocol(object[] flags)
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;

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
Expand Down Expand Up @@ -1348,9 +1349,9 @@ public SwitchParameter Restart
[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
Expand Down Expand Up @@ -1479,7 +1480,7 @@ private void DoRenameComputerWsman(string computer, string computerName, string
Microsoft.Management.Infrastructure.CimType.String,
(dPassword == null) ? CimFlags.NullValue : CimFlags.None));

if ( ! InternalTestHooks.TestRenameComputer )
if (!InternalTestHooks.TestRenameComputer)
{
CimMethodResult result = cimSession.InvokeMethod(
ComputerWMIHelper.CimOperatingSystemNamespace,
Expand Down Expand Up @@ -1553,9 +1554,9 @@ private void DoRenameComputerWsman(string computer, string computerName, string
}
}

#endregion "Private Methods"
#endregion "Private Methods"

#region "Override Methods"
#region "Override Methods"

/// <summary>
/// ProcessRecord method.
Expand Down Expand Up @@ -1588,12 +1589,12 @@ protected override void EndProcessing()
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>
Expand Down Expand Up @@ -1675,9 +1676,9 @@ private string FormatLine(string HasSucceeded, string newcomputername, string ol
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.
Expand Down Expand Up @@ -2103,7 +2104,7 @@ internal static bool InvokeWin32ShutdownUsingWsman(
Microsoft.Management.Infrastructure.CimType.SInt32,
CimFlags.None));

if ( ! InternalTestHooks.TestStopComputer )
if (!InternalTestHooks.TestStopComputer)
{
CimMethodResult result = cimSession.InvokeMethod(
ComputerWMIHelper.CimOperatingSystemNamespace,
Expand Down Expand Up @@ -2226,8 +2227,7 @@ internal static string ValidateComputerName(
return validatedComputerName;
}
}
#endregion Helper

#endregion Helper
}//End namespace

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ContentCommandBase : CoreCommandWithCredentialsBase, IDisposable
/// </summary>
[Parameter(ParameterSetName = "LiteralPath",
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
[Alias("PSPath","LP")]
[Alias("PSPath", "LP")]
public string[] LiteralPath
{
get { return Path; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public string[] Path
/// </summary>
[Parameter(ParameterSetName = "LiteralPath",
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
[Alias("PSPath","LP")]
[Alias("PSPath", "LP")]
public string[] LiteralPath
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public string[] Path
/// </summary>
[Parameter(ParameterSetName = "LiteralPath",
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
[Alias("PSPath","LP")]
[Alias("PSPath", "LP")]
public string[] LiteralPath
{
get { return paths; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public string[] Path
/// </summary>
[Parameter(ParameterSetName = literalChildrenSet,
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
[Alias("PSPath","LP")]
[Alias("PSPath", "LP")]
public string[] LiteralPath
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ private static DeviceGuardInfo GetDeviceGuard(CimSession session)
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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public string[] Path
/// </summary>
[Parameter(ParameterSetName = "LiteralPath",
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
[Alias("PSPath","LP")]
[Alias("PSPath", "LP")]
public string[] LiteralPath
{
get
Expand Down Expand Up @@ -197,7 +197,7 @@ public string[] Path
/// 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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public string[] Path
/// </summary>
[Parameter(ParameterSetName = "LiteralPath",
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
[Alias("PSPath","LP")]
[Alias("PSPath", "LP")]
public string[] LiteralPath
{
get { return paths; }
Expand Down
Loading