generate this script using another script Raw
if ($home_dst_folder -ne $null){$folder_in_here = $home_dst_folder.Replace("\","/")}

$new_Update                 = "update"
$network_status             = "local"
$project_anun               = "anun"

# apps to be downloaded from
$zipFileName                = 'apps.zip' 
$pojectFolderName           = 'test_folder'
$Turl3                      = $Turl1 + $apps_folder_under + $bslash + $pojectFolderName + $bslash + $zipFileName

# application configuration
# de config xml file to serarch and replace 
$xml_elements = @{
	'loggingFilePath'       = $folder_in_here + '/logs/%1$s-de-db.%2$s'
	'de.uploads.path'       = $folder_in_here + '/resources/current/%1$s/uploads'
	'de.resources.current'  = 'file:///' + $folder_in_here + '/resources/current'
}

#################
scenario 1
#################
how can i generate the script above from another powershell script other than outputting all the variables and their values e.g. 

$new_update_value = read-host "what is the script for ?"
$network_status_value = read-host "what is the network type ?"

$line1 = '$new_Update = ' + $new_update_value
$line2 = '$network_status = ' + $network_status_value

$file = "c:\config.ps1"
$line1 >> $file
$line2 >> $file

#################
scenario 2
#################
<?xml version="1.0" encoding="utf-8"?>
<main_config>
  <configs>
    <obj name="new_Update"            value="update"/>
    <obj name="network_status"        value="local"/>
    <obj name="project_anun"          value="anun"/>
    <obj name="zipFileName"           value="apps.zip"/>
    <obj name="pojectFolderName"      value="test_folder"/>
    <obj name="Turl3"                 value="$Turl1 + $apps_folder_under + $bslash + $pojectFolderName + $bslash + $zipFileName"/>

  </configs>
</main_config>

how can i generate a hahstable from an xml file to use it as a config file instead of ps1,
note the above example that there are variables inside hash table that should be treated as variables when parsed.
i was able to convert all the static entries to xml file but i don't know how to deal with variables so that
powershell treats them as variables and not strings

thanks in advance



  • Edited by Vagharsh Friday, July 31, 2015 7:21 AM
July 31st, 2015 7:20am

thanks for that , it helps a lot

is there other choices to use a file to store variables (hashtables, variables inside variables)

i dontt want to have multiple config files one ps1 and other xml i prefer not to use ps1 as config file 

  • Edited by Vagharsh Friday, July 31, 2015 7:36 AM
Free Windows Admin Tool Kit Click here and download it now
July 31st, 2015 7:33am

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

Other recent topics Other recent topics