Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am maverik on github.
  • I am maverik (https://keybase.io/maverik) on keybase.
  • I have a public key ASAsTbvDO_BXz021JE9WlDAIOy9tVgQXcXe3WXl44zfx7Qo

To claim this, I am signing this object:

@Maverik
Maverik / ExchangePowershellQuery.cs
Last active January 3, 2018 16:08
Call Exchange Powershell Commands from C# using minimal module definitions only
static readonly SerializationTypeConverter Converter = new SerializationTypeConverter();
static readonly Command SelectSerializationDataCommand = new Command("Select-Object") { Parameters = { { "Property", "SerializationData" } } };
static IEnumerable<T> ExchangeSerializerCastTo<T>(IEnumerable<object> results) => results.Where(x => Converter.CanConvertFrom(x, typeof(T)))
.Select(x => Converter.ConvertFrom(x, typeof(T), CultureInfo.CurrentCulture, false))
.OfType<T>();
void Main()
{
var state = InitialSessionState.CreateDefault2();
//Exchange2010SP3.psm1 was created using `Export-PSSession -OutputModule Exchange2010SP3 -CommandName *` command
@Maverik
Maverik / onename.md
Created April 6, 2017 12:29
Onename Blockstack ID Verification
@Maverik
Maverik / CSRGenerator.cs
Last active August 4, 2020 10:56
CSR Generator Snippet for Linqpad (C#)
// this snippet can be easily used in any normal c# project as well by simply removing the .Dump() methods
// and saving the output into a variable / file of your choice.
// you'll need to add BouncyCastle.Crypto nuget to use this.
// tested on 1.8.1
// OUTPUTS: CSR, Private Key, Public Key, Self-signed Certificate
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Cms;
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Asn1.X509;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Reflection;
using System.IO;
using System.Windows;
using System.Windows.Forms;