RegEx validate NetBIOS computer name for Domain Controllers

1
2
3
4
5
6
7
8
9
# DomainController NetBIOS naming convention validation - using RegEx.
# This RegEx requires 1-11 characters in length, allows A-Z and 0-9 PLUS Requiring an additional 4 characters, to be 'DC' followed by 2 digits.
$regString = '^[A-Z0-9-]{1,11}DC[0-9]{2}$'
$netBIOSname = 'ADFREWGEHDEDC01'
If ($netBIOSname -cmatch $regString){
    Write-Host "Name passes"
}else{
    Write-Host "Name fails"
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.