Skip to content

Instantly share code, notes, and snippets.

View Jaykul's full-sized avatar
😀
Learning

Joel Bennett Jaykul

😀
Learning
View GitHub Profile
@jborean93
jborean93 / Get-SqlServerTlsCertificate.ps1
Last active October 4, 2023 17:46
Gets the certificate used by a MS SQL Server
# Copyright: (c) 2023, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Get-SqlServerTlsCertificate {
<#
.SYNOPSIS
Gets the MS SQL X509 Certificate.
.DESCRIPTION
Gets the X509 Certificate that is being used by a remote MS SQL Server.
using namespace System
using namespace System.Linq
using namespace System.Collections
using namespace System.Collections.Generic
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
using namespace System.Reflection
# Hey person reading this! Don't do this, alright? You'll have a bad time. ty
@jborean93
jborean93 / Trace-TlsHandshake.ps1
Last active December 7, 2023 14:49
Debug TLS Handshakes using .NET
# Copyright: (c) 2022, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Trace-TlsHandshake {
<#
.SYNOPSIS
TLS Handshake Diagnostics.
.DESCRIPTION
Performs a TLS handshake and returns diagnostic information about that
class ConstrainedVariableInterpolation : System.Management.Automation.Language.AstVisitor {
hidden [Hashtable] $Property
[System.Collections.Generic.List[PSCustomObject]] $Result
hidden [System.Management.Automation.Language.Ast] $Ast
[System.Management.Automation.Language.AstVisitAction] CheckForPostAction([System.Management.Automation.Language.Ast] $ast, [System.Management.Automation.Language.AstVisitAction] $action)
{
throw 'CheckForPostAction not supported'
}
using namespace System.Management.Automation
using namespace System.Collections.Generic
class ArgumentCompleterBase : IArgumentCompleter {
hidden [List[CompletionResult]] $Results = [List[CompletionResult]]::new()
[string] $WordToComplete
[Language.CommandAst] $commandAst
# override in child class
[void] AddCompletionsFor([string] $commandName, [string] $parameterName, [Collections.IDictionary] $fakeBoundParameters) {}
@Agazoth
Agazoth / Get-MonitorInfo.ps1
Last active April 15, 2023 23:24
Iron Scripter 2018 Puzzle 1 for multiple machines
function Get-MonitorInfo {
[CmdletBinding()]
param ([string[]]$ComputerNames = $env:computername)
foreach ($ComputerName in $ComputerNames){
try {
$CimSession = New-CimSession -ComputerName $ComputerName
} catch {
Write-Warning "Please make sure PSRemoting is enabled on $ComputerName"
Continue
}
@Jaykul
Jaykul / Trace-Dependency.ps1
Last active October 6, 2022 09:38
Extract a list of commands used by a script or script command. Will warn about commands it can't identify and put them in global `$MissingCommands` variable.
#requires -Module Reflection
[CmdletBinding()]
param(
# The path to a script or name of a command
$Command,
# If you want to include private functions from a module, make sure it's imported, and pass the ModuleInfo here
[System.Management.Automation.PSModuleInfo]$ModuleScope = $(
Get-Module $Command -ListAvailable -ErrorAction SilentlyContinue | Get-Module -ErrorAction SilentlyContinue
),
Set-PowerLinePrompt `
-SetCurrentDirectory `
-RestoreVirtualTerminal `
-PowerLineFont `
-FullColor `
-Title {
$title = "PowerShell {0} - {1} ({2}) - PID: {3}" -f $PSVersionTable.PSVersion.ToString(),(Convert-Path $pwd), $pwd.Provider.Name,$PID
if (Test-Elevation) {
"Elevated - $title"
} else {
@amandadebler
amandadebler / BootlegPowerShellGet.psm1
Last active October 16, 2019 18:34 — forked from Jaykul/PowerShellGet.psm1
PowerShell Gallery Module - Bootleg Edition
<#
Forked from https://github.com/jaykul Gist, posted in response to my Twitter
whinge about PowerShellGet in the enterprise - Thank you, Joel Bennett!
This adds the ability to use a web proxy, using your current session's
credentials. Might add option to use other credentials, if there's demand.
It also adds a 'BL' (Bootleg) prefix to the nouns, just to prevent confusion with the "real"
cmdlets. Feel free to remove them.
@msnelling
msnelling / Install-Miniconda.ps1
Created December 16, 2016 09:01
Installs Miniconda from extracted .exe installer
param(
[string]$Exe7z,
[string]$PackageDir,
[string]$InstallDir
)
Function Expand-ToDirectory {
param(
[string]$Archive,
[string]$TargetDir