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
for ($i=-1;$i -lt 2; $i++) { | |
try { | |
"`nTry $i" | |
1/$i | out-null | |
} catch { | |
"Catch $i" | |
continue | |
} finally { | |
"Finally $i" |
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
# PSReadLine tips from https://opensource.com/article/18/7/powershell-tips | |
Set-PSReadlineOption -EditMode Emacs | |
Set-PSReadlineOption -BellStyle None | |
# https://learn-powershell.net/2012/08/07/make-your-powershell-errors-less-harsh-by-changing-their-color/ | |
$host.PrivateData.VerboseForegroundColor = 'DarkGreen' | |
# Work around an RS5/PSReadline-2.0.0+beta2 bug (Spacebar is not marked 'essential') | |
Set-PSReadlineKeyHandler "Shift+SpaceBar" -ScriptBlock { |
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
# original gist by Jakub | |
Describe "a" { | |
$Sources = @( | |
[PSCustomObject]@{ | |
Advanced = @{ | |
Enabled = $true | |
} | |
} | |
[PSCustomObject]@{ |
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
if ($Prefix.Length -gt 2) { | |
Write-Output 'Welcome' | |
} else { | |
throw '$Prefix missing' | |
} | |
Write-Output 'Groups overview' | |
$Groups = Get-AzADGroup -DisplayNameStartsWith $Prefix | ? DisplayName -like *Access | |
$Groups | Format-Table | |
$Groups | % {Write-Output "$($_.DisplayName) members count: $((Get-AzADGroupMember -ObjectId $_.Id).Count)"} |
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 fa { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory,ValueFromPipeline)] | |
[int]$x | |
) | |
# function 1 | |
BEGIN {Write-Verbose "Begin a: $x"} |