Locating and setting variables from text file
hello,
fairly new advanced powershell scripting here.
i have powershell script reads variables text file. can read whole lines , store them variables, want file contain text , variable descriptions make easy level 1 operators use , maintain if needed.
the structure of of file needs this:
------------------------------
description: use file change parameters, example updating password.
note: change content after "=" symbol. leading spaces ignored.
------line_separator-------
program_path = \\server\share\program.exe
program_options = /s
user_name = domain\username
password = password
-----------------------------------
i want script lines start specific description per variable , set after "=" separator variable while excluding leading spaces. in above example script set following variables follows:
$prog = \\server\share\program.exe
$opt = /s
$user = domain\username
$pass = password
can me figure out how ps parse file , set variables way?
thanks in advance!
hi,
well, why not use powershell comments?
<# ------------------------------ description: use file change parameters, example updating password. note: change content after "=" symbol. leading spaces ignored. ------line_separator------- #> $program_path = '\\server\share\program.exe' $program_options = '/s' $user_name = 'domain\username' $password = 'password' #-----------------------------------
then can import file ...
. .\config.ps1
cheers,
fred
ps: simple gui lot easier provide 1st level goons tools less break. there's non-free tool provide easy-to-use tools create guis , package scripts executables. it's great scripting in general, :)
there's no place 127.0.0.1
Windows Server > Windows PowerShell
Comments
Post a Comment