Create a script from another script

rated by 0 users
This post has 1 Reply | 1 Follower

Not Ranked
Posts 5
ykket Posted: 04-26-2012 7:53 AM

Basically what I am trying to do is have a master script. Within that script would be several variables that would hold the contents of other scripts. When run, the master script would create the .ps1 on the fly and insert the contents of the variables to generate several other scripts. Is there a way of doing this? Thanks

Top 75 Contributor
Posts 33

$variable1 = 1
$variable2 = 2

$script1 = "
#this is just a example script
$variable1 + $variable2
"
$script1 | out-file c:\scripts\script1.ps1

The above script would take the variables/ints and output a string to a ps1 file. Just schedule or run it everytime you update the variables.

Page 1 of 1 (2 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.