Skip to content

Instantly share code, notes, and snippets.

@phbits
phbits / Get-Minikube-function.ps1
Created September 16, 2021 15:34
Gets latest Minikube stable or beta release.
Function Get-Minikube
{
[CmdletBinding()]
param
(
<#
.SYNOPSIS
Gets latest Minikube stable or beta release.
.DESCRIPTION
############################################[   DRAFT   ]#############################################

The following documentation describes the process of integrating a non-DSC PowerShell module called MyModule into the Sampler module framework. Benefits of this approach include an automated build pipeline that can easily leverage custom or community developed tasks.

For technical details, refer to:

param([int]$RecordID)
# Created for: https://github.com/phbits/WebsiteFailedLogins/issues/2
# Sample Event Message Data #
<#
ClientIP = 127.0.0.1
FailedLogins = 20
Sitename = W3SVC1
IISLogPath = C:\inetpub\logs\LogFiles\W3SVC\*
# Created for: https://github.com/phbits/WebsiteFailedLogins/issues/2
# NOTE - ExecutionPolicy set to Unrestricted should only be used for testing.
$Action = New-ScheduledTaskAction -Execute 'C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe' `
-Argument '-NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -File .\Application-EventID10.ps1 -RecordID $(eventRecordID) -ExecutionPolicy Unrestricted' `
-WorkingDirectory 'C:\WebsiteFailedLogins\'
$Principal = New-ScheduledTaskPrincipal -UserId 'NT AUTHORITY\SYSTEM' -LogonType ServiceAccount
$Settings = New-ScheduledTaskSettingsSet -DisallowDemandStart -Compatibility Win8 -Hidden -WakeToRun `
Function Get-CspSha256Hash
{
<#
.SYNOPSIS
Generates SHA256 hash for Content Security Policy (CSP).
.DESCRIPTION
Creates a SHA256 hash of provided inline text to satisfy CSP.
.EXAMPLE
$Style = "html, body { height: 100%; font-family: 'Courier'; } .listed-item { display: flex; justify-content: center; align-items: center; }"
Get-CspSha256Hash $Style
@phbits
phbits / OCSP-Update.sh
Created August 18, 2020 19:20
Update OCSP staple file for relayd via cron.
#!/bin/sh
# save as /etc/OCSP-Update.sh
# script launched via cron to update OCSP staple file
# for use with relayd. Run script on first use to schedule
# next launch.
# sh /etc/OCSP-Update.sh
# Tested on OpenBSD 6.7
@phbits
phbits / GetServiceDscConfig.ps1
Last active October 17, 2020 04:09
Generates a Service configuration for DSC based on the local system.
Function Get-ServiceDscConfig
{
<#
.SYNOPSIS
Generates a Service configuration for DSC based on the local system.
.EXAMPLE
Get-ServiceDscConfig
@phbits
phbits / SUSS.go
Last active December 1, 2021 14:51
Simple URL Shortening Service
package main
import (
"flag"
"log"
"io/ioutil"
"encoding/json"
"net/http"
"regexp"
)
Function Set-SchannelProtocol
{
<#
.SYNOPSIS
Disables schannel protocols by default. Enable a protocol by using the -EnableProtocol switch.
.DESCRIPTION
Microsoft IIS uses schannel for implementing HTTPS. This function will enable/disable protocols for both the client and server.