I need a vbscript to create a variable for OS installation

Hi there, hope you can help, here we have 20 remote locations around the world and each has an answer file depending on location. Up till now we used the unknown computer suppoirt for building our machines but I am trying to cretate a lite touch eventual zero touch build but have run into issues with choosing the correct OS answer file. Each location has the same windows 10.wim but different answer file depending on site. Does anyone know how to cerate a variable I can use for choosing the corerct location as the machines are still in WINPE and so have the minnit name and not the correct asset name. We use SCCM current branch. Thanks so much if anyone can help..

4 Comments   [ + ] Show comments
  • Can you do it based on IP address? If it matches a specific location pull a specific unattend file. - cserrins 2 years ago
    • Hi there, I was trying to do like what you said but am not sure how to go about it, was thinking as the machine will get the boot.wim from dp can I copy down a file to x:something and target that as a location in the os install step?, probably a bad way to do it :), I was trying to figure out to get the onsite dp ip and match that to the site or something, is there a way to do that, thanks for your help R - robertmmk 2 years ago
    • Is there a wmi query for ip address I could maybe use?, cheers R - robertmmk 2 years ago
  • 1 up to what that person said. Bit tricky that one cos you really only have access to the IP address and maybe the SCCM DP - which kinda could tell where you are.

    Reckon IP and subset is your best bet. If you go this one, recommend you store the tables on the network, and you look them up when you image - make it scaleable, so you can add more ip ranges in later etc. - rileyz 2 years ago
    • Thanks for your suggestion, I'll need to figure out how to go about it :(, thanks again for your help R - robertmmk 2 years ago
  • Are you using a captured image you created or doing an unattended install from media? - SMal.tmcc 2 years ago
    • Hi using a captured wim, not media cheers R - robertmmk 2 years ago
      • that helps, I need to come up with something to overwrite the C:\windows\panther xml file then. Do you just need to replace a couple of the values in the xml or is there a lot of differences between files? - SMal.tmcc 2 years ago
  • Wow that's sounds doable, the xml differences are timezone, language keyboard and maybe one or two more, do you mean let the OS install with same xml, then overwrite after, can this be done? Thanks R - robertmmk 2 years ago

Answers (2)

Posted by: SMal.tmcc 2 years ago
Red Belt

you can use powershell or a batch file to replace text in a flie. You would need one line for every line you want to replace.

powershell -Command "(gc C:\Windows\Panther\unattended.xml) -replace 'this  text', 'that text' | Out-File C:\Windows\Panther\unattended.xml"

in a batch file

@echo off     setlocal enableextensions disabledelayedexpansion
for /f "delims=" %%i in ('type "C:\Windows\Panther\unattended.xml" ^& break ^> "%C:\Windows\Panther\unattended.xml%" ') do ( set "line=%%i" setlocal enabledelayedexpansion >>"C:\Windows\Panther\unattended.xml" echo(!line:%search%=%replace%! endlocal

  • I use Kace but same end result:

    I had to do replace a line in my answer file due to a change for all my images and I used the powershell command as a WinPE task. I have PS installed into my pe boot env

    To add for SCCM:
    https://www.google.com/search?q=add+powershell+to+winpe+sccm&sourceid=ie7&rls=com.microsoft:en-US:IE-SearchBox&ie=&oe= - SMal.tmcc 2 years ago
    • Just to say, thanks for all your help, you are a star.. - robertmmk 2 years ago
Posted by: flip1001 2 years ago
Black Belt

I just whipped this up right now, but since I do not have experience with SCCM, I don't know if you can use batch files.

Should be very easy to do something like this in vbscript if that is the requirement.

@echo off

REM Place all prepopulated xml files
REM with the batch file

REM IP Ranges to search
REM ------------------------------------------

REM Site 1
ipconfig | find "192.168.0."
if [%errorlevel%] equ [0] (goto :site1)

REM Site 2
ipconfig | find "192.168.1."
if [%errorlevel%] equ [0] (goto :site2)

REM Site 3
ipconfig | find "192.168.2."
if [%errorlevel%] equ [0] (goto :site3)

REM If the IP did not match
REM Either copy a default config
REM Or exit with no copy
REM copy /Y default.xml C:\windows\panther.xml

REM ------------------------------------------

REM Section to copy xml files
REM ------------------------------------------

copy /Y site1.xml C:\windows\panther.xml

copy /Y site2.xml C:\windows\panther.xml

copy /Y site3.xml C:\windows\panther.xml

REM ------------------------------------------

  • On 2nd thought, it would be better to redirect the ipconfig output to a temp file and then use the find command on the output, for speed and reliability. - flip1001 2 years ago
    • Just to say, thanks for all your help, you are a star.. - robertmmk 2 years ago
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ