Skip to content

Instantly share code, notes, and snippets.

View ajomathew's full-sized avatar
🏠
Working from home

Ajo Mathew ajomathew

🏠
Working from home
View GitHub Profile
@ajomathew
ajomathew / sql-windows-azure.json
Created May 24, 2020 09:42
ARM template to enable SQL VM using Microsoft.SqlVirtualMachine/SqlVirtualMachines
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"sqlVirtualMachineLocation": {
"type": "string"
},
"sqlVirtualMachineName": {
"type": "string"
},
@ajomathew
ajomathew / sqlAzureVMDiskConfig.json
Created May 24, 2020 02:02
Microsoft.SqlVirtualMachine/SqlVirtualMachines with disk configurations for SQL Instance
{
"type": "Microsoft.SqlVirtualMachine/SqlVirtualMachines",
"apiVersion": "2017-03-01-preview",
"name": "[parameters('virtualMachineName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]"
],
"properties": {
"virtualMachineResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]",
@ajomathew
ajomathew / SendGridV2API.ps1
Created May 19, 2020 05:17
SMTP mail with attachment using SendGrid V3 API
<#
.SYNOPSIS
This function will enable you to send mail with SendGrid without using 'Send-MailMessage'
.DESCRIPTION
Azure VM's sending mail with 'Send-MailMessage' cmdlet reported failure. Hence new script is created to handle this.
This script works by calling send grid v3 rest API
.EXAMPLE
PS . <pathToThisFunctionps>
Then you can invoke this script natively in any other scripts
@ajomathew
ajomathew / Azure Policy to tag resource with UTC time
Last active March 23, 2020 05:43
Tag Azure resource using UTC time
{
"id": "/providers/Microsoft.Authorization/policyDefinitions/addcreatedtag",
"type": "Microsoft.Authorization/policyDefinitions",
"name": "addcreatedtag",
"properties": {
"displayName": "Append datetime (utc) tag when resource is created",
"policyType": "Custom",
"mode": "All",
"description": "Appends the a creationd date tag and the time (utc) when the resource was created. Does not modify the tags of resource groups created before this policy was applied until those resource groups are changed.",
"metadata": {
@ajomathew
ajomathew / azureTableStorag.ps1
Last active November 11, 2019 13:46
Use Azure table storage as a place to retain filters of resources
#Requires -Module AzTable
$auditfilterStorageAcc = '<yourStorageAccount>'
$auditfilterStorageAccRg = '<yourStorageAccoutResourceGroup'
$tableName = '<tableStorageName>'
function getStorageAcconts{
$context = (Get-AzStorageAccount -Name $auditfilterStorageAcc -ResoruceGroupName $auditfilterStorageAccRg).context
$table = (Get-AzStorageTable -name $tableName -context $context).CloudTable
$result = Get-AzTableRow -Table $table -ParitionKey 'filterStorage'
@ajomathew
ajomathew / installAndExportGPO.ps1
Created March 19, 2019 09:32
Install Powershell Module and export GPO to DSC using baseline module
## Install Module - ensure you are running powershell as Administrato
Install-Module -Name BaselineManagement
## Import installed module to powershell
Import-Module BaselineManagement
## Export GPO to DSC
ConvertFrom-GPO -Path .\2012R2\
@ajomathew
ajomathew / unlockRecoveryVaultBackups.ps1
Last active March 13, 2019 03:16
Remove Resource Lock Azure Recovery vault backups
######################################################################
# Powershell Script to unlock Backup Vault Restore point collections.#
######################################################################
$resources = Get-AzureRmResource
$resourceTypeToUnlock = 'Microsoft.Compute/restorePointCollections'
foreach ($resource in $resources)
{
if($resource.ResourceType -eq $resourceTypeToUnlock){
$lock = Get-AzureRmResourceLock -ResourceName $resource.Name -ResourceType $resourceTypeToUnlock -ResourceGroupName $resource.ResourceGroupName
if($null -ne $lock){
@ajomathew
ajomathew / lockPagesinMemorySQLAccount.ps1
Last active March 7, 2019 08:18
Grant SQL Server account access to Lock Pages in Memory using PowerShell
## Powershell script referenced from http://keepingitgeek.blogspot.com/2015/01/grant-sql-server-account-access-to-lock.html
## Powershell script was converted to a DSC module for implementation.
Configuration createServiceUserUser {
param(
# Parameter help description
[Parameter(Mandatory)]
[string]
$VMHostName,
# Parameter help description
[Parameter(Mandatory)]
@ajomathew
ajomathew / deleteDeployments.ps1
Created February 26, 2019 10:03
Delete older deployments in Azure resource group
Get-AzureRmResourceGroupDeployment -ResourceGroupName 'winVMTest'|Select-Object -Skip 100 | Remove-AzureRmResourceGroupDeployment
@ajomathew
ajomathew / setReaderPermissionOnSubscriptionsAzure.ps1
Created July 22, 2018 10:49
Use this script to set reader permission to azure application on all subscriptions
# Provide Local user credentials - No Guest user
# This user should be having permission to set/remove permissions on subscriptions
Login-AzureRmAccount -Credential (Get-Credential)
# Get all subscriptions and loop
foreach ($sub in (Get-AzureRmSubscription)){
# Follow this link to view application ID
# https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-application-id-and-authentication-key
$application = Get-AzureRmADServicePrincipal -ApplicationId (Read-Host -Prompt 'Enter Azure Application ID')
$scope = [string]::Concat('/subscriptions/', $sub.ID)
try {