title: Load all functions into PowerShell from a certain directory
body: <p>Suppose you're a system administrator who uses PowerShell to manage a lot of things on his/her system(s).</p>
  
  <p>You've probably written a lot of functions which do things you regularly need to check. However, if you have to move around a lot, use different machines a lot and so on, you'd have to re-enter all your functions again and again to be able to use them. I even have to do it every time I exit and restart PowerShell for some reason, as it won't remember the functions...</p>
  
  <p>I've written a function that does this for me. I'm posting it here because I want to be certain it's foolproof. The function itself is stored in <code>allFunctions.ps1</code>, which is why I have it excluded in the code.</p>
  
  <p>The basic idea is that you have one folder in which you store all your ps1 files which each include a function. In PowerShell, you go to that directory and then you enter:</p>
  
  <pre><code>. .\allFunctions.ps1
  </code></pre>
  
  <p>The contents of that script is this:</p>
  
  <pre><code>[string]$items = Get-ChildItem -Path . -Exclude allFunctions.ps1
  $itemlist = $items.split(" ")
  foreach($item in $itemlist)
  {
      . $item
  }
  </code></pre>
  
  <p>This script will first collect every file in your directory, meaning all non-ps1 files you might have in there too. allFunctions.ps1 will be excluded.</p>
  
  <p>Then I split the long string based on the space, which is the common separator here. And then I run through it with a Foreach-loop, each time initializing the function into PowerShell.</p>
  
  <p>Suppose you have over 100 functions and you never know which ones you'll need and which you won't? Why not enter them all instead of nitpicking?</p>
  
  <p>So I'm wondering, what can go wrong here? I want this to be really safe, since I'm probably going to be using it a lot.</p>