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
@gaelcolas
gaelcolas / CaptureWimfromVHD.ps1
Created July 9, 2016 21:58
Capture WIM from VHD
Mount-WindowsImage -ImagePath .\baseNoWMF5.vhd -Path ./VHD -Index 1
New-WindowsImage -ImagePath .\customImage.wim -CapturePath .\VHD\ -Name customImage
Dismount-WindowsImage -Path .\VHD -Discard
@gaelcolas
gaelcolas / sampleTest.ps1
Last active July 11, 2016 14:41
Pester sample test
Describe 'checking File Exists' {
it 'Should resolve to C:\WinOps.txt' {
{ Resolve-Path C:\WinOps.txt -ErrorAction Stop } | should not Throw
}
}
Configuration Default {
Import-DSCResource -ModuleName Env_Refresh
Node 'localhost' {
Env_Refresh TESTVAR
{
Ensure = 'Present'
RunName = 'RMQ_BASE_VAR'
VariableNameList = 'RABBITMQ_BASE'
}
enum Ensure {
Absent
Present
}
[DscResource()]
Class Env_Refresh {
[DSCProperty(Mandatory)]
[Ensure] $Ensure
@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 = @{
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)
}
$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) }
$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
function Get-DscSplattedResource {
[CmdletBinding()]
Param(
[String]
$ResourceName,
[String]
$ExecutionName,
[hashtable]
Configuration MyDscConfig {
$Allnodes.nodename {
ChocolateyPackage Putty {
Ensure = 'Present'
Name = 'Putty'
Version = 'Latest'
ChocolateyOptions = @{ source = 'https://chocolatey.org/api/v2/' }
}
}
}