title: Accessing session environment from powershell script/module
body: <p>The PowerCli (VMWares powershell module) has a command: Connect-VIServer</p>
  
  <p>You run <code>Connect-VIServer -Server myserver -credentials (get-credentials)</code></p>
  
  <p>After running that future powercli cmdlets in that session use that connection.</p>
  
  <p>How do I do something like this with my own modules?</p>
  
  <p>I want to have a command I could run like <code>Connect-MyDB -Server mydb -Credentials (get-credentials)</code></p>
  
  <p>How functions in my module access the server and $credentials variables when I run them in the session?</p>