title: Pester Mocking a script that varies output
body: <p>Hi all I have written a script to display the current user info, I would like to write Pester test case that should mock the output, also if I don't have <code>return</code> in the function how can I write a test for that too</p>
  
  <pre><code>function Get-CurrentUserInfo
  {
  
      $domain = [Environment]::UserDomainName
      $user = [Environment]::UserName
      if (!([string]::IsNullOrEmpty($domain))) { $domain = $domain + '\' }
  
      $currentUser = $domain + $user
  
      #return $currentUser I have commented out so that it will not return any output
  }
  </code></pre>
  
  <p>Here is my test case when there is return</p>
  
  <pre><code>$here = Split-Path -Parent $MyInvocation.MyCommand.Path
  . "$here\Get-CurrentUserInfo.ps1"
  Describe "CurrentUser" {
      It "CurrentUser Info" {
          Get-CurrentUserInfo | Should be 'MY-PC\username'
      }
  }
  </code></pre>
  
  <p>Which works fine with my PC but when I execute the same in other PC it will fail so how can I make it unique</p>