Skip to content

Instantly share code, notes, and snippets.

View gaelcolas's full-sized avatar
🏠
Working from home

Gael gaelcolas

🏠
Working from home
View GitHub Profile
configuration MyConfig {
Param()
if($Node.Role -contains 'DHCPData' -and $Node.Customers -eq 'CustomerA') {
$Domain = $ConfigurationData.customerA.Domain
}
else {
$Domain = $ConfigurationData.DefaultDomain.Domain
}
File MyDomainFile {
Ensure = 'Present'
#Assuming you already have this hashtable
$MyHashes = @(
@{
Ensure = 'Present'
Name = 'Putty'
Version = 'Latest'
ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' }
},
@{
Ensure = 'Absent'
#Assuming you already have this hashtable
$MyHashes = @(
@{
Ensure = 'Present'
Name = 'Putty'
Version = 'Latest'
ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' }
},
@{
Ensure = 'Absent'
#Assuming you already have this hashtable
$MyHash = @{
Ensure = 'Present'
Name = 'Putty'
Version = 'Latest'
ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' }
}
Configuration MyDscConfig {
$Allnodes.nodename {
Configuration MyDscConfig {
$Allnodes.nodename {
ChocolateyPackage Putty {
Ensure = 'Present'
Name = 'Putty'
Version = 'Latest'
ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' }
}
}
}
function Get-DscSplattedResource {
[CmdletBinding()]
Param(
[String]
$ResourceName,
[String]
$ExecutionName,
[hashtable]
$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
$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) }
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 July 29, 2016 14:20
Q&D PowerShell Temperature Gauge for Surface Pro 3
$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 = @{