Skip to content

Instantly share code, notes, and snippets.

View jimmyca15's full-sized avatar

Jimmy Campbell jimmyca15

View GitHub Profile
jimmyca15 / Certificate.cs
Created December 13, 2017 02:10
Code for creating a self signed certificate in .NET Core using CertEnroll APIs
namespace CreateCert
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
class Certificate
public static async Task<X509Certificate2> Create(string subject, string friendlyName, IEnumerable<string> alternativeNames)
jimmyca15 / Get-InstalledProducts.ps1
Created November 10, 2017 00:56
List installed products on Windows
$reg = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("$UninstallKey")
$products = @()
foreach ($name in $reg.GetSubKeyNames()) {
$product = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("$UninstallKey\$name")
$products += $product.GetValue("DisplayName")
jimmyca15 / MonitoringGet.ps1
Last active October 31, 2017 02:52
PowerShell IIS Administration monitoring demo
# Add type to handle the API certificate
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class ITrustACertificatePolicy : ICertificatePolicy {
public ITrustACertificatePolicy() {}
public bool CheckValidationResult(
ServicePoint sPoint, X509Certificate cert,
WebRequest wRequest, int certProb) {
X509Certificate2 apiCert = cert as X509Certificate2;
jimmyca15 / VssInit.ps1
Last active September 20, 2017 17:36
Azure Scale Set Script Extension
[String] $StorageAccountName,
[String] $StorageAccountKey,
[String] $DriveLetter,
jimmyca15 / Create-SelfSignedCertificate.ps1
Created August 26, 2016 03:32
Create a self signed certificate on Windows (Compatible with Server 2008 R2 - Nano Server)
function Create-SelfSignedCertificate
$subjectDn = new-object -com "X509Enrollment.CX500DistinguishedName"
$subjectDn.Encode( "CN=" + $subject, $subjectDn.X500NameFlags.X500NameFlags.XCN_CERT_NAME_STR_NONE)
$issuer = $Subject