I'm making a menu system for a script I have where I can change the values I need to by using the menu or by passing them as arguments to the script. One of the annoyances I have at the moment is after entering a new value when the menu refreshes, the variable in the menu text does not update to the new values.
$global:drive="C:"
$title = "Setup
"
$message = "The default variables are:
VARIABLES TO CHANGE
1. The Drive Location: $global:drive <<<--- This is the variable that does not update after I change it when I run the script.
"
$one = New-Object System.Management.Automation.Host.ChoiceDescription "&1 Drive", "The Drive Location:"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($one)
:OuterLoop do
{
for ($i = 1; )
{
$result = $host.ui.PromptForChoice($title, $message, $options, 1)
switch ($result)
{
0 {$global:drive = Read-Host "Drive is $global:drive .Set the Drive Location";
"The Drive is now: $global:drive";
break;}
}
}
}
while ($y -ne 100)
Initially I did not set the variable to to global but read on here that that might help. It did not but it did not hurt either. I also tried setting it to script too. The variable does change, so this is cosmetic more than anything.
Thanks