Skip to content

Instantly share code, notes, and snippets.

🌠
Shooting for the stars!

Andrew Pla AndrewPla

🌠
Shooting for the stars!
Block or report user

Report or block AndrewPla

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@AndrewPla
AndrewPla / New-TempDirectory
Last active Dec 11, 2019
Cross-platform function to create temp folders. Created by Justin Grote https://twitter.com/JustinWGrote/status/1190311627746267136
View New-TempDirectory
function New-TempDirectory {
$pathToCreate = join-path ([io.path]::GetTempPath()) ([io.path]::GetRandomFileName())
New-Item -ItemType Directory -Path $pathToCreate
}
@AndrewPla
AndrewPla / PicoCTF2019_Based.ps1
Created Dec 1, 2019
This script was written to solve the Based challenge from PicoCTF 2019.
View PicoCTF2019_Based.ps1
<#
.Description
This script was written to solve the Based challenge from PicoCTF 2019.
This script connects to a target computer nad port and converts the output from Base2, Base8, and Base16.
It establishes a tcp connection, answers the questions and returns the flag for this challenge.
#>
[cmdletbinding()]
param(
[string]$computer = '2019shell1.picoctf.com',
$port = '44303',
@AndrewPla
AndrewPla / Get-PublicIPInfo.ps1
Last active Sep 11, 2019
Returns Public IP info from ip.nf Can be ran on remote computers
View Get-PublicIPInfo.ps1
function Get-PublicIPInfo {
<#
.Description
Returns Public IP info from ip.nf
.Parameter IPAddress
Supply an IP address that you would like to lookup.
.Parameter ComputerName
Names of computers to run this command on.
.Parameter Credential
Credential used by Invoke-Command when performing the lookup on a remote machine.
View Get-MmaEvent.ps1
function Get-MmaEvent {
<#
.Description
Returns upcoming MMA events from https://www.whenarethefights.com/
#>
$request = Invoke-WebRequest -Uri 'https://www.whenarethefights.com/'
# Only grab the events that have a countdown.
$content = $request.Links.outertext | Where-Object {$_ -like '*days*'}
View Add-WindowsTerminalSchemes.ps1
# Path to the profile when installed from the Windows Store.
$profilePath = "C:\Users\$Env:Username\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\profiles.json"
$profile = Get-Content $ProfilePath | ConvertFrom-Json
$backupProfilePath = "$home\Documents\WindowsTerminalprofiles.json"
Write-Verbose "Backing up profile to $backupProfilePath"
$profile | ConvertTo-Json | Set-Content $backupProfilePath
@AndrewPla
AndrewPla / Parse-TOPdeskAccessLog.ps1
Last active Feb 6, 2019
Downloads yesterday's access log from TOPdesk. We then extract the logfile from the zip and parse it. Finally we output an object. For a cleaner implementation of this see the TOPdeskPS module github.com/AndrewPla/TOPdeskPS
View Parse-TOPdeskAccessLog.ps1
$credential = Get-Credential -Message 'enter TOPdesk credentials.'
# folder where we want to copy the access log zip
$Directory = 'c:\Path\To\Folder'
# Splat our parameters
$psDriveParams = @{
PSProvider = 'FileSystem'
Root = '\\company.topdesk.net@SSL\webdav' # ex: '\\contoso.topdesk.net@SSL\webdav'
Credential = $credential
@AndrewPla
AndrewPla / Download-Latest_TOPdesk_Backup.ps1
Created Jan 28, 2019
Download the latest backup from TOPdesk using PowerShell.
View Download-Latest_TOPdesk_Backup.ps1
# Credential needs to
$Credential = Get-Credential -Message 'enter TOPdesk operator credential with WebDAV permissions.'
$OutputFolder = 'C:\path\to\folder'
$tdurl = 'company.topdesk.net'
$psDriveParams = @{
PSProvider = 'FileSystem'
Root = "\\$tdUrl@SSL\webdav" # ex: '\\contoso.topdesk.net@SSL\webdav'
Credential = $Credential
Name = 'TOPdesk'
@AndrewPla
AndrewPla / Iterate Over PSCustomObject Properties Example.ps1
Created Jan 6, 2019
iterate through all properties on a pscustomobject. This is example code to accompany a blogpost.
View Iterate Over PSCustomObject Properties Example.ps1
# Create a pscustomobject from a hashtable
$object = [pscustomobject]@{ Key1 = 'Val1' ; Key2 = 'Val2' }
# Grab all noteproperty members
$objMembers = $object.psobject.Members | where-object membertype -like 'noteproperty'
foreach ($member in $objMembers) {
# Now you can do what you want with the name and value.
$Member.name
$Member.Value
You can’t perform that action at this time.