Skip to content

Instantly share code, notes, and snippets.

@jamesbannan
jamesbannan / getBillingData.ps1
Created Jun 17, 2020
Azure Billing and Usage Data scripts
View getBillingData.ps1
# Licensed under the MIT license.
# Copyright (C) 2017 Kristofer Liljeblad
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@jamesbannan
jamesbannan / azureRegionCountry.ps1
Last active May 8, 2018
Get all Azure regions in the same country based on IP address
View azureRegionCountry.ps1
# Get all Azure regions accessible with my subscription
$regions = az account list-locations | ConvertFrom-Json
$locations = $regions | Select-Object displayName,latitude,longitude | Sort-Object displayName
# Get my location based on IP address
$request = (Invoke-WebRequest -Uri http://ip-api.com/json).Content | ConvertFrom-Json
$latitude = $request.lat
$longitude = $request.lon
$countryCode = $request.countryCode
@jamesbannan
jamesbannan / nearestAzureRegion.ps1
Created May 8, 2018
Find nearest Azure region based on IP address
View nearestAzureRegion.ps1
# Get all Azure regions accessible with my subscription
$regions = az account list-locations | ConvertFrom-Json
$locations = $regions | Select-Object displayName,latitude,longitude | Sort-Object displayName
# Get my location based on IP address
$request = (Invoke-WebRequest -Uri http://ip-api.com/json).Content | ConvertFrom-Json
$latitude = $request.lat
$longitude = $request.lon
$hash = [ordered]@{
View azuredeploy.parameters.json
"chefValidationKey": {
"reference": {
"keyVault": {
"id": "/subscriptions/<SUBSCRIPTIONID>/resourceGroups/<RESOURCEGROUPNAME>/providers/Microsoft.KeyVault/vaults/<VAULTNAME>"
},
"secretName": "chef-org-validator"
}
}
View New-KeyVaultChefCertSecret.ps1
## Log in to Azure Resource Manager
Add-AzureRmAccount
## Create Resource Group
$resourceGroupName = 'keyvault'
$location = 'Australia Southeast'
$resourceGroup = New-AzureRmResourceGroup `
-Name $resourceGroupName `