Hi,
just a short post :-). A powershell script to get the NetBIOS Name of an Active Directory Domain
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ############################################################################### # Gets the NetBIOS Domain # Author Michael Albert michlstechblog.info # License: GPL v2 ############################################################################### [reflection.assembly] ::LoadWithPartialName( "System.DirectoryServices.Protocols" ) |Out -Null if ( $args .count -ne 1){ Write-Warning " Start script with fqdn as parameter" Write-Warning ( " for example: " + $myInvocation .myCommand.name+ " yourdomain.com" ) exit 1 } $sDomainName = $args [0] # Get AD Root $oRootDSE = [ADSI] "LDAP://RootDSE" $sConfig = $oRootDSE .Get( "configurationNamingContext" ) # AD Object AD Root $oADSearchRoot = New-object System.DirectoryServices.DirectoryEntry( "LDAP://CN=Partitions," + $sConfig ) # Search for Netbiosname of the specified domain $sSearchString = "(&(objectclass=Crossref)(dnsRoot=" + $sDomainName + ")(netBIOSName=*))" $oSearch = New-Object directoryservices.DirectorySearcher( $oADSearchRoot , $sSearchString ) $sNetBIOSName =( $oSearch .FindOne()).Properties[ "netbiosname" ] # Print out Write-Host "Domain NetBIOS Name:" $sNetBIOSName |
Have fun :-)!
Michael