How to Dot Source a PowerShell Script

So I wrote a script the other day in PowerShell ISE and it worked fine. But when I wanted to use the function in a standard PowerShell window, I was perplexed. It is actually a really easy thing to take care of.

In the case of my server, I wrote a PowerShell function and stored it in my Documents folder. So when opening a new PowerShell window, all I had to do was run the following command:

PS C:\Users\<username>\Documents> . .\New-Function.ps1

This made all of the functions written in the script available for use during my current session. For me and this case, I am OK with only running the script when needed.

Leave a Reply

Your email address will not be published. Required fields are marked *