Skip to content

Instantly share code, notes, and snippets.

View markekraus's full-sized avatar
😀

Mark Kraus markekraus

😀
View GitHub Profile
@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 / 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 / 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 / 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 / Demo.ps1
Last active May 12, 2021 05:42
Format the Pipeline as Markdown
Invoke-WebRequest 'google.com' | Out-MarkDown

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 / 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]
@markekraus
markekraus / Out-Default.ps1
Created June 15, 2018 19:05
Cheap Screen reader code for PowerShell
Function Out-Default {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline)]
[PSObject]
$InputObject,
[switch]
$Transcript
)
@markekraus
markekraus / AzCmdletMapping.md
Last active February 18, 2024 17:34
Az to AzureRm Cmdlet Mappings

Az to AzureRM command Mappings

Source

Az.Aks

Az Command AzureRm Command
Get-AzAks Get-AzureRmAks
New-AzAks New-AzureRmAks
@markekraus
markekraus / ARM-Logic.txt
Created January 8, 2019 15:21
Perform Conditional Operations on Parameters in Azure ARM templates
[
if(
equals(
parameters('settings')[copyIndex('settings')].type,
'static'
),
parameters('settings')[copyIndex('settings')].value,
if(
equals(
parameters('settings')[copyIndex('settings')].type,