AADSCConfigContent.psm1
function Get-AADSCConfigContent { param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [String] $ResourceGroup, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [String] $AutomationAccount, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [String] $Configuration ) # Get Auth token using classes registered by Az.Accounts module # Used in many Azure API examples such as: https://docs.microsoft.com/en-us/azure/governance/resource-graph/first-query-rest-api#rest-api-and-powershell $azContext = Get-AzContext $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($azContext.Subscription.TenantId) $authHeader = @{ 'Content-Type'='application/json' 'Authorization'='Bearer ' + $token.AccessToken } # API spec: https://github.com/Azure/azure-rest-api-specs/tree/master/specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01 $apiVersion = '2019-06-01' # Documented: https://docs.microsoft.com/en-us/rest/api/automation/dsc-configuration/get-content $restUri = "https://management.azure.com/subscriptions/$($azContext.Subscription)/resourceGroups/$ResourceGroup/providers/Microsoft.Automation/automationAccounts/$AutomationAccount/configurations/$Configuration/content?api-version=$apiVersion" Invoke-RestMethod -Uri $restUri -Method Get -Headers $authHeader } |