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
| Remember, kids, the only difference | |
| between screwing around and science | |
| is writing it down. |
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
| install-Module psedit | |
| set-alias edit show-pseditor |
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
| <################################################################################## | |
| # | |
| # Script name: ternary.ps1 | |
| # source http://blogs.technet.com/b/heyscriptingguy/archive/2009/06/15/hey-scripting-guy-event-2-solutions-from-expert-commentators-beginner-and-advanced-the-long-jump.aspx | |
| # | |
| ##################################################################################> | |
| set-alias ?: Invoke-Ternary -Option AllScope -Description "PSCX filter alias" | |
| filter Invoke-Ternary ([scriptblock]$decider, [scriptblock]$ifTrue, [scriptblock]$ifFalse) { | |
| if (&$decider) { |
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
| <# | |
| The basics: A HashSet is a collection that holds unique elements in no particular order (O(1) complexity | |
| for adding, searching or removing). The HashSet<T> is a generic class in the System.Collections.Generic | |
| namespace, ideal for managing large data sets and performing set operations. | |
| Core aspects: The dotnet HashSet is a hash-based collection that allows only distinct elements. | |
| It supports various operations such as Union, Intersection, Difference, and more. | |
| More: https://www.bytehide.com/blog/hashset-csharp | |
| #> |
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
| # option 1 | |
| using namespace System.Collections.Specialized | |
| $ordered = new-object OrderedDictionary | |
| # option 2 | |
| $ordered = new-object System.Collections.Specialized.OrderedDictionary | |
| # members | |
| $ordered | get-member |
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 mandatoryUserBoolParam { | |
| param( | |
| [Parameter(Mandatory=$true)] | |
| [ValidateSet("true","false","1","0","yes","no","y","n")] | |
| [string]$param | |
| ) | |
| $boolParam = $false | |
| switch ($param.ToLower()) { | |
| "true" { $boolParam = $true } |
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
| { | |
| "background": "#F9F9F9", | |
| "black": "#AB3D2C", | |
| "blue": "#275FE4", | |
| "brightBlack": "#C21458", | |
| "brightBlue": "#0099E1", | |
| "brightCyan": "#7B86BB", | |
| "brightGreen": "#3D942E", | |
| "brightPurple": "#CE33C0", | |
| "brightRed": "#FF0308", |
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
| filter ThrowStdOutErrors($messageFilter,[Parameter(ValueFromPipeline)]$obj) { | |
| if ($obj -is [Management.Automation.ErrorRecord]) { | |
| if ($obj -match $messageFilter) { | |
| throw $obj | |
| } else { | |
| Write-Error $obj | |
| return | |
| } | |
| } | |
| $obj |
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
| $PSDefaultParameterValues["Get-AzADUser:Select"] = @("DisplayName", "Id", "UserPrincipalName", "UserType", "AccountEnabled") |
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
| using namespace System.Management.Automation | |
| using namespace Microsoft.PowerShell.Commands | |
| function Write-FunctionError { | |
| <# | |
| .SYNOPSIS | |
| Writes an error within the context of the containing CmdletBinding() function. Makes error displays prettier | |
| .NOTES | |
| ScriptStackTrace will still show Write-FunctionError, so its not completely transparent. There's no way to "edit" or "replace" this stacktrace that I can find. | |
| .EXAMPLE | |
| function test { |
NewerOlder