Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Gael gaelcolas

🏠
Working from home
View GitHub Profile
View PseudoSplattingDsc.ps1
#Assuming you already have this hashtable
$MyHashes = @(
@{
Ensure = 'Present'
Name = 'Putty'
Version = 'Latest'
ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' }
},
@{
Ensure = 'Absent'
View IteratingResources.ps1
#Assuming you already have this hashtable
$MyHashes = @(
@{
Ensure = 'Present'
Name = 'Putty'
Version = 'Latest'
ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' }
},
@{
Ensure = 'Absent'
View DSC+hashtable.ps1
#Assuming you already have this hashtable
$MyHash = @{
Ensure = 'Present'
Name = 'Putty'
Version = 'Latest'
ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' }
}
Configuration MyDscConfig {
$Allnodes.nodename {
View Dscconfig_ex1.ps1
Configuration MyDscConfig {
$Allnodes.nodename {
ChocolateyPackage Putty {
Ensure = 'Present'
Name = 'Putty'
Version = 'Latest'
ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' }
}
}
}
View Get-DscSplattedResource.ps1
function Get-DscSplattedResource {
[CmdletBinding()]
Param(
[String]
$ResourceName,
[String]
$ExecutionName,
[hashtable]
View SetupHyperVNatContainerAndVM.ps1
$containerPrefix = '10.111.110.0/24'
$sharedPrefix = '10.111.0.0/16'
$vmprefix = '10.111.111.0/24'
$vmPrefixLength = 24
$SharedGw = '10.111.111.1'
$vmNatSwitchName = 'NAT'
$null = Get-ContainerNetwork | Remove-ContainerNetwork -Force -ErrorAction SilentlyContinue
$null = Get-NetNat | Remove-NetNat -Confirm:$false -ErrorAction SilentlyContinue
$null = Get-VMSwitch -Name $vmNatSwitchName -ErrorAction SilentlyContinue | Remove-VMSwitch -Force -Confirm:$false -ErrorAction Stop
View selfCastingObject.ps1
$deserialized = [psobject][ordered]@{
'string' = 'this is a string'
'double' = [double]::MaxValue
'fileInfo' = 'C:\'
'__castme' = {
param($myself)
switch (($myself|Get-Member -MemberType NoteProperty).Name)
{
'string' {$myself.string = $myself.string }
'double' {$myself.double = [double]($myself.double) }
View TestGenerator.ps1
Function Export-StructuralUnitTestFromCommand {
param(
[parameter(Mandatory=$true,ValueFromPipelineByPropertyName = $true,ValueFromPipeline = $true)]
[System.Management.Automation.CommandInfo[]]
$command
)
begin {
$stringBuilder = New-object -TypeName System.Text.StringBuilder
$BuiltInParameters = ([Management.Automation.PSCmdlet]::CommonParameters + [Management.Automation.PSCmdlet]::OptionalCommonParameters)
}
@gaelcolas
gaelcolas / temperature_monitor.sp3.ps1
Last active Jul 29, 2016
Q&D PowerShell Temperature Gauge for Surface Pro 3
View temperature_monitor.sp3.ps1
$pshost = get-host
$pswindow = $pshost.ui.rawui
$newsize = $pswindow.windowsize
$newsize.height = 8
$newsize.width = 80
$pswindow.windowsize = $newsize
$pswindow.buffersize = $newsize
cls;while ($true){
$temp = gwmi MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"
$ProgressParams = @{
View DscClassResource.ps1
enum Ensure {
Absent
Present
}
[DscResource()]
Class Env_Refresh {
[DSCProperty(Mandatory)]
[Ensure] $Ensure