i am writing a simple script in powershell using "read-host -prompt" so that i can input some text that will then be used to create some environment variables.
You cannot do this straight :
####[int]$myVar = 10 Read too fast the question :)
#$myVar = Get-ItemProperty ...
#or
#myVar = Get-Content ...
$tempVar = Read-Host "Enter the value ($myVar is default)"
if ($tempVar)
{
$myVar = $tempVar
}
$myVar
# Store $myVar in the registry or in the file for next run
My bad, I answered without a good reading :) As @postanote said, If you need to keep a track of the value from each run, you can store it in a file (IMHO, I would avoid the profile.ps1) or in a personal registry key. Then read the file or the registry value to initialize your variable.