{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-powershell/issues/2179","repository_url":"https://api.github.com/repos/Azure/azure-powershell","labels_url":"https://api.github.com/repos/Azure/azure-powershell/issues/2179/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-powershell/issues/2179/comments","events_url":"https://api.github.com/repos/Azure/azure-powershell/issues/2179/events","html_url":"https://github.com/Azure/azure-powershell/issues/2179","id":151975907,"number":2179,"title":"Can't schedule a Job via Azure automation (get-AzureRmAutomationSchedule,new-azurermAutomationschedule, register-AzureRmAutomationScheduledRunbook)","user":{"login":"crshnbrn66","id":4615130,"avatar_url":"https://avatars.githubusercontent.com/u/4615130?v=3","gravatar_id":"","url":"https://api.github.com/users/crshnbrn66","html_url":"https://github.com/crshnbrn66","followers_url":"https://api.github.com/users/crshnbrn66/followers","following_url":"https://api.github.com/users/crshnbrn66/following{/other_user}","gists_url":"https://api.github.com/users/crshnbrn66/gists{/gist_id}","starred_url":"https://api.github.com/users/crshnbrn66/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crshnbrn66/subscriptions","organizations_url":"https://api.github.com/users/crshnbrn66/orgs","repos_url":"https://api.github.com/users/crshnbrn66/repos","events_url":"https://api.github.com/users/crshnbrn66/events{/privacy}","received_events_url":"https://api.github.com/users/crshnbrn66/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-29T21:50:29Z","updated_at":"2016-05-02T14:58:35Z","closed_at":null,"body":" I have a Azure automation script that I'm using to schedule Azure jobs.\r\n\r\nAlso Written up here: http://powershell.org/wp/forums/topic/scheduling-azure-rm-automation-schedule/\r\n\r\nWhen I run the script under my own credentials and session it works fine.\r\nWhen I attempt to use this with a webhook that calls script that then in turn logs in as the user specified. then attempts to run anyone of the following cmdlets (get-AzureRmAutomationSchedule,new-azurermAutomationschedule, register-AzureRmAutomationScheduledRunbook ) \r\n\r\nI get:\r\n\r\nGet-AzureRmAutomationSchedule : Run Login-AzureRmAccount to login.\r\nAt line:54 char:16\r\n+ ... if(Get-AzureRmAutomationSchedule -name $jobname -ResourceGro ...\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n+ CategoryInfo : InvalidOperation: (:) [Get-AzureRmAutomationSchedule], PSInvalidOperationException\r\n+ FullyQualifiedErrorId : InvalidOperation,Microsoft.Azure.Commands.Automation.Cmdlet.GetAzureAutomationSchedule\r\n\r\nI've mocked up one of the calls and use it in a Azure job and i get the same result code follows:\r\n\r\nParam\r\n(\r\n  [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]\r\n  [string]$credential \r\n  )\r\n     $cred = Get-AutomationPSCredential -Name $credential\r\n      Add-AzureRmAccount -Credential $cred    \r\n     set-azurermcontext -subscriptionName 'Azure Testing'\r\n  Get-AzureRmAutomationSchedule -name CaptureAlerts-MemoryPercentage -ResourceGroupName AzureTesting -AutomationAccountName AutomationAccountTest -Verbose  -ErrorAction SilentlyContinue\r\n\r\n\r\n____________________________________________________________________________\r\nError:\r\n\r\nAccount Environment Subscription Tenant\r\n——- ———– ———— ——\r\nxxx@ok.com AzureCloud xzzzddd\r\n\r\nERROR: Get-AzureRmAutomationSchedule : Run Login-AzureRmAccount to login.\r\nAt line:10 char:1\r\n+ Get-AzureRmAutomationSchedule -name CaptureAlerts-MemoryPercentage -R ...\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n+ CategoryInfo : InvalidOperation: (:) [Get-AzureRmAutomationSchedule], PSInvalidOperationException\r\n+ FullyQualifiedErrorId : InvalidOperation,Microsoft.Azure.Commands.Automation.Cmdlet.GetAzureAutomationSchedule\r\n\r\nIf anyone can think of or offer advice on what I need to do or something I've forgotten I'm all ears."},"comment":{"url":"https://api.github.com/repos/Azure/azure-powershell/issues/comments/216259067","html_url":"https://github.com/Azure/azure-powershell/issues/2179#issuecomment-216259067","issue_url":"https://api.github.com/repos/Azure/azure-powershell/issues/2179","id":216259067,"user":{"login":"crshnbrn66","id":4615130,"avatar_url":"https://avatars.githubusercontent.com/u/4615130?v=3","gravatar_id":"","url":"https://api.github.com/users/crshnbrn66","html_url":"https://github.com/crshnbrn66","followers_url":"https://api.github.com/users/crshnbrn66/followers","following_url":"https://api.github.com/users/crshnbrn66/following{/other_user}","gists_url":"https://api.github.com/users/crshnbrn66/gists{/gist_id}","starred_url":"https://api.github.com/users/crshnbrn66/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crshnbrn66/subscriptions","organizations_url":"https://api.github.com/users/crshnbrn66/orgs","repos_url":"https://api.github.com/users/crshnbrn66/repos","events_url":"https://api.github.com/users/crshnbrn66/events{/privacy}","received_events_url":"https://api.github.com/users/crshnbrn66/received_events","type":"User","site_admin":false},"created_at":"2016-05-02T14:58:35Z","updated_at":"2016-05-02T14:58:35Z","body":"Is this what I need to do to allow for scheduling jobs? \r\nhttps://blogs.msdn.microsoft.com/cloud_solution_architect/2015/05/14/using-a-service-principal-for-azure-powershell-authentication/"}}