Skip to content

Instantly share code, notes, and snippets.

[cmdletbinding()]
param(
[Parameter(mandatory=$true)]
[string] $StorageAccountId,
[Parameter(mandatory=$true)]
[string] $LogAnalyticsWorkspaceId,
[Parameter(mandatory=$true)]
[string] $ResourceGroupName
@tjsullivan1
tjsullivan1 / New-NSGRulesFromCSV.ps1
Last active January 25, 2021 01:28
This PowerShell Script will allow you to create many NSG rules from a CSV. An example of the "Redis VNET" connectivity requirements is attached. Replace 10.100.100.0/24 with the CIDR of your redis subnet to test.
[cmdletbinding()]
param(
$filePath,
$ResourceGroup,
$NSGName
)
function New-NSGRule {
[cmdletbinding()]
param(
<#
.SYNOPSIS
A brief description of the function or script. This keyword can be used only once in each topic.
.DESCRIPTION
A detailed description of the function or script. This keyword can be used only once in each topic.
.PARAMETER
The description of a parameter. Add a ".PARAMETER" keyword for each parameter in the function or script syntax.
@tjsullivan1
tjsullivan1 / set_outage.py
Created September 29, 2018 04:53
This is a small app that will allow you to create a redirect automatically for ALBs. Useful for pointing ALBs to an outage page when you aren't fully "Cloud Native".
#! python3
import boto3
def make_tags_dict(b3_client, lb_arn):
lb = b3_client.describe_tags(ResourceArns=[lb_arn]).get('TagDescriptions')[0]
tags = {x['Key']: x['Value'] for x in lb.get('Tags', [])}
if not tags:
BUCKET = 'your-bucket-here'
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket(BUCKET)
bucket.object_versions.delete()
@tjsullivan1
tjsullivan1 / Get-NonStandardACL.ps1
Created April 19, 2018 15:15
Returns objects with folders containing NTFS permissions that include non-administrative users. This was used for eliminating personal storage permissions as part of a CIFS migration.
cd \\cifspath\users
Get-Childitem \\cifspath\users\ | % {
$current_folder = $_.BaseName
# Remove inheritance
$acl = Get-Acl $_
$acl.Access | % {
$FileSystemRights = $_.FileSystemRights
$IdentityReference = $_.IdentityReference
@tjsullivan1
tjsullivan1 / main.tf
Created April 13, 2018 21:23
An example of tf-single-server
data "aws_vpc" "vpc_name" {
filter {
name = "tag:Name"
values = ["${var.vpc_level}-VPC"]
}
}
data "aws_subnet_ids" "selected" {
vpc_id = "${data.aws_vpc.vpc_name.id}"
@tjsullivan1
tjsullivan1 / relay_state.py
Created April 9, 2018 15:21
Creates an AD FS relay state for AWS resources.
#! python3
from urllib.parse import quote_plus
def create_aws_relay_state(idp, target):
'''
Provided an identity provider url as a string and a target url as string,
we will create an ADFS relay state. I don't know why we need to run the
quote_plus funciton twice, other than we need to re-encode all of the %
#!/bin/bash
# List all VPCs, their names, and their CIDR blocks. If no name tag is specified, output "None"
aws ec2 describe-vpcs --query 'Vpcs[].[VpcId,CidrBlock,Tags[?Key==`Name`].Value[]]' --output text | sed 's/None$/None\n/' | sed '$!N;s/\n/ /'
# Output all route tables for a specific VPC with the following format:
#
# table id
# table name tag value
# route list
@tjsullivan1
tjsullivan1 / convertNyansaJsonToCsv.sh
Created March 7, 2018 19:30
These scripts will create a CSV from every device that has talked to a Nyansa device and a full list of all the info we have on it.
#!/bin/bash
echo "apGroup,apMacAddr,browser,bssid,chWidth,class,controllerIp,createdAt,dnsHostname,essid,ipAddress,is5ghzCapable,isActive,isDfsCapable,isOnDualBandAp,isWireless,lastUpdated,macAddress,model,network,os,osAndVersion,osVersion,protocol,radioChannel,radioNumber,radioTechType,rfBand,source,userAgent,userName,uuid" > /vagrant/Code/tmp/output.csv
for f in *; do
cat $f |
jq '.data.deviceList.clients[] | [.apGroup, .apMacAddr, .browser, .bssid, .chWidth, .class, .controllerIp, .createdAt, .dnsHostname, .essid, .ipAddress, (.is5ghzCapable | tostring), (.isActive | tostring), (.isDfsCapable | tostring), (.isOnDualBandAp | tostring), (.isWireless | tostring), .lastUpdated, .macAddress, .model, .network, .os, .osAndVersion, .osVersion, .protocol, .radioChannel, .radioNumber, .radioTechType, .rfBand, .source, .userAgent, .userName, .uuid ] | join(",")' |
sed -e s/\"//g >> /vagrant/Code/tmp/output.csv
done