Standard escape codes are prefixed with Escape:
- Ctrl-Key:
^[ - Octal:
\033 - Unicode:
\u001b - Hexadecimal:
\x1B - Decimal:
27
| ## Different ways to Sort | |
| # ======================== | |
| # a) via Array class and the .Sort() method | |
| # b) via LINQ and the OrderBy() method | |
| # c) via the Sort-Object function | |
| # d) via Comparer class for | |
| # d1) List & SortedSet |
| <# | |
| Prerequisites: PowerShell v5.1 and above (verified; may also work in earlier versions) | |
| License: MIT | |
| Author: Michael Klement <[email protected]> | |
| DOWNLOAD and DEFINITION OF THE FUNCTION: | |
| irm https://gist.github.com/mklement0/7f2f1e13ac9c2afaf0a0906d08b392d1/raw/Debug-String.ps1 | iex |
| using module ActiveDirectory | |
| using namespace System.Reflection | |
| function Convert-ADFilter { | |
| <# | |
| .SYNOPSIS | |
| Converts PowerShell-style filters used by the AD module into LDAP filters. | |
| .DESCRIPTION | |
| Convert-ADFilter uses the QueryParser from the AD module to convert PowerShell-style filters into LDAP |
| using namespace System.Management.Automation | |
| function ThrowUser { | |
| <# | |
| .SYNOPSIS | |
| Throws a terminating exception record that shows the cmdlet as the source of the error, rather than the inner "throw". Makes for more user friendly errors than simply using "throw" | |
| .INPUTS | |
| [String] | |
| [Exception] | |
| [Object] | |
| .OUTPUTS |
| <# | |
| Prerequisites: PowerShell v5.1 and above (verified; may also work in earlier versions) | |
| License: MIT | |
| Author: Michael Klement <[email protected]> | |
| DOWNLOAD and DEFINITION OF THE FUNCTION: | |
| irm https://gist.github.com/mklement0/9e1f13978620b09ab2d15da5535d1b27/raw/Time-Command.ps1 | iex |
| function Set-WindowState { | |
| <# | |
| .SYNOPSIS | |
| Set the state of a window. | |
| .DESCRIPTION | |
| Set the state of a window using the `ShowWindowAsync` function from `user32.dll`. | |
| .PARAMETER InputObject | |
| The process object(s) to set the state of. Can be piped from `Get-Process`. |
| <# | |
| .Synopsis | |
| Creates an custom ErrorRecord that can be used to report a terminating or non-terminating error. | |
| .Description | |
| Creates an custom ErrorRecord that can be used to report a terminating or non-terminating error. | |
| .Parameter Exception | |
| The Exception that will be associated with the ErrorRecord. | |