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 3:44pm

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 6:31pm

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 6:47pm

Hi Bob, thank you very much for providing this script. I have been looking for something like this for some time. However I seem to have an issue with it. I put this script right before the apply network settings task sequence and it appears as if the script and the apply network settings run successfully without error. However upon system reboot the IP information is gone. I have no idea how to troubleshoot this as there is no error in the smsts.log file regarding either of the above steps.
Free Windows Admin Tool Kit Click here and download it now
August 22nd, 2011 5:04pm

Not sure why it wouldn't work. Here's a script I put together to do a quick dump to check what the variables are doing. Dim sVar Set osdV4 = CreateObject("Microsoft.SMS.TSEnvironment") For Each sVar in osdv4.GetVariables() WScript.Echo "Variable " & sVar & ":" & osdv4(sVar) Next run it from the command prompt F8 before minisetup kicks in. cscript GetVars.vbs > c:\dump.txt This thing outputs a lot of stuff, so make sure you dump to a file and you don't use wscript. Bob
August 22nd, 2011 8:04pm

Hi Bob. I ran that little script you gave me, but I'm a little unclear about what you mean by minisetup? I ran that getvars script right after the Apply Network Settings, which obviously is before the system reboot. Here are some pertinent parts of that dump.txt: Variable OSDAdapter0DNSServerList:XX.XX.XX.XX Variable OSDAdapter0EnableDHCP:False Variable OSDAdapter0Gateways:XX.XX.XX.X Variable OSDAdapter0IPAddressList:XX.XX.XX.XX Variable OSDAdapter0SubnetMask:XX.XX.XX.XX Variable OSDAdapterCount:0 All of the DNS and IP information is correct so before the reboot, it looks like the OSD variables have been assigned, but aren't surviving the reboot. The OSDAdapterCount:0 is concerning to me however. Is there other parts of the dump that I could provide you that might help? Just for giggles, I ran the script immediately after the first reboot as soon as I could bring the F8 command prompt up and it tells me that ActiveX component can't create object: 'Microsoft.SMS.TSEnvironment'. It is finishing up the Setup Windows and ConfigMgr task sequence at that point. Just for more info, here is the order of the task sequence around the OSD Variables script: Apply Device Drivers Your OSD Variable Script Apply Network Settings Setup Windows and ConfigMgr. I really really appreciate the help so far. I feel like I am so close here to getting over this hump.
Free Windows Admin Tool Kit Click here and download it now
August 24th, 2011 3:24pm

Mini setup is when Windows does the actual setup using the info in the image and the task sequence. OSDAdapterCount set to zero tells me that you might not have an identified network adapter. Quick check, at the F8 command prompt, do an IPCONFIG and see if you have a network connection. If you don't that generally means the cable is unplugged or WinPE doesn't have the driver it needs and you need to add it. If you haven't added a driver to WinPE, I always work from another copy of the WIM, or at least make a backup. When you add a driver you have to add all of the drivers that you need and the ones that were already there. SCCM can show you what's already there.Bob
August 25th, 2011 9:25am

Bob, Thanks so much for the reply. So minisetup is prior to the first reboot? If so, then my dump was done correctly. At the F8 command prompt before the reboot (after OS image is laid down), I have network connectivity. From the moment I punch in the IP information at the WinPE prompt, I have network connectivity until after the first reboot. My drivers are in order on the WinPE boot disk (we don't have PXE, rather we mount virtual media to drac/ilo.). I'm wondering if I can modify collection settings on the collection to set OSDadaptercount = 1 so that might override the 0. I will give it a shot and let you know. Please let me know if you can think of anything else. I have been using this test box for a while so I know network connectivity is good as far as cabling and WinPE drivers. Again, I really appreciate the help. This is the last hump before we are done with OSD and ready to deploy in production.
Free Windows Admin Tool Kit Click here and download it now
August 25th, 2011 9:51am

Here is a new version of the script, I think it has a few tweaks in it, it's been a while. But I don't think it will solve your problem, neither will setting the variable in the collection. Try this, it might help, run the script as cscript StaticIPBoot and look at the output, it might give you some clue as to what's going on, or better yet change the script in the task sequence to: cscript StaticIPBoot.vbs > c:\ip.txt The script is fairly verbose, it might give you an idea of why it's not working. The only reason I can see for that variable to be zero is that the script isn't finding any network adapters, or DHCP is enabled. 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
August 25th, 2011 10:28am

Well, there actually is DHCP on the network I am building servers on, but its a Unix DHCP box that has no IP helpers so with the given IP address we can't see the SCCM servers or DPs. We want DHCP disabled on the NICs. Using collection variables previously, one of the variables was OSDAdapter0EnableDHCP = false so you might be right there. I think if I just change the top of your script near the DHCP part and just disable it right off the bat, we might be in business.
Free Windows Admin Tool Kit Click here and download it now
August 25th, 2011 10:38am

Your DHCP address can't see the SCCM servers? Your networking group needs to go figure out your problem, using static as a fix for a bad DHCP configuration isn't the answer. I'm not sure why the UNIX guys still control the network these days, with most of my customers they get it wrong a lot more often than they get it right. But assuming you can't get the problem fixed, unfortuntely fairly common, modifying the script is probably the best answer.Bob
August 25th, 2011 10:51am

Bob, I hear what you're screaming. They have taken over the DHCP and PXE environments with their Opsware deployment tool, and it doesn't play well with others. Unfortunately that DHCP is a fight we will have to wage later on, but for now we are the red-headed step child. In my opinion, you either don't have DHCP in your server environment or set it up so it can be used by all people who might need it. I have modified the script and am running a test. And in breaking news, I am still running a test with your original script but tried collection variables (Adapter count=1, enable WINS) and believe it or not it seems to have worked. IP information survived the reboot, despite not doing anything to actually disable DHCP which is odd. System came back up from the reboot and resumed the task sequence. F8 ipconfig confirms all IP info carried over.
Free Windows Admin Tool Kit Click here and download it now
August 25th, 2011 11:20am

Yeah, giving the UNIX guys control of the network is the biggest issue I always run into, that's been true for 15 years or so.Bob
August 25th, 2011 11:55am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics