title: Powershell Export-ModuleMember Object Reference Error
body: <p>I'm trying to teach myself Azure Powershell scripting and have an ultimate goal of setting up a script that reads in an Excel Spreadsheet with specifications for Azure VMs to create (things like, type of VM, tags, timezone, which AD group to add it to, etc).  If anybody has any tutorial references for this, that would be very helpful.</p>
  
  <p>Currently, I'm falling on my face on what should be something relatively simple.  Exporting functions.  I have opened Powershell ISE and tried to run the following code (taken from one of the examples I found on MSDN): </p>
  
  <pre><code>Function New-Test
  {
      Write-Output 'I am New-Test function'
  }
  Export-ModuleMember -Function New-Test
  
  function Validate-Test
  {
      Write-Output 'I am Validate-Test function'
  }
  function Start-Test
  {
      Write-Output 'I am Start-Test function'
  }
  Set-Alias stt Start-Test
  Export-ModuleMember -Function Start-Test -Alias stt
  </code></pre>
  
  <p>But I get an error saying: 
  "Export-ModuleMember: Object Reference not set to an instance of an object"</p>
  
  <p>I have tried saving this code out to a ps1 file named test and then navigating to the directory it's in and running "./test.ps1" but the same error comes up.</p>
  
  <p>Any idea on what I'm doing wrong here?  There is surely something fundamental that I am missing here.</p>