Skip to content

Instantly share code, notes, and snippets.

View bgelens's full-sized avatar

Ben Gelens bgelens

View GitHub Profile
@bgelens
bgelens / pulumi-azurenextgen-sample.cs
Last active October 29, 2020 20:32
Sample using Pulumi Azure NextGen provider to create AKS and deploy app into it.
using Pulumi;
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AzureNextGen = Pulumi.AzureNextGen;
using K8s = Pulumi.Kubernetes;
using Helm3 = Pulumi.Kubernetes.Helm.V3;
class MyStack : Stack
@bgelens
bgelens / ben.json
Last active March 22, 2021 07:03
My oh-my-posh v3 theme!
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": false,
"console_title": false,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
$tenantId = ''
$context = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext
$token = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate(
$context.Account,
$context.Environment,
$context.Tenant.Id.ToString(),
$null,
[Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never,
$null,
'https://management.azure.com/'
@bgelens
bgelens / Get-WECSubscription.ps1
Last active September 9, 2019 07:01
Run on a Windows Event Collector to enumerate the subscriptions and parse out lot's of details with the `-Detailed` switch and get objects instead
function Get-WECSubscription {
param (
[Parameter(ValueFromPipeline, ValueFromPipeLineByPropertyName)]
[ValidateNotNullOrEmpty()]
[string] $Name,
[switch] $Detailed
)
begin {
$wecUtilPresent = ($null -ne (Get-Command -CommandType Application -Name wecutil -ErrorAction SilentlyContinue))
@bgelens
bgelens / Convert-PesterResultToJUnitXml.ps1
Created August 13, 2019 05:47
GitLab does not support NUnitXml as provided by Pester. Instead, it supports JUnitXml. This helper function takes the Pester output and generates a JUnitXml from it to be consumed by GitLab pipelines
function Convert-PesterResultToJUnitXml {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
$PesterResult
)
$junit = '<?xml version="1.0" encoding="utf-8"?>'
$junit += "`n" + '<testsuites name="Pester" tests="{0}" failures="{1}" disabled="{2}" time="{3}">' -f @(
$PesterResult.TotalCount,
[cmdletbinding()]
param (
[Parameter(Mandatory)]
[string] $Path,
[Parameter(Mandatory)]
[string] $PFXPin
)
$resolvedPath = Resolve-Path -Path $Path
@bgelens
bgelens / nodeConfigurations.json
Last active January 10, 2019 17:54
arm template to deploy pre-compiled nodeConfigurations to Azure Automation DSC
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"automationAccountName": {
"type": "string",
"metadata": {
"description": "The name of the automation account."
}
},
@bgelens
bgelens / errorvariablemock.ps1
Created June 7, 2018 13:35
Have ErrorVariable populated through a Mock
Mock -CommandName Get-SomeCommand -MockWith {
param (
$ErrorVariable
)
$errorRecord = [System.Management.Automation.ErrorRecord]::new(
[System.Exception]::new('Failed!'),
'Error',
[System.Management.Automation.ErrorCategory]::InvalidOperation,
$null
)
$enums = Get-ChildItem -Path $PSScriptRoot\enums\*.ps1 -ErrorAction SilentlyContinue | ForEach-Object -Process {
Get-Content $_.FullName
}
if (Test-Path "$PSScriptRoot\Classes\classes.psd1") {
$ClassLoadOrder = Import-PowerShellDataFile -Path "$PSScriptRoot\classes\classes.psd1" -ErrorAction SilentlyContinue
}
$classes = foreach ($class in $ClassLoadOrder.order) {
$path = '{0}\classes\{1}.ps1' -f $PSScriptRoot, $class
function Get-SoftwareUpdateConfigurations {
[CmdletBinding(DefaultParameterSetName = 'list')]
param (
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $ResourceGroupName,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $AutomationAccountName,