Skip to content

Instantly share code, notes, and snippets.

View bgelens's full-sized avatar

Ben Gelens bgelens

View GitHub Profile
configuration SQL
{
Import-DscResource -ModuleName xSQLServer,xDisk
node sql01
{
xWaitForDisk SMAInstallDisk
{
DiskNumber = 2
RetryIntervalSec = 60
RetryCount = 60
@bgelens
bgelens / DSCClassResourceTemplate.psm1
Last active August 29, 2015 14:18
DSC Class Resource Template.
enum Ensure
{
Absent
Present
}
enum List
{
First = 1
Second = 2
@bgelens
bgelens / gist:eaf45d229876279e9da8
Last active August 29, 2015 14:21
SMA Killing lingering sessions
#ChildRunbook to stop lingering sessions which is called inline
workflow Stop-LingeringSession {
param (
[Parameter(Mandatory)]
[Int] $ProcessId,
[Parameter(Mandatory)]
[String] $Server,
[Parameter(Mandatory)]
function Get-CorpSysInfo {
[cmdletbinding()]
param (
[Parameter(ValueFromPipeline,
ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[String[]] $ComputerName = $env:COMPUTERNAME,
[ValidateSet('dcom','Wsman')]
[String] $Protocol = 'Wsman'
$adal = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
$adalforms = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"
[System.Reflection.Assembly]::LoadFrom($adal)
[System.Reflection.Assembly]::LoadFrom($adalforms)
$adTenant = 'bla.onmicrosoft.com'
$subscriptionid = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
$jobname = 'MyJob'
$collection = 'MyCollection'
$location = 'westeurope'
$clientId = '1950a258-227b-4e31-a9cf-717495945fc2'
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"metadata": {
"description": "Name of the existing VM to onboard into Azure Automation DSC"
}
},
@bgelens
bgelens / Get-OsInfo.ps1
Created September 28, 2016 18:31
Parse os-release into object
function Get-OSInfo {
[cmdletbinding(DefaultParameterSetName='Brief')]
param (
[Parameter(ParameterSetName='Full')]
[Switch] $Full
)
process {
$osInfoFull = (Get-Content -Path /etc/os-release).Replace('"','') | ConvertFrom-StringData
if ($PSCmdlet.ParameterSetName -eq 'Brief') {
$osInfoFull.PRETTY_NAME
#requires -Version 3
function Get-PowerPlan {
<#
.SYNOPSIS
Display PowerPlans on requested machines.
.DESCRIPTION
Display PowerPlans on requested machines using CIM.
.PARAMETER ComputerName
ComputerNames to query for PowerPlans.
Default value is the local computername through $env:COMPUTERNAME
function Test-ClassResource
{
param(
[Parameter(ValueFromPipeline=$True,Mandatory=$True)]
[string]$fileName
)
$ast = [System.Management.Automation.Language.Parser]::ParseFile($fileName, [ref]$null, [ref]$null)
$result = foreach ($item in $ast.FindAll({$args[0] -is [System.Management.Automation.Language.AttributeAst]}, $false))
{
Install-Module -Name xPSDesiredStateConfiguration -Force
[DscLocalConfigurationManager()]
configuration LCM {
Settings {
RebootNodeIfNeeded = $true
ActionAfterReboot = 'ContinueConfiguration'
}
}