Skip to content

Instantly share code, notes, and snippets.

View markekraus's full-sized avatar
😀

Mark Kraus markekraus

😀
View GitHub Profile
@markekraus
markekraus / Get-AADBitLockerRcoveryKey.ps1
Last active June 6, 2018 12:26
Get BitLocker Recovery Key from Azure AD
#Requires -Modules AzureRM.Profile, AzureAD
$DeviceObjectId = '' # Set an objectID for a device
$SubScriptionID = '' # change with your subscription ID
Add-AzureRmAccount
$Subscription = Select-AzureRmSubscription -Subscription $SubScriptionID
$currentAzureContext = Get-AzureRmContext -Name $Subscription.Name
$TenantId = $currentAzureContext.Tenant.Id
$tokenCache = $currentAzureContext.TokenCache
$Cache = $tokenCache.ReadItems().Where({$_.ExpiresOn -gt (Get-Date) -and $_.TenantId -eq $TenantId })[0]

Keybase proof

I hereby claim:

  • I am markekraus on github.
  • I am markekraus (https://keybase.io/markekraus) on keybase.
  • I have a public key ASAQRsY5KChGA8ePPV6gQ5ilSZ4KFmVciWsQL-ud4zZnGAo

To claim this, I am signing this object:

@markekraus
markekraus / Demo.ps1
Last active May 12, 2021 05:42
Format the Pipeline as Markdown
Invoke-WebRequest 'google.com' | Out-MarkDown
@markekraus
markekraus / Test-StringExpansionScoping.ps1
Created April 18, 2018 18:14
String Expansion Scoping... Wat?
$MyObjGlobal = [PSCustomObject]@{
PSTypeName = 'MyObj'
Prop1 = 'Value1'
}
$MyObjFunction = [PSCustomObject]@{
PSTypeName = 'MyObj'
Prop1 = 'Value1'
}
@markekraus
markekraus / DownloadCmdletDemo.cs
Created March 31, 2018 20:13
Demo of the Download Cmdlet Interfaces and a fake mock up the the cmdlet and how it would use them
using System;
using System.Collections.Generic;
using System.IO;
using System.Management.Automation;
using System.Text;
namespace System.Management.Automation
{
internal interface IInvokeDownloadProtocolFactory
{
@markekraus
markekraus / PBnC-Deployment.log
Created March 16, 2018 13:44
Peanut Butter and Chocolate Deployment Log data from Azure Functions Web App Deployment and AWS CloudWatch for AWS Lambda
----------------------- Azure Web App Deployment Log -----------------------------------
log_time : 2018-02-18T21:11:19.1757131Z
id : 9e378a01-337f-4303-bd35-39f84845320b
message : Updating submodules.
type : 0
details_url :
log_time : 2018-02-18T21:11:19.3475551Z
@markekraus
markekraus / GetInboxRuleReport.ps1
Last active January 31, 2019 18:33
Generates Multi-Threaded Office 365 Inbox Rule Report That Scales with the Number of Service Accounts Provided
using namespace System.Collections.Concurrent
$StartDate = [datetime]::UtcNow
# can be generated with something like
# 1..10 | %{ Get-Credential} | Export-CliXml -path 'C:\reports\InboxRules\Creds.xml'
# Which will prompt for credentials 10 times and store them in the xml file
$CredentialFile = 'C:\reports\InboxRules\Creds.xml'
$RunDate = $StartDate.ToString('o') -replace ':'
# This is the path of the CSV file. It is imperative that this file not be
# access while the script is running
@markekraus
markekraus / ConvertKMSEncryptedStrings.ps1
Created February 18, 2018 19:41
PowerShell Functions to convert a string to a base64 representation of the KMS encryoted string and to convert back to an unencrypted string
function ConvertTo-Base64KMSEncryptedString {
[CmdletBinding()]
param (
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true
)]
[String[]]
$String,
@markekraus
markekraus / CodeCommitEvent.cs
Last active February 13, 2018 21:03
CodeCommitEvent Model for Receiving CodeCommit Events in C# AWS Lambdas
using System;
namespace Lambda
{
public class CodeCommitEventCodecommitReference
{
public string commit;
public bool created = false;
public string @ref;
@markekraus
markekraus / StyleCopErrors.txt
Created December 21, 2017 13:40
Web Cmdlet StyleCop Issues
.\commands\utility\WebCmdlet\StreamHelper.cs(279,27): error SA1204: Static members should appear before non-static members
.\commands\utility\WebCmdlet\FormObject.cs(40,16): error SA1201: A constructor should not follow a property
.\commands\utility\WebCmdlet\FormObject.cs(17,23): error SA1609: Property documentation should have value
.\commands\utility\WebCmdlet\FormObject.cs(22,23): error SA1609: Property documentation should have value
.\commands\utility\WebCmdlet\FormObject.cs(27,23): error SA1609: Property documentation should have value
.\commands\utility\WebCmdlet\FormObject.cs(32,43): error SA1609: Property documentation should have value
.\commands\utility\WebCmdlet\FormObjectCollection.cs(19,13): error SA1616: Element return value documentation should have text
.\commands\utility\WebCmdlet\FormObjectCollection.cs(18,13): error SA1614: Element parameter documentation should have text
.\commands\utility\WebCmdlet\Common\BasicHtmlWebResponseObject.Common.cs(5,1): error SA1200: Using directive should ap