Skip to content

Instantly share code, notes, and snippets.

View bgelens's full-sized avatar

Ben Gelens bgelens

View GitHub Profile
wget -Uri https://raw.githubusercontent.com/PowerShell/DscResources/master/Tests.Template/integration_template.ps1 -OutFile .\NetworkingDsc\Tests\Integration\MSFT_LMHost.Integration.Tests.ps1
wget -Uri https://raw.githubusercontent.com/PowerShell/DscResources/master/Tests.Template/integration_config_template.ps1 -OutFile .\NetworkingDsc\Tests\Integration\MSFT_LMHost.Config.ps1
Set-PowerLinePrompt `
-SetCurrentDirectory `
-RestoreVirtualTerminal `
-PowerLineFont `
-FullColor `
-Title {
$title = "PowerShell {0} - {1} ({2}) - PID: {3}" -f $PSVersionTable.PSVersion.ToString(),(Convert-Path $pwd), $pwd.Provider.Name,$PID
if (Test-Elevation) {
"Elevated - $title"
} else {
$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'
param (
[string] $Name = 'GitHub'
)
'Hello World from {0}!' -f $Name
@bgelens
bgelens / test.sh
Last active March 20, 2018 14:06
test.sh
echo $1
cat /etc/os-release | grep -i pretty
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"osType": {
"type": "string",
"allowedValues": [
"linux",
"windows"
],
function Get-SoftwareUpdateConfigurations {
[CmdletBinding(DefaultParameterSetName = 'list')]
param (
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $ResourceGroupName,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $AutomationAccountName,
$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
@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
)
@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."
}
},