Skip to content

Instantly share code, notes, and snippets.

Ben Gelens bgelens

Block or report user

Report or block bgelens

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bgelens
bgelens / Convert-PesterResultToJUnitXml.ps1
Created Aug 13, 2019
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
View Convert-PesterResultToJUnitXml.ps1
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,
View Expand-PFX.ps1
[cmdletbinding()]
param (
[Parameter(Mandatory)]
[string] $Path,
[Parameter(Mandatory)]
[string] $PFXPin
)
$resolvedPath = Resolve-Path -Path $Path
@bgelens
bgelens / nodeConfigurations.json
Last active Jan 10, 2019
arm template to deploy pre-compiled nodeConfigurations to Azure Automation DSC
View nodeConfigurations.json
{
"$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 Jun 7, 2018
Have ErrorVariable populated through a Mock
View errorvariablemock.ps1
Mock -CommandName Get-SomeCommand -MockWith {
param (
$ErrorVariable
)
$errorRecord = [System.Management.Automation.ErrorRecord]::new(
[System.Exception]::new('Failed!'),
'Error',
[System.Management.Automation.ErrorCategory]::InvalidOperation,
$null
)
View module.psm1
$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
View AzureUpdateManagement.ps1
function Get-SoftwareUpdateConfigurations {
[CmdletBinding(DefaultParameterSetName = 'list')]
param (
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $ResourceGroupName,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $AutomationAccountName,
View deploy.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"osType": {
"type": "string",
"allowedValues": [
"linux",
"windows"
],
View test.sh
echo $1
cat /etc/os-release | grep -i pretty
View test.ps1
param (
[string] $Name = 'GitHub'
)
'Hello World from {0}!' -f $Name
View Expand-AzureRMTemplate.ps1
$armProfileModule = (Get-Module -Name AzureRM.profile -ListAvailable)[0]
Add-Type -Path "$($armProfileModule.ModuleBase)\Newtonsoft.Json.dll"
function Expand-AzureRMTemplate {
<#
.Synopsis
Validates ARM template in combination with parameter file and returns ARM expanded results.
.Example
Expand-AzureRMTemplate -TemplateFile c:\subnet.json -ParameterFile c:\param.json -ResourceGroupName 'myRG'
You can’t perform that action at this time.