This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# completed example | |
<# | |
.SYNOPSIS | |
Template for creating DSC Resource Unit Tests | |
.DESCRIPTION | |
To Use: | |
1. Copy to \Tests\Unit\ folder and rename <ResourceName>.tests.ps1 (e.g. MSFT_xFirewall.tests.ps1) | |
2. Customize TODO sections. | |
3. Delete all template comments (TODOs, etc.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-TargetResource | |
{ | |
[CmdletBinding()] | |
[OutputType([System.Collections.Hashtable])] | |
param | |
( | |
[parameter(Mandatory = $true)] | |
[ValidateSet("Yes")] | |
[System.String] | |
$IsSingleInstance, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install-Module -Name xPSDesiredStateConfiguration -Force | |
[DscLocalConfigurationManager()] | |
configuration LCM { | |
Settings { | |
RebootNodeIfNeeded = $true | |
ActionAfterReboot = 'ContinueConfiguration' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$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" | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |