If you deleted the file after the previous recipe, restore it or recreate it using the steps in the previous recipe. Then, perform the following steps:
- Open the script file that you created in the previous recipe. At the second line, type the following:
PS> $Message = "I was dot-sourced!"
- Save the script. Do not run it yet.
- Place your cursor at the integrated console, and call the script using the call operator:
PS> & ./hello-world
- We declared $Message and assigned a string value to it. Call the variable to see what value it contains:
PS> $Message
It contains nothing.
- Dot-source the script (there are two dots; one is the operator, and the other after the space is reference to the current directory):
PS> . ./hello-world.ps1 ...