Skip to content

Instantly share code, notes, and snippets.

@yufufi
yufufi / deleteOldSnapshots.sh
Created April 6, 2020 16:15
Scripts to manage AKS Disk snapshots
# set the expiry to a month ago
expirydate=$(date -d'-1 month' +%s)
# I can use az -o table with cut -d driectly
for snapshot in $(az snapshot list -g $resourceGroup | jq -r '.[] | [.id, .timeCreated[:10], .name] | join("#")')
do
snapshotId=$(echo $snapshot | cut -f1 -d "#")
snapshotDate=$(echo $snapshot | cut -f2 -d "#" | xargs -I{} date -d {} +%s)
snapshotName=$(echo $snapshot | cut -f3 -d "#")
@yufufi
yufufi / VSTSPasswordGenerator.ps1
Last active June 13, 2018 19:52
A powershell script that generates a password of arbitrary length and assigns to a vso variable
param(
[string] $targetvariablename,
[int] $length
)
# create a list of characters to select from
$ascii=$null
for ($a = 33; $a -le 126; $a++) {
$ascii+=,[system.convert]::tochar($a)
@yufufi
yufufi / setVarsFromARMOutput.ps1
Created June 13, 2018 13:16
Loop through ARM output and set variables
param (
[Parameter(Mandatory=$true)][string]$ARMOutput
)
$json = $ARMOutput | convertfrom-json
$json.PSObject.Properties | ForEach-Object {
Write-Host "##vso[task.setvariable variable=$($_.name);]$($_.value)"
}