Skip to content

Instantly share code, notes, and snippets.

Avatar
⚙️
Automating things.......from home!

Luke Leigh BanterBoy

⚙️
Automating things.......from home!
View GitHub Profile
@BanterBoy
BanterBoy / Find-FilesLastDays.ps1
Created Jun 29, 2018
Short scrappy script to locate recently created files (scripts/notes)
View Find-FilesLastDays.ps1
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 Jul 25, 2018
Snippet used to capture the title bar for all active windows for all foreground processes
View Capture-MainWindowTitle.ps1
$p = @(Get-Process -Name *)
$p | Select-Object -Property MainWindowTitle | Where-Object { $_.MainWindowTitle -match "\w+" }
View Find-Domainadmins.ps1
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 / Check-HIPBPwned.ps1
Created Jun 2, 2018
Quick script to check an Email address against https://haveibeenpwned.com/api also creates object $Pwned which can then be interrogated further.
View Check-HIPBPwned.ps1
[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 / IP-Scan.ps1
Last active Aug 6, 2018
Resolve PTR for an array of IP's
View IP-Scan.ps1
$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",
View keybase.md

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 Jun 10, 2020
PowerShell function to show you when the next patch Tuesday will occur. You can also specify month/year to find historical or future dates.
View Get-PatchTue.ps1
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 Aug 10, 2020
Powershell cmdlet for locating recent files in a specified folder.
View Get-LatestFiles.ps1
<#
.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 Aug 14, 2020
Function to test if the current session is running as an administrator
View Test-IsAdmin.ps1
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 Aug 14, 2020
Function used in conjunction with Test-IsAdmin to start a new Admin Shell (runs powershell or pwsh as admin)
View New-AdminShell.ps1
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