Boot from Media and static IP script
I thought I would give back a bit to the community. My current engagement has a client where 2/3 of the computers are not on DHCP, and probably won't be anytime soon. There is a feature deficiency in the SCCM boot from media function, it lets
you set the IP address in the initial WinPE startup, but that address isn't communicated to Windows. Windows comes up expecting to find DHCP. Hint, hint here anyone from the product group, this should be added to the Apply Network Settings task
:)
This script needs to be put in the task sequence right before the Apply Network Settings task sequence step. The script will check to see if the variables were already set in Windows (which works correctly). If not (only happens when you are
doing a new install) it will read the entries from WinPE and write them to the TS variables needed by Apply Network Settings.
There is a limitation to the scipt that it can only put in as much as can be entered by WinPE. So things like multiple DNS servers for example can't be entered into PE, so they can't be transfered to Windows.
Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2")
WQL = "Select * from Win32_NetworkAdapterConfiguration where IPEnabled = TRUE"
Set colNetAdapters = objWMIService.ExecQuery (WQL)
WScript.Echo "Number of adapters is " & colNetAdapters.Count
set objSCCM = CreateObject("Microsoft.SMS.TSEnvironment")
if objSCCM("OSDAdapter0IPAddressList") = "" then
For Each objNetAdapter In colNetAdapters
if objNetAdapter.DHCPEnabled then
WScript.Echo "DHCP Enabled"
else
WScript.Echo "DHCP Disabled"
objSCCM("OSDAdapter0EnableDHCP") = false
if Not IsNull (objNetAdapter.IPAddress) then
strIPAddress = objNetAdapter.IPAddress(0)
WScript.Echo "IP Address: " & strIPAddress
objSCCM("OSDAdapter0IPAddressList") = strIPAddress
end if
if Not IsNull (objNetAdapter.IPSubnet) then
strIPSubnet = objNetAdapter.IPSubnet(0)
WScript.Echo "IP Subnet: " & strIPSubnet
objSCCM("OSDAdapter0SubnetMask") = strIPSubnet
end if
if Not IsNull (objNetAdapter.DefaultIPGateway) then
strIPGateway = objNetAdapter.DefaultIPGateway(0)
WScript.Echo "IP Gateway: " & strIPGateway
objSCCM("OSDAdapter0Gateways") = strIPGateway
end if
if Not IsNull (objNetAdapter.DNSServerSearchOrder) then
strDNSServerSearchOrder = objNetAdapter.DNSServerSearchOrder(0)
WScript.Echo "DNS Server: " & strDNSServerSearchOrder
objSCCM("OSDAdapter0DNSServerList") = strDNSServerSearchOrder
end if
if Not IsNull (objNetAdapter.MACAddress) then
strMACAddress = objNetAdapter.MACAddress(0)
WScript.Echo "MAC Address: " & strMACAddress
end if
if Not IsNull (objNetAdapter.DNSDomainSuffixSearchOrder) then
strDNSDomainSuffixSearchOrder = objNetAdapter.DNSDomainSuffixSearchOrder(0)
WScript.Echo "DNS DOMAIN: " & strDNSDomainSuffixSearchOrder
end if
if Not IsNull (objNetAdapter.WINSPrimaryServer) then
strWins = objNetAdapter.WINSPrimaryServer
objSCCM("OSDAdapter0EnableWINS") = true
if Not IsNull (objNetAdapter.WINSSecondaryServer) then
strWins = strWins & "," & objNetAdapter.WINSSecondaryServer
end if
WSCript.Echo "WINS Server: " & strWins
objSCCM("OSDAdapter0WINSServerList") = strWins
else
objSCCM("OSDAdapter0EnableWINS") = false
end if
objSCCM("OSDAdapterCount") = 1
end if
Next
End IfBob
May 26th, 2011 8:58am
MDT 2010 has the option to set static IP in Winpe
Free Windows Admin Tool Kit Click here and download it now
May 26th, 2011 1:42pm
That's true but we aren't using MDT. The customer I'm at couldn't begin to support MDT after we left. Besides there is very little in MDT that we need, SCCM provides just about everything we need. Bob
May 26th, 2011 1:58pm
That's true but we aren't using MDT. The customer I'm at couldn't begin to support MDT after we left. Besides there is very little in MDT that we need, SCCM provides just about everything we need. Bob
Free Windows Admin Tool Kit Click here and download it now
May 26th, 2011 1:58pm
MDT 2010 has the option to set static IP in Winpe
May 26th, 2011 6:31pm