Tools for a better console experience
- Ninmonkey.Console
- Useful Commands
- Custom Verbs
- Frequently used
- Console Encoding
- AppxPackages : Windows Apps
- Types
- See More
Name | Description |
---|---|
Hex |
ConvertTo-HexString |
Bits |
ConvertTo-BitString |
Base64 |
. |
Get-EnumInfo |
. |
Out-Fzf |
. |
Out-Code |
. |
Goto |
cd to directory, works on non-directories |
Here |
Open filemanager |
π> Get-ChildItem $Env:APPDATA -Directory | Out-Fzf | Format-RelativePath $Env:APPDATA
.\Code
.\Code - Insiders
π> $Fzf
C:\Users\monkey\AppData\Roaming\Code
C:\Users\monkey\AppData\Roaming\Code - Insiders
# $Fzf was set because it defaults to:
$PSDefaultParameterValues['Out-Fzf:OutVariable'] = 'Fzf'
Name | Description |
---|---|
Label |
Colored Label: Value pairs |
H1 |
Heading text |
Br |
Add newlines |
Hr |
Horizontal Rule with padding |
π> $numbers = 0, 127, 0xffef
>> $numbers | Hex
0x0
0x7f
0xffef
π> $numbers | Bits
0000.0000
0111.1111
1111.1111 1110.1111
π> '0x34' | Number # returned type [Int32]
π> $bytes | Base64
Name | Description |
---|---|
Ensure-> |
ensure condition is true, else make it so, like: Ensure-FileExists , Ensure-CurrentDirIs , etc.The intent is non-fatal asserts on a state, which are silently resolved -- if needed |
Resolve-> |
ConvertType to another type -- if needed. Like: Resolve-TypeInfo , ..Resolve->FileInfo attempts to return a Get-Item . If it fails, return the original string, instead of errors or nothing. Resolve-> Is similar to Ensure-> , the difference is Resolve-> returns objects . Ensure is about a valid state. |
To-> and From-> |
Sugar for ConvertTo-Type and ConvertFrom-Type / load from |
Fmt-> |
Custom Formatting of objects and strings depending on the command Built to chain off of one another, unlike Format-* functions |
# Jump to modules
π> Get-Module PSKoans | Goto
pwd
C:\Users\monkey\Documents\PowerShell\Modules\PSKoans\0.67.1
π> Get-ConsoleEncoding
Name Encoding CodePage isSingleByte
---- -------- -------- ------------
OutputEncoding Unicode (UTF-8) 65001 False
[console]::InputEncoding Unicode (UTF-8) 65001 False
[console]::OutputEncoding Unicode (UTF-8) 65001 False
Package names are not always descriptive. Sometimes nothing in the fields Name
, PackageName
or FamilyName
are useful.
This example has the package name Dayton
even though the game is named State of Decay 2
π> Get-AppXPackage *state*decay*
# nothing found
π> $results = Get-NinAppXPackage 'state.*decay' -PassThru
π> $results | Format-List
Regex : state.*decay
App : Microsoft.Dayton_2.408.280.0_x64__8wekyb3d8bbwe
ExeList : {C:\Program Files\WindowsApps\Microsoft.Dayton_2.408.280.0_x64__8wekyb3d8bbwe\StateOfDecay2.exe, C:\Program Files\WindowsApps\Microsoft.Dayton_2.408.280.0_x64__8wekyb3d8bbwe\StateOfDecay2\Binaries\Win64\StateOfDecay2-Win64-Shipping.exe}
π> Get-NinAppXPackage 'state.*decay'
Name : Microsoft.Dayton
Publisher : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture : X64
ResourceId :
Version : 2.408.280.0
PackageFullName : Microsoft.Dayton_2.408.280.0_x64__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.Dayton_2.408.280.0_x64__8wekyb3d8bbwe
IsFramework : False
PackageFamilyName : Microsoft.Dayton_8wekyb3d8bbwe
PublisherId : 8wekyb3d8bbwe
IsResourcePackage : False
IsBundle : False
IsDevelopmentMode : False
NonRemovable : False
Dependencies : {Microsoft.VCLibs.140.00.UWPDesktop_14.0.29231.0_x64__8wekyb3d8bbwe}
IsPartiallyStaged : False
SignatureKind : Store
Status : Ok
Regex : state.*decay
App : Microsoft.Dayton_2.408.280.0_x64__8wekyb3d8bbwe
ExeList : {C:\Program Files\WindowsApps\Microsoft.Dayton_2.408.280.0_x64__8wekyb3d8bbwe\StateOfDecay2.exe, C:\Program Files\WindowsApps\Microsoft.Dayton_2.408.280.0_x64__8wekyb3d8bbwe\StateOfDecay2\Binaries\Win64\StateOfDecay2-Win64-Shipping.exe}
Regex App
----- ---
state.*decay Microsoft.Dayton_2.408.280.0_x64__8wekyb3d8bbwe
π> ls . | foreach-object{ $_.pstypenames } | sort -Unique
System.IO.DirectoryInfo
System.IO.FileInfo
System.IO.FileSystemInfo
System.MarshalByRefObject
System.Object
π> ls . | foreach-object{ $_.pstypenames } | sort -Unique | Format-TypeName
[IO.DirectoryInfo]
[IO.FileInfo]
[IO.FileSystemInfo]
[MarshalByRefObject]
[Object]
π> $items = [list[string]]::new()
$items.GetType().FullName
System.Collections.Generic.List`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
π> $items.GetType() | Format-TypeName
List`1[[String]]
π> 10, '', " ", $null, "`u{0}" | Test-NullArg | Format-Table
Value Type IsNull IsNullOrWhiteSpace IsNullOrEmpty AsString ToString CastString TestId IsNullCodepoint
----- ---- ------ ------------------ ------------- -------- -------- ---------- ------ ---------------
10 Int32 False False False '10' '10' '10' 0 False
String False True True '' '' '' 1 True
String False True False ' ' ' ' ' ' 2 False
β [Null] True True True '' 'β' '' 3 False
β String False False False 'β' 'β' 'β' 4 True
- ClassExplorer by SeeminglyScience/ClassExplorer
- Creating Dynamic Sets for ValidateSet
- Working With Argument Transformations in PowerShell
- Working with PowerShell's -replace Operator
- ScriptBlocks and GetNewClosure()
- Searching the PowerShell Abstract Syntax Tree
- Implementing-ShouldProcess
- [Invoke a PowerShell Module Command in the Global Scope](Invoke a PowerShell Module Command in the Global Scope)
-
& (Get-Module 'Pester') { Get-Command -Module Pester }
-