scripting - Accessing hash tables values in the same hash table in powershell -


i'm storing lot of variables depend on other variables, depend on other variables, :

$soft_version = "5.8.2" $soft_filename = "somesoft-${soft_version}.exe" $soft_path = "/some/path/$soft_filename" $soft_call_args = "/s /forcerestart" 

and i'd store in hash table can access values more : tried following

$soft = @{ version="5.8.2"; filename="somesoft-${soft.version}.exe" path="/some/path/$soft.filename" call_args = "/s /forcerestart" } 

so can access values :

$soft.version $soft.filename $soft.path $soft.call_args 

but doesn't seem work, corresponding keys remain empty :

$soft  name                           value                                                                                                ----                           -----                                                                                                filename                       somesoft-.exe path                           /some/path/ call_args                      /s /forcerestart version                        5.8.2 

is there way access values of hash table inside same hash table ? :-)

try wrap in brackets, works me (psversion 5):

$soft = @{ version="5.8.2"; filename="somesoft-$($soft.version).exe" path="/some/path/$($soft.filename)" call_args = "/s /forcerestart" } 

result

$soft  name                           value    ----                           ----- filename                       somesoft-5.8.2.exe path                           /some/path/somesoft-5.8.2.exe call_args                      /s /forcerestart version                        5.8.2 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -