title: Powershell Active Directory commands not working in Powershell session
body: <p>When I run an Active Directory related PowerShell command in a PowerShell session, I get this error:</p>
  
  <blockquote>
    <p>Get-ADUser : Unable to find a default server with Active Directory Web Services running.</p>
  </blockquote>
  
  <p>This is the code which I used:</p>
  
  <pre><code>$password = ConvertTo-SecureString "test@b1234" -AsPlainText -Force
  
  $cred= New-Object System.Management.Automation.PSCredential ("stackuser", $password )
  
  $sess = New-PSSession -Credential $cred -ComputerName 'windows'
  
  Enter-PSSession $sess
  
  Get-ADUser -Identity 'krbtgt'
  
  Exit-PSSession
  
  Remove-PSSession $sess
  </code></pre>
  
  <p>The answer I am expecting is to get the details from AD</p>