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..
Answers (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
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 ------------------------------------------
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