Skip to content

Instantly share code, notes, and snippets.

View Rugby-Ball's full-sized avatar

Ed Walsh Rugby-Ball

View GitHub Profile
@Rugby-Ball
Rugby-Ball / upload-single-file-to-s3.ps1
Last active October 18, 2021 19:21
Uploading a single file to an S3 Bucket using PowerShell. #S3 #Public #AWS #Utility #File_System #Powershell
#Uploading a single file to an S3 Bucket using PowerShell.
# AWS accessKey and secretKey can be removed below and from Write-S3Object if running on an EC2 instance and using IAM roles for security.
$accessKey = "Access Key Here"
$secretKey = "Secret Key Here"
# I broke it out like this to make it more modular, but you could just add this information directly to the write-S3object cmdlet if you wanted to make
# a one liner to do this.
#This section is setting up the variables for the local file you want to move to S3.
$filepath = "c:\temp\backupFiles" #This is the path where the file you want to move from Windows machine to S3 resides.
@Rugby-Ball
Rugby-Ball / Download-single-S3-file-to-local-computer.ps1
Last active October 18, 2021 19:19
Download a single file from an S3 bucket to your local computer. #S3 #Public #AWS #Utility #File_System #Powershell
#Download a single file from an S3 bucket to your local computer.
# AWS accessKey and secretKey can be removed below and from Copy-S3Object if running on an EC2 instance and using IAM roles for security.
$accessKey = "Access Key Here"
$secretKey = "Secret Key Here"
# I broke it out like this to make it more modular, but you could just add this information directly to the Copy-S3object cmdlet if you wanted to make
# a one liner to do this.
#This section is setting up the variables for the local file you want to move the S3 file to.
@Rugby-Ball
Rugby-Ball / Backup-my-installed-posh-modules.ps1
Last active October 26, 2021 02:36
Use this to backup you installed PowerShell Modules to a PS1 file so you can re-install onto another computer. #Utility #Backup #PowerShell-Modules #Powershell #Public
#Backup-my-installed-posh-modules.ps1
# Use this to backup your installed PowerShell Modules to a PS1 file so you can re-install onto another computer.
##Check if c:\scripts\powershell\backups exists, if it doesnt create it.
$foldertest = "c:\scripts\powershell\backups"
If (-not(Test-Path -Path $foldertest))
{ New-Item -ItemType Directory -Force -Path $foldertest }
#Pull installed modules and join them in a single line comma seperated.
$Modules_Installed = (Get-InstalledModule | sort name).name -join ","
#Build the install Module Powershell line.
@Rugby-Ball
Rugby-Ball / membership_of_AWS_IAM_Groups.ps1
Last active November 3, 2021 23:03
This will show the membership of IAM Users in a list of AWS IAM Groups. #Public #AWS #Security #IAM #Inventory #Utility #Audit
# membership_of_AWS_IAM_Groups.ps1
<#
Description: This will show the membership of IAM Users in a list of AWS IAM Groups.
For Password_LastUsed, if the account does not have a password, which means no access to AWS Console, or if the password was never used, it outputs "1/1/0001 12:00:00 AM", I capture this and replace with a blank.
Written: Ed Walsh
PowerShell.Core tested: Not Tested
Version: 1.0.0
Create Date: 11/3/2021
Revised Date: 11/3/2021
#>
@Rugby-Ball
Rugby-Ball / active_aws_access_keys_Details.ps1
Last active November 8, 2021 03:40
Pulls all User IAM accounts ACTIVE Access keys that are over a set days since used. And checks the Access Keys details. This will skip Disabled Keys. #Public #AWS #Security #IAM #Inventory
# active_aws_access_keys_Details.ps1
<#
Description: Pulls user IAM accounts ACTIVE Access keys that are older than a set number of days since used and Create Days is older than a set amount. And gets the Access Keys details. This will skip Disabled Keys.
Can be used to find keys older than a set amount of days and not used in a set amount of days so they can be disabled.
Written: Ed Walsh
PowerShell.Core tested: Not Tested
Version: 1.0.2
Create Date: 11/5/2021
Revised Date: 11/7/2021
#>
@Rugby-Ball
Rugby-Ball / ec2-snapshots-inventory.ps1
Created November 12, 2021 02:08
This will pull an inventory of all snapshots for all EBS volumes attached to an EC2 Instance #Public #AWS #Inventory #EC2 #EBS
# ec2-snapshots-inventory.ps1
<#
Description: This will pull an inventory of all snapshots for all EBS volumes attached to an EC2 Instance
original from: https://matthewdavis111.com/powershell/ec2-latest-snapshots-of-attached-volumes/
Altered original script to fit my needs.
Written by: Matthew Davis - see link above to original script.
Modified by: Ed Walsh
PowerShell.Core tested: Not Tested
Version: 1.0.0
@Rugby-Ball
Rugby-Ball / ec2-cpu-utilization-report.ps1
Created December 3, 2021 01:20
This will pull from a date range, the AVG CPU utilization for an EC2 Instance, and save to a CSV file. #AWS #EC2 #Public #Utility #AWS_Cloud_Watch
# ec2-cpu-utilization-report.ps1
<#
Description: This will pull from a date range, the AVG CPU utilization for an EC2 Instance, and save to a CSV file.
Written: Ed Walsh
PowerShell.Core tested: Not Tested
Version: 1.0.0
Create Date: 12/2/2021
Revised Date: 12/2/2021
#>
@Rugby-Ball
Rugby-Ball / get-password.ps1
Created December 15, 2021 19:55
A Function used to make a password, Can set length and Complexity of password. #Security #Utility #Public #Function
# get-password.ps1
<#
Description: A Function used to make a password, Can set length and Complexity of password.
Written: Ed Walsh
PowerShell.Core tested: Not Tested
Version: 1.0.0
Create Date: 12/15/2021
Revised Date: 12/15/2021
#>
@Rugby-Ball
Rugby-Ball / set-ec2-tag-all-running-windows-instances.ps1
Created January 11, 2022 03:11
Set Tag and Value to all running Windows EC2 #EC2 #AWS #Public #Maintenance #Windows #Utility
#set-ec2-tag-all-running-windows-instances.ps1
<#
Description: Set Tag and Value to all running Windows EC2
Written: Ed Walsh
PowerShell.Core tested: Yes
Version: 1.0.0
Create Date: 1/10/2022
Revised Date: 1/10/2022
#>
@Rugby-Ball
Rugby-Ball / Check-for-available-AWS-ENI.ps1
Created January 15, 2022 00:11
Scan Each Region, Each VPC, Each Subnet for Available ENI and count the IP's associated to the ENI. #Utility #AWS #Public #Inventory
#Check-for-available-AWS-ENI.ps1
<#
Scan Each Region, Each VPC, Each Subnet for Available ENI and count the IP's associated to the ENI. Use it to clean up un-used ENI and regain those Private IP's
#>
(Get-EC2Region).regionname | foreach { (Get-EC2Vpc -Region $_).vpcid | foreach { Get-EC2Subnet -Filter @{Name="vpc-id";Value="$_"} | foreach { Get-EC2NetworkInterface -Filter @(@{Name="subnet-id";Values=$_.subnetid} ; @{Name="status";Values="available"} ) | Select-Object VPCID, InterfaceType, NetworkInterfaceID, @{n="PrivateIP-Count"; e= {($_.privateipaddresses | Measure-Object).count}}, SubnetID, Status } } } | Format-Table -AutoSize