Skip to content

Instantly share code, notes, and snippets.

if (-not (Get-Command choco -ErrorAction SilentlyContinue) ) {
Invoke-Webrequest https://chocolatey.org/install.ps1 | Invoke-Expression
}
choco source add -n=Certus -s "https://pkgs.dev.azure.com/Tactis/Repo/_packaging/Certus/nuget/v2"
choco source disable -n=Chocolatey
@mcx808
mcx808 / Get-RemoteCertificate.ps1
Created November 5, 2024 15:13
Get-RemoteCertificate.ps1
function Get-RemoteCertificate {
<#
.SYNOPSIS
Retrieves the SSL certificate from a remote server.
.DESCRIPTION
The Get-RemoteCertificate function connects to a specified remote server using its URI and retrieves the SSL certificate. It uses a TcpClient to establish the connection and an SslStream to perform the SSL handshake. The function returns the remote server's SSL certificate as an X509Certificate object.
.PARAMETER Uri
The URI of the remote server from which to retrieve the SSL certificate. This parameter is mandatory and accepts pipeline input.
.PARAMETER TimeoutMilliseconds
The timeout period in milliseconds for the connection attempt. The default value is 500 milliseconds.
@mcx808
mcx808 / Enable-PwshSubsystemForSsh.ps1
Created September 27, 2024 10:39
Enable Powershell Subsystem for SSH on Linux
$subsystemConfig = @"
Subsystem powershell /usr/bin/pwsh -sshs -nologo`n
"@
$existingContent = Get-Content -Path /etc/ssh/sshd_config -Raw
$lastSubsystemIndex = $existingContent.LastIndexOf("Subsystem")
$newContent = $existingContent.Insert($lastSubsystemIndex, $subsystemConfig)
Set-Content /etc/ssh/sshd_config -Value $newContent
systemctl restart sshd
@mcx808
mcx808 / Add-SshKeys.ps1
Created November 6, 2023 16:09
Add github user keys to authorized_keys file
if(-not(Test-Path ~/.ssh)) {New-Item ~/.ssh -ItemType Directory}
(Invoke-WebRequest https://github.com/mcx808.keys).Content | Out-File ~/.ssh/authorized_keys -Append
@mcx808
mcx808 / Install-Powershell-on-Debian-11.sh
Created October 5, 2022 09:18
Install Powershell on Debian 11
# Install system components
sudo apt update && sudo apt install -y curl gnupg apt-transport-https
# Import the public repository GPG keys
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
# Register the Microsoft Product feed
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list'
# Install PowerShell
@mcx808
mcx808 / Get TLS certificate.ps1
Created July 27, 2022 14:51
Gets a remote TLS certificate in Powershell 6/7
function Get-RemoteCertificate {
[CmdletBinding()]
[OutputType([System.Security.Cryptography.X509Certificates.X509Certificate])]
param (
[Parameter(
Mandatory,
ValueFromPipeline
)]
[ValidateNotNull()]
[Uri]
@mcx808
mcx808 / README.md
Created March 9, 2022 10:15 — forked from shawnsi/README.md
Ansible Vault Environment Variable

Ansible Vault Environment Variable

Per http://docs.ansible.com/ansible/playbooks_vault.html you can set an environment variable to use a password file for vault access. We can use this to create an environment variable to hold the password.

Password Script

Copy vault-env from this project to ~/bin. Then add this to your ~/.bashrc:

export ANSIBLE_VAULT_PASSWORD_FILE=~/bin/vault-env
#Sets user interface preferences
#Configure keyboard & language prefs
Set-WinUserLanguageList en-US -Force
Set-WinUILanguageOverride -Language en-GB
#show extensions for known file types
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -name 'HideFileExt' -Value 0
#show hidden files and folders
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -name 'Hidden' -Value 1
@mcx808
mcx808 / config.xml
Created May 21, 2021 16:53
Notepad++ Preferences
<?xml version="1.0" encoding="Windows-1252" ?>
<NotepadPlus>
<FindHistory nbMaxFindHistoryPath="10" nbMaxFindHistoryFilter="10" nbMaxFindHistoryFind="10" nbMaxFindHistoryReplace="10" matchWord="no" matchCase="no" wrap="yes" directionDown="yes" fifRecuisive="yes" fifInHiddenFolder="no" fifFilterFollowsDoc="no" fifFolderFollowsDoc="no" searchMode="0" transparencyMode="1" transparency="150" dotMatchesNewline="no" isSearch2ButtonsMode="no" regexBackward4PowerUser="no">
<Filter name="" />
<Filter name="" />
<Find name="api" />
<Find name="custom" />
<Find name="customerror" />
<Replace name="" />
<Replace name="" />
@mcx808
mcx808 / Install-Powershell-on-Debian-10.sh
Created March 22, 2021 11:18
Install Powershell on Debian 10 (Buster)
# Download the Microsoft repository GPG keys
wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Update the list of products
sudo apt-get update
# Install PowerShell