{"id":22574409,"url":"https://github.com/kirkmunro/typepx","last_synced_at":"2026-02-27T07:32:18.573Z","repository":{"id":21346698,"uuid":"24663736","full_name":"KirkMunro/TypePx","owner":"KirkMunro","description":"PowerShell Type Extensions and Accelerators","archived":false,"fork":false,"pushed_at":"2016-03-28T20:50:32.000Z","size":546,"stargazers_count":49,"open_issues_count":2,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-10T16:31:22.538Z","etag":null,"topics":["module","powershell","powershell-modules"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KirkMunro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-01T02:50:48.000Z","updated_at":"2025-03-12T02:53:12.000Z","dependencies_parsed_at":"2022-08-21T00:10:45.907Z","dependency_job_id":null,"html_url":"https://github.com/KirkMunro/TypePx","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/KirkMunro/TypePx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KirkMunro%2FTypePx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KirkMunro%2FTypePx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KirkMunro%2FTypePx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KirkMunro%2FTypePx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KirkMunro","download_url":"https://codeload.github.com/KirkMunro/TypePx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KirkMunro%2FTypePx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29887535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T05:38:26.446Z","status":"ssl_error","status_checked_at":"2026-02-27T05:38:25.235Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["module","powershell","powershell-modules"],"created_at":"2024-12-08T03:05:52.549Z","updated_at":"2026-02-27T07:32:18.559Z","avatar_url":"https://github.com/KirkMunro.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿## TypePx\n\n### Overview\n\nThe TypePx module adds properties and methods to the most commonly used types\nto make common tasks easier. Using these type extensions together can provide\nan enhanced syntax in PowerShell that is both easier to read and self-\ndocumenting. TypePx also provides commands to manage type accelerators. Type\nacceleration also contributes to making scripting easier and they help produce\nmore readable scripts, particularly when using a library of .NET classes that\nbelong to the same namespace.\n\n### Minimum requirements\n\n- PowerShell 3.0\n- SnippetPx module\n\n### License and Copyright\n\nCopyright 2016 Kirk Munro\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n### Installing the TypePx module\n\nNote that TypePx used to be called TypeAccelerator. Both modules share several\ncommands and have the same GUID. If you have the TypeAccelerator module installed,\nyou should manually remove that module before you download and install TypePx.\n\nTypePx is dependent on the SnippetPx module. You can download and install the\nlatest versions of TypePx and SnippetPx using any of the following methods:\n\n#### PowerShellGet\n\nIf you don't know what PowerShellGet is, it's the way of the future for PowerShell\npackage management. If you're curious to find out more, you should read this:\n\u003ca href=\"http://blogs.msdn.com/b/mvpawardprogram/archive/2014/10/06/package-management-for-powershell-modules-with-powershellget.aspx\" target=\"_blank\"\u003ePackage Management for PowerShell Modules with PowerShellGet\u003c/a\u003e\n\nNote that these commands require that you have the PowerShellGet module installed\non the system where they are invoked.\n\n```powershell\n# If you don’t have TypePx installed already and you want to install it for all\n# all users (recommended, requires elevation)\nInstall-Module TypePx,SnippetPx\n\n# If you don't have TypePx installed already and you want to install it for the\n# current user only\nInstall-Module TypePx,SnippetPx -Scope CurrentUser\n\n# If you have TypePx installed and you want to update it\nUpdate-Module\n```\n\n#### PowerShell 3.0 or Later\n\nTo install from PowerShell 3.0 or later, open a native PowerShell console (not ISE,\nunless you want it to take longer), and invoke one of the following commands:\n\n```powershell\n# If you want to install TypePx for all users or update a version already installed\n# (recommended, requires elevation for new install for all users)\n\u0026 ([scriptblock]::Create((iwr -uri http://bit.ly/Install-ModuleFromGitHub).Content)) -ModuleName TypePx,SnippetPx\n\n# If you want to install TypePx for the current user\n\u0026 ([scriptblock]::Create((iwr -uri http://bit.ly/Install-ModuleFromGitHub).Content)) -ModuleName TypePx,SnippetPx -Scope CurrentUser\n```\n\n### Loading the TypePx module\n\nWhen it comes to module auto-loading, type extensions do not function the\nsame way that commands do in PowerShell. As a result, if you want to use one\nof the type extensions that the TypePx module creates, you have two choices:\n\n1. If you are working inside of another module, add a dependency to the\nTypePx module in the module you are working on.\n\n2. Manually load TypePx by invoking the following command:\n\n```powershell\nImport-Module TypePx\n```\n\nIf you use these extensions on a regular basis, you can add that to your\nprofile script.\n\nIf, on the other hand, you are working with type accelerators, simply\ninvoking one of the *-TypeAccelerator commands will cause the module to\nload automatically using auto-loading and then the command will invoke\nproperly.\n\n### Using the TypePx module\n\nTo see a list of Type Accelerator commands that are available, invoke the\nfollowing command:\n\n```powershell\nGet-Command -Module TypePx\n```\n\nThis will return a list of the commands that are included in the TypePx\nmodule. In this release, there are 5 commands, each with an associated\nalias, as follows:\n\nAdd-TypeAccelerator, with alias atx\nGet-TypeAccelerator, with alias gtx\nRemove-TypeAccelerator, with alias rtx\nSet-TypeAccelerator, with alias stx\nUse-Namespace, with alias use\n\nAll commands are fully documented with examples, so you can get detailed\nhelp information for any of these commands by invoking something like\nthe following:\n\n```powershell\nGet-Help Use-Namespace -Full | more\n```\n\nThe type acceleration commands will make it much easier for you to use\n.NET types inside of your PowerShell scripts.\n\nThe type extensions that come with the TypePx module are not discoverable\nvia a simple command call at the moment, however the TypePx module is\nopen source and you can see all type extensions that it includes by\nreviewing the files in the typedata folder within the TypePx module.\n\nTo give you a few examples of some of the type extensions that are\nincluded in the TypePx module, any of the following commands will work\nanywhere in PowerShell once TypePx is loaded:\n\n```powershell\n#################\n# Fun with arrays\n#################\n# Show a string representation of an array that respects $FormatEnumerationLimit\n$a = 1..10\n$a.ToString()\n# Compact (remove null values) from an array\n$a = 1,$null,2,$null,3\n$a.Count\n$a.Compact().Count\n# Return unique elements in an array\n$a = 1,1,2,3,3,4,4,5,6\n$a.Unique()\n# Reverse an array\n$a = 1,2,3,4\n$a.Reverse()\n# Flatten a multi-dimensional array\n$a = (1,2),(3,4),(5,6)\n$a.Flatten()\n# Slice an array into chunks\n$a = 1,2,3,4,5,6\n$a.Slice(3)[1]\n##################\n# Fun with numbers\n##################\n# Get a timespan in a human readable way\n$x = 30\n$x.Years\n$x.Months\n$x.Weeks\n$x.Days\n$x.Hours\n$x.Minutes\n$x.Seconds\n$x.Milliseconds\n(1).Year\n(1).Month\n(1).Week\n(1).Day\n(1).Hour\n(1).Minute\n(1).Second\n(1).Millisecond\n# Calculate relative dates\n(30).Days.Ago\n(7).Days.FromNow\n(1).Week.Ago.InUtc\n# Use relative dates in practice\nGet-EventLog -LogName System -After (2).Days.Ago\n# Perform a task a specific number of times\n$x = 10\n# Note that in PowerShell 4 or later, the brackets are not necessary\n$x.Times({'Hello'})\n######################\n# Fun with collections\n######################\n# Compare collections against collections\n$names = gsv | Select-Object -ExpandProperty Name\n$names.MatchAny('^b','^u')\n$names.LikeAny('b*','u*')\n$names.ContainsAny('wuauserv','bits')\n$names.ContainsAny('notaservicename','notaservicenameeither')\n# Calculate the sum of a collection\n$a = 1,2,3,4\n$a.Sum()\n(gps).Sum('WorkingSet64')\n# Add an item to a hashtable as a collection\n$ht = @{}\n$ht.Add('A','This is not a collection')\n$ht.AddArrayItem('B','This is a collection')\n$ht.AddArrayItem('B','This adds to the collection')\n$ht\n# Note that PowerShell 4+ include foreach and where \"magic\" methods. This module\n# adds them to PowerShell 3\n# Perform some task on each object in a collection (brackets not necessary in PSv4+)\n(gsv w*).foreach({'Name = ' + $_.Name + '; DisplayName = ' + $_.DisplayName})\n# Expand a property in a collection\n(gsv).foreach('Name')\n# Convert every object in a collection to another type\n(gps).foreach([string])\n# Set property values on all objects in a collection\n$s = Get-Service\n$s.foreach('Name','Hello')\n$s\n# Invoke a method on all objects in a collection\n$s = @(gsv wuauserv)\n$s.foreach('Start')\n# Invoke a method on all objects in a collection, with parameters\n$a = (1,2),(3,4),(5,6)\n$a.foreach('Get',1)\n# Filter a collection (again, brackets are not necessary here in PSv4+)\n$s = gsv c*\n$s.where({$_.Status -eq 'Running'})\n# Get the first item matching a filter\n$s.where({$_.Status -eq 'Running'},'First')\n# Get the first N items matching a filter\n$s.where({$_.Status -eq 'Running'},'First',2)\n# Get the last item matching a filter\n$s.where({$_.Status -eq 'Running'},'Last')\n# Get the last N items matching a filter\n$s.where({$_.Status -eq 'Running'},'Last',2)\n# Skip items in a collection until a filter matches, then return all objects\n$s.where({$_.Status -eq 'Running'},'SkipUntil')\n# Skip items in a collection until a filter matches, then return the first N items\n$s.where({$_.Status -eq 'Running'},'SkipUntil',2)\n# Return all items in a collection until a filter matches\n$s.where({$_.Status -eq 'Running'},'Until')\n# Return the first N items in a collection until a filter matches\n$s.where({$_.Status -eq 'Running'},'Until', 1)\n# Return a collection of all items matching a filter, followed by a collection of all other items\n$collections = $s.where({$_.Status -eq 'Running'},'Split')\n$collections[0]\n$collections[1]\n# Return a collection of the first N items matching a filter, followed by a collection of all other items\n$collections = $s.where({$_.Status -eq 'Running'},'Split',2)\n$collections[0]\n$collections[1]\n# Return all items in a collection matching a filter\n$s.where({$_.Status -eq 'Running'},'Default')\n# Return the first N items in a collection matching a filter.\n$s.where({$_.Status -eq 'Running'},'Default',3)\n##################\n# Fun with strings\n##################\n# Expand PowerShell variables/subexpressions in a string\n$value = Get-Date\n$s = 'The value of `$value is \"${value}\".'\n$s.Expand()\n# Compare string values against collections\n$s = 'Hello'\n$s.MatchAny('^b','o$')\n$s.LikeAny('b*','*o')\n# Calculate the MD5 hash of a string\n'Hello'.GetMD5Hash()\n#########################\n# Fun with secure strings\n#########################\n$ss = ConvertTo-SecureString -String 'P0w3r$h31!' -AsPlainText -Force\n# Calculate the MD5 hash of the unencrypted string\n$ss.GetMD5Hash()\n# Show the unencrypted string\n$ss.Peek()\n```\n\nOther type extensions are included that are designed for use in specific\nscenarios. Module Local Storage (MLS) is a term that was created as part\nof this module, and it is used to refer to local storage locations for\nthe current user or for all users where a module can store and retrieve\ninformation from files on disk that are related to that module. MLS will\nalways refer to accessible folders on the local system, even for modules\nthat are loaded from file shares or other locations. The following examples\nillustrate how you can use type extensions to work with MLS via extensions\nthat have been added to the System.Management.Automation.PSModuleInfo type:\n\n```powershell\n#########################################\n# Working with Module Local Storage (MLS)\n#########################################\n# From inside a module, get the MLS location for the current user\n$ExecutionContext.SessionState.Module.GetLocalStoragePath($true)\n# From inside a module, get the MLS location for all users\n$ExecutionContext.SessionState.Module.GetLocalStoragePath()\n```\n\nThere are also extensions that make some tasks easier when working with\nadvanved functions. The following examples demonstrate methods that have\nbeen added to the System.Management.Automation.PSScriptCmdlet type:\n\n```powershell\n#################################\n# Working with Advanced functions\n#################################\n# Retrieve any paging parameters that were used as a splattable hashtable\n$PSCmdlet.GetBoundPagingParameters()\n# Retrieve any should process parameters that were used as a splattable hashtable\n$PSCmdlet.GetBoundShouldProcessParameters()\n# Retrieve specific parameters that were used as a splattable hashtable\n$PSCmdlet.GetBoundParameters('Name','Type')\n# Retrieve all parameters in a splattable hashtable\n$PSCmdlet.GetBoundParameters()\n# Throw a terminating error if incompatible parameters are used together\n$PSCmdlet.ValidateParameterIncompatibility('Session',@('ServerName'))\n# Throw a terminating error if parameters required when other parameters are used are missing\n$PSCmdlet.ValidateParameterDependency('AsPlainText',@('Force'))\n# Throw a property structured terminating error when a command is not found\n$PSCmdlet.ThrowCommandNotFoundError('This-DoesNotExist')\n# Throw a property structured terminating error\n$message = 'An item was not found.'\n$exceptionType = 'System.Management.Automation.ItemNotFoundException'\n$errorCategory = [System.Management.Automation.ErrorCategory]::ObjectNotFound\n$relatedObject = $null\n$PSCmdlet.ThrowError($message,$exceptionType,$errorCategory,$relatedObject)\n# Throw an exception as a terminating error\n$exception = New-Object -TypeName System.Management.Automation.ItemNotFoundException -ArgumentList 'An item was not found.'\n$errorCategory = [System.Management.Automation.ErrorCategory]::ObjectNotFound\n$relatedObject = $null\n$PSCmdlet.ThrowException($exception,$errorCategory,$relatedObject)\n```\n\nThat should give you a good idea of the kind of power that is included in this\nmodule. This is something that will grow and evolve over time, and if you have\nvalue to add, please contribute!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirkmunro%2Ftypepx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirkmunro%2Ftypepx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirkmunro%2Ftypepx/lists"}