Skip to content

Instantly share code, notes, and snippets.

function IsEvenNumber($number) {
return $number % 2 -eq 0
}
public class Tests
{
[Fact]
public void IsEvenNumber_WhenGivenAnEvenNumber_ItReturnsTrue()
{
var gna = new Gnabber();
Assert.True(gna.IsEvenNumber(42));
}
[Fact]
public class Gnabber
{
public bool IsEvenNumber(int number)
{
return number % 2 == 0;
}
}
$LinksCopy = Import-Clixml $Filename
$powerShellObject = Invoke-WebRequest "https://mallibone.com"
$Filename = ((Get-Date -format "yyyyMMMdd_HHmm") + "_mallibone_dump.xml")
$powerShellObject.Links | Export-Clixml $Filename
"Looks like I'll be the string ending up in a file..." >> "SomeFile.txt"
"What are you complaining about I'll be remembered as the second line..." >> "SomeFile.txt"
function DefaultValues
{
Param(
[Parameter(Position = 0)][string]$Message = "Hello from the standard parameters",
[Parameter(Position = 1)][string]$SecondMessage = "",
[Parameter(Position = 2)][bool]$PrintItYellow = $false
)
if($PrintItYellow)
{
.\MultipleParameter.ps1 -Message "Hello" -SecondMessage "Dear Reader" -PrintItYellow $true
Param(
[string]$Message,
[string]$SecondMessage,
[bool]$PrintItYellow
)
if($PrintItYellow)
{
Write-Host "$Message $SecondMessage" -ForegroundColor "Yellow"
}
function MultipleParameters
{
Param(
[Parameter(Position = 0)][string]$Message,
[Parameter(Position = 1)][string]$SecondMessage,
[Parameter(Position = 2)][bool]$PrintItYellow
)
if($PrintItYellow)
{