Skip to content

Instantly share code, notes, and snippets.

View BanterBoy's full-sized avatar
⚙️
Automating things.......from home!

Luke Leigh BanterBoy

⚙️
Automating things.......from home!
View GitHub Profile
@BanterBoy
BanterBoy / Check-HIPBPwned.ps1
Created June 2, 2018 20:30
Quick script to check an Email address against https://haveibeenpwned.com/api also creates object $Pwned which can then be interrogated further.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$PwnedSite = "https://haveibeenpwned.com/api/v2/breachedaccount/"
$PwnedAddress = Read-Host "Email Address"
Invoke-RestMethod -Uri ($PwnedSite + $PwnedAddress) -OutVariable Pwned
@BanterBoy
BanterBoy / Find-FilesLastDays.ps1
Created June 29, 2018 22:01
Short scrappy script to locate recently created files (scripts/notes)
Clear-Host
$DaysPast = Read-Host "Enter Number of Days"
$Start = (Get-Date).AddDays(-$DaysPast)
$Path = Read-Host "Enter Search Path"
$Extenstion = Read-Host "Enter Extenstion"
Clear-Host
$Stopwatch = [system.diagnostics.stopwatch]::startNew()
Get-ChildItem -Path $Path -Include $Extenstion -Recurse |
Where-Object { $_.LastWriteTime -ge "$Start" } |
@BanterBoy
BanterBoy / Capture-MainWindowTitle.ps1
Last active July 25, 2018 10:15
Snippet used to capture the title bar for all active windows for all foreground processes
$p = @(Get-Process -Name *)
$p | Select-Object -Property MainWindowTitle | Where-Object { $_.MainWindowTitle -match "\w+" }
@BanterBoy
BanterBoy / Find-Domainadmins.ps1
Created July 27, 2018 14:49
Find Domain Admins
Get-ADGroupMember -Identity Administrators -Recursive |
ForEach-Object { get-aduser $_} |
Select-Object SamAccountName, GivenName, Surname, objectclass, name, enabled |
Sort-Object SamAccountName |
Format-Table -AutoSize
@BanterBoy
BanterBoy / IP-Scan.ps1
Last active August 6, 2018 12:41
Resolve PTR for an array of IP's
$IPs = New-Object System.Collections.ArrayList
$IPs.AddRange(
(
"64.4.250.33",
"64.4.250.32",
"23.43.65.124",
"23.195.132.187",
"52.23.120.130",
"52.20.68.174",

Keybase proof

I hereby claim:

  • I am banterboy on github.
  • I am lukeleigh (https://keybase.io/lukeleigh) on keybase.
  • I have a public key ASDtkLpfa19ylVA7cUgFDXSqwo7cScFxbEWP786RCZsIvAo

To claim this, I am signing this object:

@BanterBoy
BanterBoy / Get-PatchTue.ps1
Created June 10, 2020 18:27
PowerShell function to show you when the next patch Tuesday will occur. You can also specify month/year to find historical or future dates.
function Get-PatchTue {
<#
.SYNOPSIS
Get the Patch Tuesday of a month
.PARAMETER month
The month to check
.PARAMETER year
The year to check
.EXAMPLE
Get-PatchTue -month 6 -year 2015
@BanterBoy
BanterBoy / Get-LatestFiles.ps1
Created August 10, 2020 19:28
Powershell cmdlet for locating recent files in a specified folder.
<#
.SYNOPSIS
Short function to find recently saved files.
.DESCRIPTION
Short function that can be used to find/locate recently saved files.
Searches are performed by passing the parameters to Get-Childitem which will then
recursively search through your specified file path and then perform a sort to output
@BanterBoy
BanterBoy / Test-IsAdmin.ps1
Created August 14, 2020 19:11
Function to test if the current session is running as an administrator
function Test-IsAdmin {
<#
.Synopsis
Tests if the user is an administrator
.Description
Returns true if a user is an administrator, false if the user is not an administrator
.Example
Test-IsAdmin
#>
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
@BanterBoy
BanterBoy / New-AdminShell.ps1
Created August 14, 2020 19:13
Function used in conjunction with Test-IsAdmin to start a new Admin Shell (runs powershell or pwsh as admin)
function New-AdminShell {
<#
.Synopsis
Starts an Elevated PowerShell Console.
.Description
Opens a new PowerShell Console Elevated as Administrator. If the user is already running an elevated
administrator shell, a message is displayed in the console session.
.Example