Obtaining WDS server IP from WDS PXE boot

by Ravikanth on March 31, 2009

Recently, I worked on some automation related to OS recovery using WDS and in that process I needed to obtain the WDS server IP address using a script. In this scenario, I used a custom WinPE boot image and no install image. Hence, I modified startnet.bat to invoke a custom application to do OS recovery. Coming to the subject of this post, when ever we use a WinPE boot image and use WDS PXE method to boot the client, boot server information is stored in WinPE registry as HKLM\SYSTEM\CurrentControlSet\Control\PXE\BootServerReply. Presence of this key itself indicates that the system booted off a WDS server. However, this entry is a binary value and does not directly give any information about WDS server name or IP address. We need to parse the a few bytes of information to obtain the right values. Within this binary value, IP address information starts at byte offset 20. So, here is the script to do that job

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = “.”
Set objReg = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & _
strComputer & “\root\default:StdregProv”)
strKeypath = “SYSTEM\CurrentControlSet\Control\PXE”
strEntryName = “BootServerReply”
objReg.GetBinaryValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, arrValue
Wscript.Echo arrvalue(20) & “.” & arrValue(21) & “.” & arrValue(22) & “.” & arrValue(23)

Ravikanth

A technology enthu and a Windows PowerShell MVP working on SharePoint solutions at Dell Inc. Has deep interests in Windows Server OS & Virtualization.

More Posts - Website - Twitter - Facebook

Previous post:

Next post: