Last active
September 10, 2019 06:54
-
-
Save tonesandtones/1ae4411fbc1b631e9caa9c68942a5e71 to your computer and use it in GitHub Desktop.
Powershell snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Read an environment variable where the name is given in another variable | |
$EnvironmentVariableVariableName = "VAR_NAME_HERE" | |
$value = (Get-Item env:$EnvironmentVariableVariableName).Value | |
## Decode an ARM output block as JSON and set the output variables as Azure DevOps pipeline variables | |
#include iterating over the PsCustomObject field names (which are the variable names) and using them as property keys to access the values | |
$outputBlockAsJson = '{"variable1":{"type":"string","value":"value1"},"variable2":{"type":"string","value":"value2"}}' | |
$outputs = $outputBlockAsJson | ConvertFrom-Json | |
foreach ($key in $outputs.psobject.Properties.name){ | |
Write-Host "##vso[task.setvariable variable=$key]$($outputs.$key.Value)" | |
} | |
> ##vso[task.setvariable variable=variable1]value1 | |
> ##vso[task.setvariable variable=variable2]value2 | |
#list the available Azure Sql DB service objectives and SKUs (for putting the fields into an ARM template) | |
#see https://docs.microsoft.com/en-us/powershell/module/Az.Sql/Get-AzSqlServerServiceObjective?view=azps-2.6.0 | |
Get-AzSqlServerServiceObjective -Location australiaeast |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment