Skip to content

Instantly share code, notes, and snippets.

@rmbolger
rmbolger / Convert-PfxToPem.ps1
Last active December 3, 2024 10:48
Convert-PfxToPem.ps1
# Adapted from Vadims Podāns' amazing work here.
# https://www.sysadmins.lv/blog-en/how-to-convert-pkcs12pfx-to-pem-format.aspx
#
# Also, if you need a more complete PKI PowerShell module, he has authored one here:
# https://github.com/Crypt32/PSPKI
#
# This version of the function includes a few fixes from the module's version of the
# function and changes up the output options so you get separate .crt/.key files by
# default named the same as the pfx file (or thumbprint if directly referencing a cert).
# -IncludeChain adds an additional -chain.pem. Relative paths are now
@danmaq
danmaq / rund4wsl.sh
Last active August 13, 2016 07:06
/etc/rcX.d/AllScripts launcher for "Ubuntu on Windows". Usage: sudo rund4wsl.sh -l <runlevel> -o <start|stop>
#!/bin/bash
failed()
{
echo $1 1>&2
exit 1
}
usage()
{
failed "Usage: sudo $0 -l <runlevel> -o <start|stop>"
@meziantou
meziantou / CredentialManager.cs
Last active January 5, 2025 03:16
Using the Windows Credential API (CredRead, CredWrite, CredDelete, CredEnumerate).
// The most up to date version is available
// on GitHub: https://github.com/meziantou/Meziantou.Framework/tree/master/src/Meziantou.Framework.Win32.CredentialManager
// NuGet package: https://www.nuget.org/packages/Meziantou.Framework.Win32.CredentialManager/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32.SafeHandles;
@cdhunt
cdhunt / Get-CredentialFromWindowsCredentialManager.ps1
Last active September 4, 2024 19:46 — forked from toburger/Get-CredentialFromWindowsCredentialManager.ps1
Gets a PowerShell Credential [PSCredential] from the Windows Credential Manager. This only works for Generic Credentials.
<#
.SYNOPSIS
Gets a PowerShell Credential (PSCredential) from the Windows Credential Manager
.DESCRIPTION
This module will return a [PSCredential] object from a credential stored in Windows Credential Manager. The
Get-StoredCredential function can only access Generic Credentials.
Alias: GSC