Skip to content

Instantly share code, notes, and snippets.

View irwinwilliams's full-sized avatar

Irwin irwinwilliams

View GitHub Profile
@irwinwilliams
irwinwilliams / create-azure-resource-group-with-contributors.ps1
Created November 9, 2017 13:19
Create azure resource group and assign contributors
#Clear-Host
$classlist - ".\class-list.tsv" #contains a tab-delimited list of object ids, resource group names and locations
$tenant = "guid"
$app_id = "guid"
$app_key = ConvertTo-SecureString "key" -AsPlainText -Force
$cred = New-Object -TypeName pscredential -ArgumentList $app_id, $app_key
Login-AzureRmAccount -Credential $cred -ServicePrincipal -TenantId $tenant
Get-Content $classlist | ForEach-Object {
$tokens = $_ -split "\t"
@irwinwilliams
irwinwilliams / create-azure-storage-accounts-with-keys.sh
Created October 12, 2017 04:19
Creates a list of azure storage accounts, output their name and keys in bash
for number in {1..20}
do
account=comp69052017a2
account+=$number
az storage account create --name $account --resource-group COMP6905A2Storage --location eastus --sku Standard_LRS --encryption blob | jq ".name"
az storage account keys list --account-name $account --resource-group COMP6905A2Storage | jq '.[].value' | tr -s '\n' ','
done
@irwinwilliams
irwinwilliams / display-storage-account-keys.sh
Created October 12, 2017 02:48
Display storage account keys using azure cli
az storage account keys list --account-name comp69052017a2test --resource-group COMP6905A2Storage
@irwinwilliams
irwinwilliams / single-storage-account-create.sh
Created October 12, 2017 02:46
Create a storage account via azure CLI
#ensure logged in to azure
#ensure default subscription is desired one
az storage account create --name comp69052017a2test \ #test storage account
--resource-group COMP6905A2Storage \#test resource group
--location eastus --sku Standard_LRS \
--encryption blob
@irwinwilliams
irwinwilliams / create-resource-group.sh
Created October 12, 2017 02:43
Create a resource group using Azure's CLI
#Prior to doing this, ensure that user is logged in
# 'az login' works
#Then, if you have multiple subscriptions attached to account, select the appropriate one using:
# 'az account set --subscription <name or id>'
#command below:
az group create --name COMP6905A2Storage #name I used
@irwinwilliams
irwinwilliams / change-rdp-settings-azure-web-role.ps
Created September 23, 2017 07:44
Change RDP settings on Azure Web Role
#This works with a Classic Azure Cloud Service Web Role
$SubsciptionName = "<name>"
$CloudServiceName = "<web-role-name>"
Add-AzureAccount
Select-AzureSubscription -Name $SubscriptionName
Get-AzureRole -ServiceName $CloudServiceName
$username = "<username>"
$password = "<other-options-can-be-used>"
$securepassword = ConvertTo-SecureString -String $password -AsPlainText -Force
@irwinwilliams
irwinwilliams / SystemWebCookieManager.cs
Created May 29, 2017 16:39
Importing a bit of code from Katana on CodePlex
//stick this in public void ConfigureAuth(IAppBuilder app)
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
// ...
CookieManager = new SystemWebCookieManager()
});
//And create this class elsewhere:
public class SystemWebCookieManager : ICookieManager
{
@irwinwilliams
irwinwilliams / FillRows.vb
Created May 1, 2017 11:58
Needed to update rows in an excel document for a project called Time For Water, based on data @wasatnt released.
Sub FillRows()
For i = 1 To ThisWorkbook.Sheets.Count
Sheets(i).Activate
'You can add more code
With ActiveSheet
Dim lRow As Long
Dim lCol As Long
lRow = Cells(Rows.Count, 3).End(xlUp).Row
lCol = Cells(1, Columns.Count).End(xlToLeft).Column
@irwinwilliams
irwinwilliams / SetAzureADRoles.ps1
Created October 7, 2016 12:50
Set Roles in Azure AD via PowerShell
#'I got this from here: https://github.com/Azure-Samples/active-directory-dotnet-graphapi-console/issues/27#issuecomment-155565140
$Tenant = "[something].onmicrosoft.com";
$tenantGuid = "[find this in the manifest]"
$graphver = "1.5"
$appID = "[also manifest, but portal, too.]"
$userVal = "[username]@" + $tenant
$pass = "[password]"
$creds = New-Object System.Management.Automation.PsCredential($userVal, (ConvertTo-SecureString $pass -AsPlainText -Force))
@irwinwilliams
irwinwilliams / UpdateAzureBlobCORS.ps
Last active August 24, 2016 06:58
Update an Azure Blob's CORS setting
#works with Azure in Powershell v 1.3.2
clear
$StorageAccountName = "[storageaccountname]"
$Key = "[storageaccountkey]"
$Context = New-AzureStorageContext -StorageAccountKey $Key -StorageAccountName $StorageAccountName
$CorsRules = (@{
AllowedHeaders=@("*");
AllowedOrigins=@("*");
ExposedHeaders=@("content-length");
MaxAgeInSeconds=200;