title: "Access denied" on Remote winrm
body: <p>I created a Windows VM on Windows Azure with winrm over SSL set.</p>
  
  <p>But, I can't connect it using a powershell script.</p>
  
  <p>When I'm running the following:</p>
  
  <pre><code>​Enter-PSSession -ConnectionUri https://myniceapp.cloudapp.net:5986 
                  -Credential "hostname/username"  
                  -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
  </code></pre>
  
  <p>I'm getting a prompt asking for password and after I type it I manage to connect.</p>
  
  <p>But, when I try to automate it, it always returns with "Access is denied" </p>
  
  <pre><code>$securePassword = ConvertTo-SecureString -AsPlainText -Force "password"
  $cred = New-Object System.Management.Automation.PSCredential "hostname/username", $securePassword 
  ​Enter-PSSession -ConnectionUri https://myniceapp.cloudapp.net:5986 -Credential $mycreds -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck)
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The full error looks like this:</p>
  
  <blockquote>
    <p>Enter-PSSession : Connecting to remote server myniceaspp.cloudapp.net failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.</p>
    
    <p>At line:1 char:1<br>
    + Enter-PSSession -ConnectionUri <a href="https://myniceaspp.cloudapp" rel="noreferrer">https://myniceaspp.cloudapp</a> ...<br>
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
    + CategoryInfo          : InvalidArgument: (https:// myniceaspp...udapp.net:5986/:Uri) [Enter-PSSession], PSRemotingTransportException<br>
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed </p>
  </blockquote>