| Loop | Return | Continue | Break |
|---|---|---|---|
| Normal Expectation | Exit Scope | Next Item | Exit Loop |
| .foreach{} | Next Item | Break Scopes / Next Item of Parent Loop | Break Scopes / Exit Parent Loop |
| foreach ($y in $x) | Exit Scope | Next Item | Exit Loop |
| for ($i;$i -lt 5;$i++) | Exit Scope | Next Item | Exit Loop |
| Foreach-Object -InputObject @() | Next Item | Break Scopes / Next Item of Parent Loop | Break Scopes / Exit Parent Loop |
| Switch | Exit Scope | Next Item | Exit Switch |
| While |
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 | |
| # Use of StopUpstreamCommandsException is obviously not supported. Subject to breaking at any time. | |
| function Select-FirstObject { | |
| [Alias('first', 'top')] | |
| [CmdletBinding(PositionalBinding = $false)] | |
| param( | |
| [Parameter(ValueFromPipeline)] | |
| [psobject] $InputObject, |
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
| class MagicNumber | |
| { | |
| hidden [int] $_value | |
| MagicNumber([int]$value) | |
| { | |
| $this._value = $value | |
| } | |
| # ECMA-335 I.10.3.2 |
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
| # Copyright: (c) 2021, Jordan Borean (@jborean93) <jborean93@gmail.com> | |
| # MIT License (see LICENSE or https://opensource.org/licenses/MIT) | |
| Function Get-ServiceCertStore { | |
| <# | |
| .SYNOPSIS | |
| Open an X509 store to a service account. | |
| .DESCRIPTION | |
| Opens an X509 store to the NT SERVICE account specified. The X509 store can be used to then add/remove/enumerate |
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
| # Copyright: (c) 2021, Jordan Borean (@jborean93) <jborean93@gmail.com> | |
| # MIT License (see LICENSE or https://opensource.org/licenses/MIT) | |
| class EncodingTransformAttribute : Management.Automation.ArgumentTransformationAttribute { | |
| [object] Transform([Management.Automation.EngineIntrinsics]$engineIntrinsics, [object]$InputData) { | |
| $outputData = switch ($InputData) { | |
| { $_ -is [Text.Encoding] } { $_ } | |
| { $_ -is [string] } { | |
| switch ($_) { |
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
| # Copyright: (c) 2021, Jordan Borean (@jborean93) <jborean93@gmail.com> | |
| # MIT License (see LICENSE or https://opensource.org/licenses/MIT) | |
| using namespace System.Management.Automation | |
| using namespace System.Management.Automation.Host | |
| using namespace System.Runtime.InteropServices | |
| $typeParams = @{ | |
| TypeDefinition = @' | |
| using Microsoft.Win32.SafeHandles; |
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 | |
| using namespace System.Linq | |
| using namespace System.Collections | |
| using namespace System.Collections.Generic | |
| using namespace System.Management.Automation | |
| using namespace System.Management.Automation.Language | |
| using namespace System.Reflection | |
| # Hey person reading this! Don't do this, alright? You'll have a bad time. ty |
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
| # Copyright: (c) 2022, Jordan Borean (@jborean93) <jborean93@gmail.com> | |
| # MIT License (see LICENSE or https://opensource.org/licenses/MIT) | |
| Function Get-WTSSessionInfo { | |
| <# | |
| .SYNOPSIS | |
| Enumerates sessions on a Windows host. | |
| .DESCRIPTION | |
| Enumerates all the sessions available on a Windows host through the WTSEnumerateSessionsExW API. |
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
| <Configuration> | |
| <ViewDefinitions> | |
| <View> | |
| <Name>Utility.PullRequest</Name> | |
| <ViewSelectedBy> | |
| <TypeName>Utility.PullRequest</TypeName> | |
| </ViewSelectedBy> | |
| <CustomControl> | |
| <CustomEntries> | |
| <CustomEntry> |