title: Get-AzAutomationCredential works in Powershell ISE but not in runbook
body: <p>I've been running the Get-AzAutomationCredential cmdlet in powershell ISE and it returns my account, but when I run the same script in my automation account in a runbook, I receive the following:</p>
  <p>Code:</p>
  <pre><code>$autoCredential = get-AzAutomationCredential -ResourceGroupName &quot;ResourceGroup&quot; -AutomationAccountName &quot;automationaccount&quot; -Name &quot;accountName&quot;
  
  $User = $autoCredential.UserName
  </code></pre>
  <p>Output:</p>
  <p><code>&quot;Object reference not set to an instance of an object.&quot;</code></p>
  <p>The credentials are present in the credentials blade within the automation account.</p>