This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 12 days of christmas | |
$i=0;while($i-lt12){$f="On the $(("First;Second;Third;Fourth;Fifth;Sixth;Seventh;Eighth;Ninth;Tenth;Eleventh;Twelfth"-split";")[$i]) day of Christmas;My true love sent to me;A Partridge in a Pear Tree.;Two Turtle Doves;Three French Hens,;Four Calling Birds,;Five Gold Rings,;Six Geese-a-Laying,;Seven Swans-a-Swimming,;Eight Maids-a-Milking,;Nine Ladies Dancing,;Ten Lords-a-Leaping,;Eleven Pipers Piping,;Twelve Drummers Drumming,"-split";";$a=$f[0,1]+$f[$(2+$i)..2];$a[-2]=$i++ ?$a[-2]+', and':$a[-2];$a+''|write-host} | |
# fizzbuzz | |
1..100|%{($_%3?$^:'Fizz')+($_%5?$^:'Buzz')??$_}|write-host | |
# seven segment | |
$n=$args;1..3|%{$l=$_;$o="";$n.ToCharArray()|%{$o+=('{"1":{"1":" ","2":" |","3":" |"},"2":{"1":" _ ","2":" _|","3":"|_ "},"3":{"1":" _ ","2":" _|","3":" _|"},"4":{"1":" ","2":"|_|","3":" |"},"5":{"1":" _ ","2":"|_ ","3":" _|"},"6":{"1":" _ ","2":"|_ ","3":"|_|"},"7":{"1":" _ ","2":" |","3":" |"},"8":{"1":" _ ","2":"|_|","3":"|_|"},"9":{"1":" _ ","2":"|_|","3":" _|"},"0":{"1":" _ "," |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Describe 'Get-PodcastImage' { | |
BeforeAll { | |
. $PSScriptRoot\function-Get-PodcastImage.ps1 | |
$TestData = (Get-Content $PSScriptRoot\ObjectMother\RSSData.json -Raw | ConvertFrom-Json) | ForEach-Object { | |
@{ | |
Data = $_ | |
ImageURL = $_.ImageURL | |
Exist = [int][bool]($i++ % 2) # makes odd indexes return false for exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ProgressPreference = "SilentlyContinue" | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
# Enable WinRM | |
Enable-PSRemoting -Force -SkipNetworkProfileCheck | |
# Install PowerShell | |
if (-not (Invoke-DscResource -Name Package -ModuleName PSDesiredStateConfiguration -Method Test -Property @{ Ensure = "Present"; Path = "$env:temp\powershell.msi"; Name = "PowerShell 6-preview-x64"; ProductID = '' })) { | |
Write-Verbose "Installing latest version of PowerShell" -Verbose | |
$LatestRelease = irm https://api.github.com/repos/powershell/powershell/releases/latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import module from previous step | |
Import-Module -Name posh-git | |
function Test-Administrator { | |
$user = [Security.Principal.WindowsIdentity]::GetCurrent(); | |
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |
} | |
function prompt { | |
$realLASTEXITCODE = $LASTEXITCODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"files.trimTrailingWhitespace": true, | |
"powershell.codeFormatting.preset": "OTBS", | |
"powershell.codeFormatting.alignPropertyValuePairs": true, | |
"files.insertFinalNewline": true, | |
"files.trimFinalNewlines": true, | |
"editor.insertSpaces": true, | |
"editor.detectIndentation": false, | |
"editor.tabSize": 4, | |
"[json]": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertFrom-SQLDatabaseConnectionString { | |
[OutputType([PSCustomObject])] | |
[cmdletbinding()] | |
param( | |
[Parameter(mandatory, Valuefrompipeline)] | |
[string] | |
$ConnectionString | |
) | |
begin { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-PreviousWorkday ($Days = 0) { | |
begin { | |
$date = get-date | |
} | |
process { | |
$i = 0 | |
do { | |
$date = $date.adddays(-1) | |
if ($date.DayOfWeek -match '^[^s]') { | |
$i++ |