Skip to content

Instantly share code, notes, and snippets.

@tech-zombie
tech-zombie / _part1.ps1
Created Dec 6, 2020
AdventOfCode2020 day6
View _part1.ps1
$list = gc .\day6input.txt -Delimiter "`n`r"
$answer = 0
foreach ($group in $list)
{
$group = (($group -replace "`n","")-replace " ","")-replace "`r",""
$answer = $answer + (($group.ToCharArray() | sort -unique).count)
}
$answer
@tech-zombie
tech-zombie / _part1.ps1
Last active Dec 6, 2020
AdventOfCodeDay5
View _part1.ps1
#####puzzle can be found here: https://adventofcode.com/2020/day/5
$list = gc .\day5Input.txt
$highest =0
foreach ($ticket in $list)
{
$rowCode = $ticket.Substring(0,7).ToCharArray()
$columnCode = $ticket.Substring(7,3).ToCharArray()
$rowLowerbound = 0
@tech-zombie
tech-zombie / _part1.ps1
Last active Dec 4, 2020
Advent of code day3 2020 POSH
View _part1.ps1
#puzzle can be found at https://adventofcode.com/2020/day/3
$i = gc .\input.txt
$position = 1
$results = $null
$horizontalMovement = 3
foreach($line in $i)
View AdventOfCode2020-day2 -part1
################PART 1################
(((Get-Content .\input.txt -raw) -replace " ",",") -replace "-",",") -replace ":","" > input.csv
$header ="min","max","char","password"
$list = import-csv .\input.csv -header $header
$total = 0
foreach ($line in $list)
{
View AdventOfCode2020-day1
#https://adventofcode.com/2020/day/1
################part 1################
$list = Get-Content .\list.txt
foreach ($item in $list)
{
foreach ($item1 in $list)
{
$total = [int]$item + [int]$item1
if ($total -eq 2020)
@tech-zombie
tech-zombie / executePoSHfromPage.aspx.cs
Last active Nov 13, 2020
executePoSHfromPage.aspx.cs
View executePoSHfromPage.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Management.Automation;
using System.Text;
namespace PowerShellExecution
View callPoSHscriptFromWeb.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PowerShellExecution.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
@tech-zombie
tech-zombie / set-dnsServer.ps1
Last active Jan 29, 2019
Sets DNS server based on octet in AWS
View set-dnsServer.ps1
<##>
param (
[int]$WhichOctet,
[int]$Zone1_OctetValue,
[int]$Zone2_OctetValue,
$DNSZone1_server,
$DNSZone2_server
)
@tech-zombie
tech-zombie / connect-to-webiste.ps1
Created Jan 9, 2019
Quick and stupid traffic generator, will show chrome on site so you can see how it deals with traffic, has a hard dependency on chrome.
View connect-to-webiste.ps1
Function connect-towebsite
{
Param($siteURL)
cd "C:\Program Files (x86)\Google\Chrome\Application\"
for ($i=0; $i -lt 100; $i++)
{
.\chrome.exe -incognito $siteURL
start-sleep 5
get-process "*chrome*" | Stop-Process
@tech-zombie
tech-zombie / get-newestfile.ps1
Last active Jan 9, 2019
Powershell to get newest file in folder
View get-newestfile.ps1
function Get-NewestFile
{
param($PathToDirectory)
$NewestFile = Get-ChildItem $PathToDirectory | sort LastWriteTime | select -last 1
$PathToNewestFile = $PathToDirectory + "\" + $NewestFile
$PathToNewestFile
}