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
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 1
# create new (empty) log files after rotating old ones
create
@ajomathew
ajomathew / syslog.sh
Created July 22, 2018 05:26
/opt/logrotate.d/syslog
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
missingok
sharedscripts
postrotate
@ajomathew
ajomathew / host.yml
Created July 22, 2018 05:29
Anible Hosts files in yaml format
win:
hosts:
192.168.57.4
vars:
ansible_user: Administrator
ansible_password: <myPassword>
ansible_connection: winrm
ansible_port: 5986
ansible_winrm_scheme: https
ansible_winrm_server_cert_validation: ignore
@ajomathew
ajomathew / loginAzureRMFunction.ps1
Last active July 22, 2018 05:33
Function to login to AzureRM
function loginAzure {
param (
$tenantID,
$azUserName,
[securestring]$azSecPassword,
$azIsServicePrincipal
)
# Logout of any pervious AzureRM account
try {
Logout-AzureRmAccount -ErrorAction Stop
@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 {
@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 / 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 / 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 / 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 / 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'