Collect domain names to automate admin script customization
Takeaway: TechRepublic asked members to submit their favorite Network Administration scripts and this is one of the responses. You can use this script to automate the collection of enterprise-specific domain names required for the customization of other admin scripts.
TechRepublic recently asked members to submit their favorite Network Administration scripts for possible publication. One of the first to make a submission was Kevin Wood. For his effort, Kevin earned $100 and the satisfaction of seeing his script published on TechRepublic.
Earn $100 for your admin script
Let us pay you for your original scripts so that we can publish them as downloads on TechRepublic and allow your fellow IT professionals to benefit from your scripting savvy. We only ask that you put in the appropriate comments to your scripts so that it's easy to tell what the script is doing and which variables might need to be customized. Send us your original Windows admin scripts and we'll pay you $100 for each one that we publish as a TechRepublic download.
Here in his own words and code is Kevin's admin script:
Many scripts that you can download or get from other sources, hard code-in the domain information. To use the script quickly, one tends to merely hard code-in the current domain information.
If as a consultant, you travel from client to client, you change locations (and domains) frequently, re-keying the information becomes annoying. Also if I share a script, telling the recipient, change this line for your domain, becomes a necessity.
I have a script called GetDomain.vbs. (Listing A) It generates the domain name in a variety of ways. I merely copy the appropriate information into my scripts and voila—they are now domain generic and portable.
Listing A
--==[GetDomain.vbs]==--
'get the DNS domain name and the netbios domain name
'* find domain name - LDAP
dim strBaseDN, strDNSDomain, oRootDSE
Set oRootDSE = GetObject("LDAP://rootDSE")
strBaseDN = "LDAP://" & oRootDSE.Get("defaultNamingContext")
strDNSDomain = oRootDSE.Get("defaultNamingContext")
'* use this line " & strDNSDomain
msgbox "User DNS domain = " & oRootDSE.Get("defaultNamingContext")
'* find domain name - Dotted - need LDAP domain as well for this part
dim arrDomain, intCountstrDotDomain
arrDomain = split(oRootDSE.Get("defaultNamingContext"), ",")
for intCount = 0 to ubound(arrDomain)
strDotDomain = strDotDomain & "." & mid(arrDomain(intcount),4)
next
strDotDomain = mid(strDotDomain,2)
msgbox "Dotted Domain = " & strDotDomain
'* find domain name - NetBIOS
dim WshNetwork, strDomainName
Set WshNetwork = WScript.CreateObject("WScript.Network")
strDomainName = WshNetwork.UserDomain
msgbox "User NetBIOS domain = " & WshNetwork.UserDomain
Print/View all Posts Comments on this article
|
|
|
|
SponsoredWhite Papers, Webcasts, and Downloads
- Building the Next Generation "Virtual, Cooler and Easier" Data Center with Rackonomics BLADE Network Technologies
- Oracle Web 2.0 Resource Library Oracle
- Calculate your energy savings with the IBM Power Configurator tool IBM
- Building a Small Office Network: Getting Started Cisco Systems
- Voice over IP FAQ Cisco Systems
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET
What it takes to stay on the edge of innovation
Going green and managing costs during tough economic times
Taking chances with the core brand
Transforming the company and developing new delivery platforms
