/build/static/layout/Breadcrumb_cap_w.png

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 5 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 5 years ago
    • Is there a wmi query for ip address I could maybe use?, cheers R - robertmmk 5 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 5 years ago
    • Thanks for your suggestion, I'll need to figure out how to go about it :(, thanks again for your help R - robertmmk 5 years ago
  • Are you using a captured image you created or doing an unattended install from media? - SMal.tmcc 5 years ago
    • Hi using a captured wim, not media cheers R - robertmmk 5 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 5 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 5 years ago

Answers (2)

Posted by: SMal.tmcc 5 years ago
Red Belt
2

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

Comments:
  • 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 5 years ago
    • Just to say, thanks for all your help, you are a star.. - robertmmk 5 years ago
Posted by: flip1001 5 years ago
Black Belt
1

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
exit

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


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

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

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

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

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


Comments:
  • 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 5 years ago
    • Just to say, thanks for all your help, you are a star.. - robertmmk 5 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