How to do it...

If you deleted the file after the previous recipe, restore it or recreate it using the steps in the previous recipe. Then,

  1. Open the script file that you created in the previous recipe. At the second line, type the following.
$Message = "I was dot-sourced!"
  1. Save the script. Do not run it yet.
  2. Place your cursor at the integrated console, and call the script using the call operator.
& ./hello-world
  1. We declared $Message and assigned a string value to it. Call the variable to see what value it contains.
$Message

Nothing.

  1. Now, dot-source the script. (There are two dots; one is the operator, and the other after the space is reference to the current directory.)
. ./hello-world.ps1
  1. Call the $Message variable again.
$Message
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.219.217