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
. .\lib.common\MethodHelpers.ps1
. .\lib.common\PowerObject.ps1
function Resolve-DNSHost {
[cmdletBinding()]
Param ()
DynamicParam {
Get-DynamicParamForMethod -method ([System.Net.Dns]::Resolve)
}
process {
try
. .\lib.common\MethodHelpers.ps1
. .\lib.common\PowerObject.ps1
function Get-Color{
[cmdletBinding()]
Param ()
DynamicParam {
[System.Drawing.Color]::FromName,[System.Drawing.Color]::FromKnownColor | Get-DynamicParamForMethod
}
process {
@gaelcolas
gaelcolas / NewVMwithDiffDisk.ps1
Created July 9, 2016 21:28
Create VM with differencing disks
New-VHD -Differencing -ParentPath .\BaseWMF5.vhd -Path .\BaseWMF5_diff.vhd
New-VM -Name TestBase -BootDevice IDE -VHDPath .\BaseWMF5_diff.vhd -SwitchName inet -Path .\hyperv\
Start-VM TestBase
@gaelcolas
gaelcolas / InstallPester.ps1
Created July 9, 2016 21:32
Install Pester with WMF5 and PackageManagement module
Install-PackageProvider -Name nuGet -Force -ForceBootstrap
Import-PackageProvider -Name nuGet -Force -ForceBootstrap
#Restart your PowerShell console / ISE.
Find-package Pester | install-package
@gaelcolas
gaelcolas / TestImageHasWMF5.ps1
Created July 9, 2016 21:34
Testing WMF5 is installed with Pester test
Describe 'Testing Image' {
It 'Should have WMF5' {
$PSVersionTable.PSVersion.Major -ge 5 | should be $true
}
}
@gaelcolas
gaelcolas / NewVMwDiffDiskAndIsoAttached.ps1
Created July 9, 2016 21:47
Create VM on Diff disk and attach unattendxml iso before starting
New-VHD -Differencing -ParentPath .\BaseWMF5.vhd -Path .\BaseWMF5_diff.vhd
New-VM -Name TestBase -BootDevice IDE -VHDPath .\BaseWMF5_diff.vhd -SwitchName inet -Path .\hyperv\
set-VMDvdDrive -VMName TestBase -Path .\Unattendxml.iso
Start-VM TestBase
@gaelcolas
gaelcolas / PatchWindowsImageDISMCmdlet.ps1
Created July 9, 2016 21:54
Patch and modify a Windows VHD Image with DISM Commandlets
Mount-WindowsImage -ImagePath .\baseNoWMF5.vhd -Path ./VHD -Index 1
Add-WindowsPackage -PackagePath .\Win8.1AndW2K12R2-KB3134758-x64.msu -Path .\VHD
Use-WindowsUnattend -UnattendPath C:\src\winopsconf\TestKitchen\Unattend.xml -Path .\VHD
Dismount-WindowsImage -Path .\VHD -Save
@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'
}