MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.28k stars 21.46k forks source link

Watcher Tasks PowerShell support #37510

Closed dani3lheidemann closed 5 years ago

dani3lheidemann commented 5 years ago

Hi all, unfortunately I cannot find a powershell command / module to administer/control watcher tasks. Is there any powershell support in latest Powershell Az module?

Thanks!


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

KrishnaG-MSFT commented 5 years ago

@nnamedieh Thanks for the comment. We are actively investigating and will get back to you shortly with an update.

eamonoreilly commented 5 years ago

You can call the Watcher Automation REST API from PowerShell (https://docs.microsoft.com/en-us/rest/api/automation/watcher) An example of calling a REST API from the service using the RunAs account is documented on https://github.com/azureautomation/runbooks/blob/master/Utility/ARM/InvokeAzureREST.ps1

You can also get the token if you have logged in to Azure using ` $LoginSession = Get-AzureRMContext

$AZProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile $ProfileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($AZProfile) $Token = ($ProfileClient.AcquireAccessToken($LoginSession.Subscription.TenantId)).AccessToken

$headers = @{ 'Authorization' = "Bearer $Token" } ` Thanks, Eamon

KrishnaG-MSFT commented 5 years ago

@eamonoreilly Thanks for sharing the useful information. 👍 @nnamedieh Closing this issue for now. If there are further questions regarding this matter or feedback on the documentation, please do let us know and we will gladly continue the discussion.