title: Azure runbook to start/stop a vm says "Completed" but nothing happens
body: <p>I'm quite new to Azure but I'm banging my head against something that seems simple. I've read a ton of resources that suggest this should be easy but I simply cannot get a runbook in the new portal (ARM) to start a specific VM. It runs and states "Completed" but nothing happens.</p>
  
  <p>Here is the script:</p>
  
  <p><em>Updated following Jack Zeng's comment which unfortunately changed little.</em></p>
  
  <pre><code>workflow StartDEVTC1
  {
  $VerbosePreference = "Continue"
  $ErrorActionPreference = "Stop"
  $WarnPreference = "Continue"
  
  Write-Output "Getting credential..."
  $cred = Get-AutomationPSCredential -Name 'AutomationPowershellCred1'
  Write-Output "Adding account..."
  Add-AzureRmAccount -Credential $cred
  
  Write-Output "Getting VM..."
  $VM = Get-AzureRmVM -ResourceGroupName "myResourceGroup" -Name "DEVTC1" -Status
  
  $vmName = $VM.Name
  $vmRG = $VM.ResourceGroupName
  Write-Output "Checking state of $vmName from $vmRG..."
  $VMDetail = $VM | Select-Object -ExpandProperty StatusesText | convertfrom-json
  $vmPowerstate = $VMDetail[1].Code
  
  if($vmPowerstate -like "PowerState/deallocated")
  {  
      Write-Output "$vmName powerstate is $vmPowerstate, starting VM..."
      $res = $VM | Start-AzureRmVM
      if (($res.StatusCode) -ne 'OK')
      {
          Write-Error "Could not start VM."
      }
  }
  else
  {
      Write-Output "$vmName powerstate is $vmPowerstate, not starting VM."
  }
  
  Write-Output "END."
  }
  </code></pre>
  
  <p>As you can see I've tried adding some logging but I can't see these in the Testing Pane. Running the key steps in a Powershell on my PC works just fine so what's going on here?</p>
  
  <p>The credential has been newly defined using the details of my azure account (I am an Owner on the account).</p>
  
  <p>It should go without saying but I've tried some much simpler approaches to call Start-AzureRmVm and nothing works.</p>
  
  <p>Thanks and appreciation in advance!</p>