Skip to content

Instantly share code, notes, and snippets.

View jwmoss's full-sized avatar
🤩
Stuck in a foreach loop

Jonathan Moss jwmoss

🤩
Stuck in a foreach loop
View GitHub Profile
@jwmoss
jwmoss / setupiisforsslperfectforwardsecrecy_v17.ps1
Created November 15, 2021 19:05 — forked from jbratu/setupiisforsslperfectforwardsecrecy_v17.ps1
Great powershell script for tightening HTTPS security on IIS and disabling insecure protocols and ciphers. Very useful on core installations.
# Copyright 2019, Alexander Hass
# https://www.hass.de/content/setup-microsoft-windows-or-iis-ssl-perfect-forward-secrecy-and-tls-12
#
# After running this script the computer only supports:
# - TLS 1.2
#
# Version 3.0.1, see CHANGELOG.txt for changes.
Write-Host 'Configuring IIS with SSL/TLS Deployment Best Practices...'
Write-Host '--------------------------------------------------------------------------------'
@jwmoss
jwmoss / setup.sh
Last active April 9, 2021 19:58 — forked from brettmillerb/setup.sh
New Mac Setup
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Update homebrew recipes
echo "Updating homebrew..."
brew update
[CmdletBinding()]
param(
[Parameter( Mandatory, Position = 1, ValueFromPipelineByPropertyName, ValueFromPipeline )]
[Alias( 'HostName', 'Server' )]
[string[]]
$ComputerName,
[System.DirectoryServices.ActiveDirectory.SyncFromAllServersOptions]
$SyncOptions = @( 'CrossSite', 'PushChangeOutward', 'SkipInitialCheck' ),
@jwmoss
jwmoss / Jenkinsfile
Created November 10, 2020 02:38 — forked from merikan/Jenkinsfile
Some Jenkinsfile examples
Some Jenkinsfile examples
@jwmoss
jwmoss / Get-HTMLTable.ps1
Created September 18, 2020 06:59 — forked from JustinGrote/Get-HTMLTable.ps1
Get-HTMLTable Prototype
using namespace HtmlAgilityPack
function Get-HTMLTable {
[CmdletBinding()]
param(
[Parameter(Mandatory,ValueFromPipeline)][HtmlNode]$HtmlDocument
)
process {
foreach ($table in $HtmlDocument.SelectNodes('//table')) {
@jwmoss
jwmoss / StandardDeviation.ps1
Created August 1, 2020 03:07 — forked from powercode/StandardDeviation.ps1
Calculate Standard Deviation is PowerShell
using namespace System.Collections.Generic
using namespace System.Linq
class StandardDeviation{
hidden [decimal] $Average
StandardDeviation([decimal] $average){
$this.Average = $average
}
enum UserRight {
SeAssignPrimaryTokenPrivilege # Replace a process level token
SeAuditPrivilege # Generate security audits
SeBackupPrivilege # Back up files and directories
SeBatchLogonRight # Log on as a batch job
SeChangeNotifyPrivilege # Bypass traverse checking
SeCreateGlobalPrivilege # Create global objects
SeCreatePagefilePrivilege # Create a pagefile
SeCreatePermanentPrivilege # Create permanent shared objects
SeCreateSymbolicLinkPrivilege # Create symbolic links
function Get-InstalledSoftware {
<#
.SYNOPSIS
Get all installed from the Uninstall keys in the registry.
.DESCRIPTION
Read a list of installed software from each Uninstall key.
This function provides an alternative to using Win32_Product.
.EXAMPLE
Get-InstalledSoftware
@jwmoss
jwmoss / Uninstall-Pester.ps1
Created April 17, 2019 15:38 — forked from nohwnd/Uninstall-Pester.ps1
Remove built-in version of Pester on Windows 10, and all other versions of Pester
#Requires -RunAsAdministrator
$modulePath = "C:\Program Files\WindowsPowerShell\Modules\Pester"
if (-not (Test-Path $modulePath)) {
"There is no Pester folder in $modulePath, doing nothing."
break
}
takeown /F $modulePath /A /R
icacls $modulePath /reset

Credit: Mark Kraus
Website: https://get-powershellblog.blogspot.com

Collection Type Guidance

When to use what

  • Use Arrays if you know the element types and have a fixed length and/or known-up-front collection size that will not change.
  • Use ArrayList if you have an unkown collection size with either unknown or mixed type elements.
  • Use a Generic List when know the type of the elements but not the size of the collection.
  • Use a HashTable if you are going to do key based lookups on a collection and don't know the object type of the elements.
  • Use a Dictionary<TKey, TValue> you are going to do key based lookups on a collection and you know the type of the elements.
  • Use a HashSet when you know the type of elements and just want unique values and quick lookups and assignmnets.