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'
function Test-NetPort {
[CmdletBinding()]
[OutputType([Boolean])]
param (
[Parameter(Mandatory,
ValueFromPipeline,
ValueFromPipelineByPropertyName)]
[String] $ComputerName,
[Parameter(Mandatory,
$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'
#region setup
$WorkingDir = $psISE.CurrentFile.FullPath | Split-Path
Set-Location $WorkingDir
Add-AzureRmAccount
$AAAcct = Get-AzureRmAutomationAccount -Name DSCDemo01 -ResourceGroupName DSCDemo01
#endregion
#region list local VMs
Get-VM | Where-Object -FilterScript {$_.State -eq 'Running'}
#endregion
{
"$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"
}
},
#region setup
$WorkingDir = $psISE.CurrentFile.FullPath | Split-Path
Set-Location $WorkingDir
#Add-AzureRmAccount
$AAAcct = Get-AzureRmAutomationAccount -Name DSCDemo01 -ResourceGroupName DSCDemo01
$Keys = $AAAcct | Get-AzureRmAutomationRegistrationInfo
$RG = Get-AzureRmResourceGroup -Name DSCNodes
$StorageAccountName = 'dscnodes4588'
$Location = 'westeurope'
#endregion
#region setup
$WorkingDir = $psISE.CurrentFile.FullPath | Split-Path
Set-Location $WorkingDir
#Add-AzureRmAccount
$AAAcct = Get-AzureRmAutomationAccount -Name DSCDemo01 -ResourceGroupName DSCDemo01
function Wait-AADSCCompileJob {
param (
[parameter(Mandatory,ValueFromPipeline)]
[Microsoft.Azure.Commands.Automation.Model.CompilationJob] $CompileJob,