Repository: PowerShell/PowerShell
File: src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs (C#)

Code before:
            string additionalmessage = string.Empty;
            if (ex.NativeErrorCode.Equals(0x00000035))
            {
                additionalmessage = StringUtil.Format(ComputerResources.NetworkPathNotFound, computername);
            }

            string message = StringUtil.Format(ComputerResources.OperationFailed, ex.Message, computername, additionalmessage);
            ErrorRecord er = new(new InvalidOperationException(message), "InvalidOperationException", ErrorCategory.InvalidOperation, computername);
            cmdlet.WriteError(er);
        }

        /// <summary>
        /// Check whether the new computer name is valid.
        /// </summary>
        /// <param name="computerName"></param>
        /// <returns></returns>
        internal static bool IsComputerNameValid(string computerName)
        {
            bool hasNonDigit = false;

            if (computerName.Length >= 64)
                return false;

            foreach (char t in computerName)
            {
                if (t is '-' || char.IsAsciiLetter(t))
                {
                    hasNonDigit = true;
                    continue;
                }
                else if (!char.IsAsciiDigit(t))
                {
                    return false;
                }
            }

            return hasNonDigit;
        }

        /// <summary>
        /// Invokes the Win32Shutdown command on provided target computer using WSMan
        /// over a CIMSession.  The flags parameter determines the type of shutdown operation
        /// such as shutdown, reboot, force etc.
        /// </summary>
        /// <param name="cmdlet">Cmdlet host for reporting errors.</param>
        /// <param name="isLocalhost">True if local host computer.</param>
        /// <param name="computerName">Target computer.</param>
        /// <param name="flags">Win32Shutdown flags.</param>
        /// <param name="credential">Optional credential.</param>
        /// <param name="authentication">Optional authentication.</param>
        /// <param name="formatErrorMessage">Error message format string that takes two parameters.</param>

Review comment (suggestion):
```suggestion
                if (char.IsAsciiLetter(t) || t == '-')
```

Code after:
            string additionalmessage = string.Empty;
            if (ex.NativeErrorCode.Equals(0x00000035))
            {
                additionalmessage = StringUtil.Format(ComputerResources.NetworkPathNotFound, computername);
            }

            string message = StringUtil.Format(ComputerResources.OperationFailed, ex.Message, computername, additionalmessage);
            ErrorRecord er = new(new InvalidOperationException(message), "InvalidOperationException", ErrorCategory.InvalidOperation, computername);
            cmdlet.WriteError(er);
        }

        /// <summary>
        /// Check whether the new computer name is valid.
        /// </summary>
        /// <param name="computerName"></param>
        /// <returns></returns>
        internal static bool IsComputerNameValid(string computerName)
        {
            bool hasAsciiLetterOrHyphen = false;

            if (computerName.Length >= 64)
                return false;

            foreach (char t in computerName)
            {
                if (char.IsAsciiLetter(t) || t is '-')
                {
                    hasAsciiLetterOrHyphen = true;
                }
                else if (!char.IsAsciiDigit(t))
                {
                    return false;
                }
            }

            return hasAsciiLetterOrHyphen;
        }

        /// <summary>
        /// Invokes the Win32Shutdown command on provided target computer using WSMan
        /// over a CIMSession.  The flags parameter determines the type of shutdown operation
        /// such as shutdown, reboot, force etc.
        /// </summary>
        /// <param name="cmdlet">Cmdlet host for reporting errors.</param>
        /// <param name="isLocalhost">True if local host computer.</param>
        /// <param name="computerName">Target computer.</param>
        /// <param name="flags">Win32Shutdown flags.</param>
        /// <param name="credential">Optional credential.</param>
        /// <param name="authentication">Optional authentication.</param>
        /// <param name="formatErrorMessage">Error message format string that takes two parameters.</param>
        /// <param name="ErrorFQEID">Fully qualified error Id.</param>