[Powershell] variable value is not retained RRS feed

  • Question

  • I'm new to Powershell.

    There is something that amazes me the way PS works, especially how it retains the variable.


        $a = "world" $b = "Hello $a" write-host $b   
        $a = "world2" write-host $b

    The following is what is resulted:
        Hello world
        Hello world

    Why the second write-host does not display "Hello world2"?
    • Edited by te_ve Tuesday, October 24, 2017 3:17 AM Removed HTML tag
    • Moved by Bill_Stewart Thursday, January 25, 2018 9:52 PM Unanswerable drive-by question
    Tuesday, October 24, 2017 3:17 AM

All replies