Skip to content

Instantly share code, notes, and snippets.

View sdwheeler's full-sized avatar
🖥️
Marking down

Sean Wheeler sdwheeler

🖥️
Marking down
View GitHub Profile
@sdwheeler
sdwheeler / parse-netstat.ps1
Created September 29, 2021 00:05
Example for parsing the output from netstat
function parseNetstat {
param([object[]]$Lines)
if ($IsWindows) {
$skip = 4
} else {
$skip = 3
}
$Lines | Select-Object -Skip $skip | ForEach-Object {
function New-DevOpsWorkItem {
param(
[Parameter(Mandatory=$true)]
[string]$title,
[Parameter(Mandatory=$true)]
[string]$description,
[int]$parentId,
@sdwheeler
sdwheeler / cards.ps1
Last active October 2, 2021 08:43
Poker hand example using Update-List
class Cards {
[System.Collections.Generic.List[string]]$cards
[string]$name
Cards([string]$_name) {
$this.name = $_name
$this.cards = [System.Collections.Generic.List[string]]::new()
}
NewDeck() {
@sdwheeler
sdwheeler / show-redirects.ps1
Last active November 16, 2022 23:58
Script to show each step of a redirection chain
param(
[string]$startURL,
[switch]$showall
)
$ErrorActionPreference = 'Stop'
$Error.Clear()
$lastError = $null
function getUrl {
function get-logonevents {
param(
[string]$computer=$env:computername,
[int]$days = 30
)
$millisecperday = 24*60*60*1000
$logonType = @{
2='Interactive';
3='Network';
4='Batch';
@sdwheeler
sdwheeler / update-sysinternals.ps1
Created October 8, 2016 21:29
Download the latest version of the sysinternals tools
function update-sysinternals {
param([switch]$exclusions=$false)
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = [Security.Principal.WindowsPrincipal] $identity
if($principal.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
$web = get-service webclient
if ($web.status -ne "Running") { "Starting webclient..."; start-service webclient }
$web = get-service webclient
while ($web.status -ne "Running") { sleep -sec 1 }
if ($exclusions) {