Skip to content
Merged
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 @@ -2019,35 +2019,24 @@ internal static void WriteNonTerminatingError(int errorcode, PSCmdlet cmdlet, st
/// <returns></returns>
internal static bool IsComputerNameValid(string computerName)
{
bool allDigits = true;
bool hasAsciiLetterOrHyphen = false;

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

foreach (char t in computerName)
{
if (t >= 'A' && t <= 'Z' ||
t >= 'a' && t <= 'z')
if (char.IsAsciiLetter(t) || t is '-')
{
allDigits = false;
continue;
}
else if (t >= '0' && t <= '9')
{
continue;
hasAsciiLetterOrHyphen = true;
}
else if (t == '-')
{
allDigits = false;
continue;
}
else
else if (!char.IsAsciiDigit(t))
{
return false;
}
}

return !allDigits;
return hasAsciiLetterOrHyphen;
}

/// <summary>
Expand Down
Loading