This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| : ${1?"Usage: $0 RHEL||Amazon||Ubuntu"} | |
| if [ $1 == "RHEL" ]; then | |
| # RHEL is slightly different so we don't sort by creation date. Instead, we look for the number after x86_64-, which indicates Kernel revision. Higher is better. | |
| aws ec2 describe-images --owner 309956199498 --filters 'Name=name,Values=RHEL-7.4_HVM-201?????-x86_64-?-Hourly2-GP2' --query 'Images[].[ImageId,Name,CreationDate,OwnerId]' --output text | sed 's/\(\S*\)\(.*\)/\2 \1/' | awk -F'x86_64-' '{print $2}' | sort | tail -n 1 | awk -F'ami-' '{print "ami-"$2}' | |
| elif [ $1 == "Amazon" ]; then | |
| aws ec2 describe-images --owner 137112412989 --filters 'Name=name,Values=amzn2-ami-hvm-2017.12.0.201?????-x86_64-gp2' --query 'sort_by(Images, &CreationDate)[-1].[ImageId]' --output text | |
| elif [ $1 == "Ubuntu" ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! python3 | |
| def sendMessage(message_subject, sender, recipient, html_body, text_body, charset="UTF-8"): | |
| import boto3 | |
| from botocore.exceptions import ClientError | |
| # Load shared configuration file | |
| session = boto3.Session(profile_name='email') | |
| # Create a new SES resource and specify a region. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests, bs4, re | |
| def check_url(url, regex): | |
| res = requests.get(url) | |
| res.raise_for_status() | |
| soup = bs4.BeautifulSoup(res.text, "lxml") | |
| found_string = soup.body.findAll(text=re.compile(regex), limit=1) | |
| if found_string: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Get-Content C:\Users\tjsullivan1\Documents\computers.txt | % { | |
| $server = $_ | |
| $SQLAttrs = Get-SqlServerInfo -ComputerName $server | select SQLVersion,SQLEdition,Hostname | |
| $ProcInfo = Get-ProcCoreSocketCount -ComputerName $server | |
| $SQLVersion = $SQLAttrs.SQLVersion | |
| $SQLEdition = $SQLAttrs.SQLEdition | |
| $Cores = $ProcInfo.Cores | |
| $Sockets = $ProcInfo.Sockets | |
| $FullInfo = [PSCustomObject]@{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| file='twiki_vms.csv' | |
| while IFS="," read servername vm | |
| do | |
| twikifile='/var/www/html/twiki/data/ITOperations/'$servername'.txt' | |
| echo $vm | |
| cat $twikifile | grep MachineName | |
| sed -i s"/name=\"MachineName\"\stitle=\"Machine\sName\"\svalue=\"\"/name=\"MachineName\" title=\"Machine Name\" value=\"$vm\"/" $twikifile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [cmdletbinding()] | |
| param( | |
| [Parameter(Mandatory=$true,HelpMessage="Remember, this must match the name part after the accountID of the AD group you are using!")] | |
| [string]$Role_Name, | |
| $Account_Number = '123456789012' | |
| ) | |
| $Name = "AWS-$Account_Number-$Role_Name" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! python3 | |
| import os, urllib.request, shutil, logging, zipfile, stat | |
| logger = logging.getLogger() | |
| logger.setLevel(logging.INFO) | |
| formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') | |
| fh = logging.FileHandler('install_hashi_tools.log') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [cmdletbinding()] | |
| param( | |
| [Parameter(HelpMessage="Remember, this must match the name part after the accountID of the AD group you are using!")] | |
| [string]$Role_Name = "Admin", | |
| $Policy_Name | |
| ) | |
| $AWS_Account_ID = Get-EC2SecurityGroup -GroupName "default" | select -ExpandProperty OwnerID # this grabs Owner ID from the default VPC security group | |
| $account_arn = 'arn:aws:iam::'+$AWS_Account_ID+':saml-provider/ADFS' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [cmdletbinding()] | |
| param( | |
| [string]$ADFS_RelyingParty_Trust_Name = 'AWS', | |
| [string]$ADFS_Metadata_URL = 'https://<ADFS_SERVER_FQDN>/FederationMetadata/2007-06/FederationMetadata.xml', | |
| [string]$IDP_Provider_Name = 'ADFS', | |
| [Parameter(HelpMessage="Remember, this must match the name of the AD group you are using!")] | |
| [string]$Role_Name = "AWS-Admin" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param( | |
| $Zone_Name, | |
| $DNS_Server, | |
| $IP | |
| ) | |
| Get-DnsServerResourceRecord -ZoneName $Zone_Name -ComputerName $DNS_Server | | |
| Where { $_.RecordType -eq 'A' -and $_.RecordData.IPv4Address.IPAddressToString -like "$IP"} |