This file contains hidden or 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
| cls;$d=((" "*3),'Black'),(("█"*40),'Black'),(("█"*40),'Yellow'),(("█"*40),'Red'); 1..40 | % { $d | % { Write-Host $_[0] -ForegroundColor $_[1] -NoNewLine -BackgroundColor Blue }; write-host; sleep -Milliseconds 10 } |
This file contains hidden or 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
| # Substitute variables late. Define the template before the variables are in context. | |
| # See also: https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-string-substitutions?view=powershell-7.3 | |
| $message = 'Hello, $Name!' | |
| $name = 'Kevin Marquette' | |
| $string = $ExecutionContext.InvokeCommand.ExpandString($message) | |
This file contains hidden or 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
| <# | |
| A simple way to create a busy-spinner in Powershell. | |
| #> | |
| $global:animation = @{ Chars = "-\|/"; Ix = 0; Counter = 0 } | |
| # Animate one step every 500 calls. Lower the number for a faster animation. | |
| function Animate() { | |
| $a = $global:animation |
This file contains hidden or 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 Do-Check ($message, $function) | |
| { | |
| write-host "[ ] $message" -nonewline | |
| $result = Invoke-Command $function | |
| if ($result) | |
| { | |
| $resultMsg = "[ OK ]" | |
| $color = "green" | |
| } |
This file contains hidden or 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
| document.querySelectorAll('.sd-content a').forEach(function (i) { i.addEventListener("click", function(){ _paq.push(['trackEvent', 'Share button', 'Click', i.title]); }) }); |
This file contains hidden or 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
| # Make a test file | |
| "0" | set-content testfile.txt | |
| 1..100 | % { $_ | add-content testfile.txt } | |
| $l = get-content testfile.txt | |
| # ***** Regular implemenation ***** |
This file contains hidden or 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
| 1..20 | % { write-host ("#"*$_ + "|" * (20-$_) + "`r") -nonewline ; sleep -Milliseconds 200 } ; "" |
This file contains hidden or 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
| id | name | |
|---|---|---|
| 1 | joe | |
| 2 | bill | |
| 3 | jane |
This file contains hidden or 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 Write-Colors ($data) | |
| { | |
| foreach ($token in $data) | |
| { | |
| if ($token -is [array]) | |
| { | |
| if ($token.Length -eq 2) | |
| { | |
| Write-Host $token[0] -Foregroundcolor $token[1] -NoNewLine | |
| } |
This file contains hidden or 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
| $d = ls obj,bin -r -directory; $d | % { "Removing $_" ; remove-item $_ -Recurse } |
NewerOlder