{"id":487,"date":"2013-03-25T21:09:11","date_gmt":"2013-03-25T20:09:11","guid":{"rendered":"http:\/\/michlstechblog.info\/blog\/?p=487"},"modified":"2013-03-26T15:31:57","modified_gmt":"2013-03-26T14:31:57","slug":"windows-script-to-get-the-netbios-name-of-an-active-directory-domain","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/windows-script-to-get-the-netbios-name-of-an-active-directory-domain\/","title":{"rendered":"Windows: Script to get the NetBIOS Name of an Active Directory Domain"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_487 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_487')){$('.twoclick_social_bookmarks_post_487').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Windows%3A%20Script%20to%20get%20the%20NetBIOS%20Name%20of%20an%20Active%20Directory%20Domain\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Ajust%20a%20short%20post%20%3A-%29.%20A%20powershell%20script%20to%20get%20the%20NetBIOS%20Name%20of%20an%20Active%20Directory%20Domain%0D%0A%0D%0A%5Bpowershell%5D%0D%0A%0D%0A%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%0D%0A%23%20Gets%20the%20NetBIOS%20Domain%0D%0A%23%20Author%20Michael%20Albert%20michlstechblog.info%0D%0A%23%20License%3A%20GPL%20v2%0D%0A%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%0D%0A%5Breflection.assembly%20...\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/windows-script-to-get-the-netbios-name-of-an-active-directory-domain\\\/\",\"post_id\":487,\"post_title_referrer_track\":\"Windows%3A+Script+to+get+the+NetBIOS+Name+of+an+Active+Directory+Domain\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>just a short post :-). A powershell script to get the NetBIOS Name of an Active Directory Domain<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n\r\n###############################################################################\r\n# Gets the NetBIOS Domain\r\n# Author Michael Albert michlstechblog.info\r\n# License: GPL v2\r\n###############################################################################\r\n&#x5B;reflection.assembly]::LoadWithPartialName(&quot;System.DirectoryServices.Protocols&quot;)|Out-Null\r\n\r\nif($args.count -ne 1){\r\n    Write-Warning &quot; Start script with fqdn as parameter&quot;\r\n    Write-Warning (&quot; for example: &quot;+$myInvocation.myCommand.name+&quot; yourdomain.com&quot;)\r\n    exit 1\r\n}\r\n$sDomainName=$args&#x5B;0]\r\n# Get AD Root\r\n$oRootDSE = &#x5B;ADSI]&quot;LDAP:\/\/RootDSE&quot;\r\n$sConfig = $oRootDSE.Get(&quot;configurationNamingContext&quot;)\r\n# AD Object AD Root\r\n$oADSearchRoot=New-object System.DirectoryServices.DirectoryEntry(&quot;LDAP:\/\/CN=Partitions,&quot; + $sConfig)\r\n# Search for Netbiosname of the specified domain\r\n$sSearchString=&quot;(&amp;(objectclass=Crossref)(dnsRoot=&quot;+$sDomainName+&quot;)(netBIOSName=*))&quot;\r\n$oSearch=New-Object directoryservices.DirectorySearcher($oADSearchRoot,$sSearchString)\r\n$sNetBIOSName=($oSearch.FindOne()).Properties&#x5B;&quot;netbiosname&quot;]\r\n# Print out\r\nWrite-Host &quot;Domain NetBIOS Name:&quot; $sNetBIOSName\r\n\r\n<\/pre>\n<p>Have fun :-)!<\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, just a short post :-). A powershell script to get the NetBIOS Name of an Active Directory Domain ############################################################################### # Gets the NetBIOS Domain # Author Michael Albert michlstechblog.info # License: GPL v2 ############################################################################### &#x5B;reflection.assembly]::LoadWithPartialName(&quot;System.DirectoryServices.Protocols&quot;)|Out-Null if($args.count -ne 1){ Write-Warning &quot; Start script with fqdn as parameter&quot; Write-Warning (&quot; for example: &quot;+$myInvocation.myCommand.name+&quot; yourdomain.com&quot;) exit 1 &hellip; <a href=\"https:\/\/michlstechblog.info\/blog\/windows-script-to-get-the-netbios-name-of-an-active-directory-domain\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Windows: Script to get the NetBIOS Name of an Active Directory Domain<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[101,45,73,102,100,97],"class_list":["post-487","post","type-post","status-publish","format-standard","hentry","category-windowsscripts","tag-active","tag-directory","tag-get","tag-name","tag-netbios","tag-netbios-domain-name"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=487"}],"version-history":[{"count":11,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/487\/revisions"}],"predecessor-version":[{"id":520,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/487\/revisions\/520"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}