This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 localizeddata | |
| if (Test-Path "${PSScriptRoot}\${PSUICulture}") | |
| { | |
| Import-LocalizedData ` | |
| -BindingVariable LocalizedData ` | |
| -Filename MSFT_LMHost.psd1 ` | |
| -BaseDirectory "${PSScriptRoot}\${PSUICulture}" | |
| } | |
| else | |
| { |
This file contains hidden or 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
| New-xDscResource -ModuleName NetworkingDsc -Name MSFT_LMHost -FriendlyName LMHost -ClassVersion 1.0.0.0 -Path ..\Demo -Property @( | |
| New-xDscResourceProperty -Name IsSingleInstance -Attribute Key -Type String -ValidateSet 'Yes' -Description "This is a system wide setting and can only be applied once" | |
| New-xDscResourceProperty -Name Enable -Type Boolean -Attribute Required -Description "This will Enable or Disable LMHost lookup" | |
| ) |
This file contains hidden or 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
| // Place your settings in this file to overwrite the default settings | |
| { | |
| "terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe", | |
| "editor.renderWhitespace": "boundary", | |
| "workbench.activityBar.visible": true, | |
| "window.zoomLevel": 3, | |
| "terminal.integrated.fontFamily": "monofur for Powerline", | |
| "editor.tabSize": 4, | |
| "editor.detectIndentation": false, | |
| "files.associations": { |
This file contains hidden or 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
| # first test | |
| Describe 'MSFT_LMHost\Test-TargetResource' { | |
| Context 'Invoking with LMHost currently enabled' { | |
| Mock -CommandName 'Test-LMHostEnabled' -MockWith {return $true} | |
| It 'Should return "true" when Enable is set to "true" and current state is "true"' { | |
| Test-TargetResource -IsSingleInstance 'Yes' -Enable $true | Should Be $true | |
| } | |
| It 'Should return "false" when Enable is set to "false" and current state is "true"' { | |
| Test-TargetResource -IsSingleInstance 'Yes' -Enable $false | Should Be $false |